diff options
| author | Nicole Mazzuca <mazzucan@outlook.com> | 2019-08-09 11:16:35 -0700 |
|---|---|---|
| committer | nicole mazzuca <mazzucan@outlook.com> | 2019-08-16 19:40:53 -0700 |
| commit | 300e21d59ebfe42e118cf4e97887f0680fbcfa2f (patch) | |
| tree | be8e7550056df9f049044e05dbcb2e5c0910662b | |
| parent | 5d1751dfda36199ae307825e38c80c3dc283b075 (diff) | |
| download | vcpkg-300e21d59ebfe42e118cf4e97887f0680fbcfa2f.tar.gz vcpkg-300e21d59ebfe42e118cf4e97887f0680fbcfa2f.zip | |
[vcpkg] Major tool CMakeLists.txt updates
- Add the "VCPKG_DEVELOPMENT_WARNINGS" flag
- setting "WERROR" will also set this flag
- This flag is set by default
- on GCC/clang, this will pass '-Wall -Wextra -Wpedantic -Werror'
- on GCC, this will additionally pass '-Wmissing-declarations'
- on clang, this will additionally pass '-Wmissing-prototypes'
- on MSVC, this will pass '-W4 -WX'
- On Visual Studio 2017 and later, pass '-permissive-'
- Change the source for fallout of these changes
- add `format` subcommand
- formats all C++ source and header files using clang-format
- move `include/vcpkg-test/catch.h` to `include/catch2/catch.hpp`
- pass CONFIGURE_DEPENDS to file(GLOB)
41 files changed, 635 insertions, 574 deletions
diff --git a/scripts/bootstrap.sh b/scripts/bootstrap.sh index 09d77b07d..afdd9c1b3 100644 --- a/scripts/bootstrap.sh +++ b/scripts/bootstrap.sh @@ -249,7 +249,7 @@ buildDir="$vcpkgRootDir/toolsrc/build.rel" rm -rf "$buildDir" mkdir -p "$buildDir" -(cd "$buildDir" && CXX=$CXX "$cmakeExe" .. -DCMAKE_BUILD_TYPE=Release -G "Ninja" "-DCMAKE_MAKE_PROGRAM=$ninjaExe" "-DBUILD_TESTING=OFF" "-DDEFINE_DISABLE_METRICS=$vcpkgDisableMetrics" "-DVCPKG_ALLOW_APPLE_CLANG=$vcpkgAllowAppleClang") || exit 1 +(cd "$buildDir" && CXX=$CXX "$cmakeExe" .. -DCMAKE_BUILD_TYPE=Release -G "Ninja" "-DCMAKE_MAKE_PROGRAM=$ninjaExe" "-DBUILD_TESTING=OFF" "-DVCPKG_DEVELOPMENT_WARNINGS=Off" "-DDEFINE_DISABLE_METRICS=$vcpkgDisableMetrics" "-DVCPKG_ALLOW_APPLE_CLANG=$vcpkgAllowAppleClang") || exit 1 (cd "$buildDir" && "$cmakeExe" --build .) || exit 1 rm -rf "$vcpkgRootDir/vcpkg" diff --git a/toolsrc/CMakeLists.txt b/toolsrc/CMakeLists.txt index 7245179f2..3ae7cdae5 100644 --- a/toolsrc/CMakeLists.txt +++ b/toolsrc/CMakeLists.txt @@ -2,10 +2,17 @@ cmake_minimum_required(VERSION 3.14) project(vcpkg C CXX)
-OPTION(BUILD_TESTING "Option for enabling testing" ON)
-OPTION(VCPKG_BUILD_BENCHMARKING "Option for enabling benchmarking" OFF)
OPTION(DEFINE_DISABLE_METRICS "Option for disabling metrics" OFF)
OPTION(VCPKG_ALLOW_APPLE_CLANG "Option for allowing apple clang" OFF)
+OPTION(VCPKG_DEVELOPMENT_WARNINGS "Option for turning on all warnings, and making them errors" ON)
+OPTION(BUILD_TESTING "Option for enabling testing" ON)
+OPTION(VCPKG_BUILD_BENCHMARKING "Option for enabling benchmarking" OFF)
+
+# for backwards compatibility with existing code
+if (WERROR)
+ set(VCPKG_DEVELOPMENT_WARNINGS On)
+endif()
+
if (DEFINE_DISABLE_METRICS)
set(DISABLE_METRICS_VALUE "1")
@@ -27,33 +34,10 @@ If you would like to try anyway, pass --allowAppleClang to bootstrap.sh.") endif()
elseif(CMAKE_CXX_COMPILER_ID MATCHES "[Cc]lang")
set(CLANG 1)
-elseif(MSVC)
- add_compile_options(/FC)
-else()
+elseif(NOT MSVC)
message(FATAL_ERROR "Unknown compiler: ${CMAKE_CXX_COMPILER_ID}")
endif()
-if(GCC OR (CLANG AND NOT MSVC))
- if(WERROR)
- add_compile_options(-Wall -Wno-unknown-pragmas -Werror)
- endif()
-endif()
-
-if (DEFINE_DISABLE_METRICS)
- set(DISABLE_METRICS_VALUE "1")
-else()
- set(DISABLE_METRICS_VALUE "0")
-endif()
-
-file(GLOB_RECURSE VCPKGLIB_SOURCES src/vcpkg/*.cpp)
-
-add_library(vcpkglib OBJECT ${VCPKGLIB_SOURCES})
-add_executable(vcpkg src/vcpkg.cpp $<TARGET_OBJECTS:vcpkglib>)
-
-target_compile_features(vcpkg PRIVATE cxx_std_17)
-target_compile_definitions(vcpkg PRIVATE -DDISABLE_METRICS=${DISABLE_METRICS_VALUE})
-target_include_directories(vcpkg PRIVATE include)
-
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
@@ -61,7 +45,7 @@ add_definitions(-DDISABLE_METRICS=${DISABLE_METRICS_VALUE}) include_directories(include)
link_libraries(Threads::Threads)
-if(CLANG)
+if(CLANG AND NOT MSVC)
include(CheckCXXSourceCompiles)
check_cxx_source_compiles("#include <iostream>
int main() { return __GLIBCXX__; }" USES_LIBSTDCXX)
@@ -73,31 +57,70 @@ if(CLANG) endif()
if(GCC OR (CLANG AND USES_LIBSTDCXX))
- target_link_libraries(vcpkg PRIVATE stdc++fs)
+ link_libraries(stdc++fs)
elseif(CLANG AND NOT MSVC)
- target_link_libraries(vcpkg PRIVATE c++fs)
+ link_libraries(c++fs)
endif()
-if(GCC OR CLANG)
+if(MSVC)
+ # either MSVC, or clang-cl
+ add_compile_options(-FC)
+
+ if (MSVC_VERSION GREATER 1900)
+ # Visual Studio 2017 or later
+ add_compile_options(-std:c++17 -permissive-)
+ else()
+ # Visual Studio 2015
+ add_compile_options(-std:c++latest)
+ endif()
+
+ if(VCPKG_DEVELOPMENT_WARNINGS)
+ string(REGEX REPLACE "/W[0-4]" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
+ add_compile_options(-W4 -WX)
+
+ if (CLANG)
+ add_compile_options(-Wmissing-prototypes -Wno-missing-field-initializers)
+ endif()
+ endif()
+elseif(GCC OR CLANG)
add_compile_options(-std=c++1z)
- if(WERROR)
- add_compile_options(-Wall -Wno-unknown-pragmas -Werror)
+
+ if(VCPKG_DEVELOPMENT_WARNINGS)
+ add_compile_options(-Wall -Wextra -Wpedantic -Wno-unknown-pragmas -Wno-missing-field-initializers -Werror)
+
+ # GCC and clang have different names for the same warning
+ if (GCC)
+ add_compile_options(-Wmissing-declarations)
+ elseif(CLANG)
+ add_compile_options(-Wmissing-prototypes)
+ endif()
endif()
endif()
+file(GLOB_RECURSE VCPKGLIB_SOURCES CONFIGURE_DEPENDS src/vcpkg/*.cpp)
+
+add_library(vcpkglib OBJECT ${VCPKGLIB_SOURCES})
+add_executable(vcpkg src/vcpkg.cpp $<TARGET_OBJECTS:vcpkglib>)
+
if (BUILD_TESTING)
- file(GLOB_RECURSE VCPKGTEST_SOURCES src/vcpkg-test/*.cpp)
+ file(GLOB_RECURSE VCPKGTEST_SOURCES CONFIGURE_DEPENDS src/vcpkg-test/*.cpp)
enable_testing()
add_executable(vcpkg-test
${VCPKGTEST_SOURCES}
$<TARGET_OBJECTS:vcpkglib>)
- add_test(NAME default COMMAND vcpkg-test [${TEST_NAME}])
+ add_test(NAME default COMMAND vcpkg-test)
if (VCPKG_BUILD_BENCHMARKING)
target_compile_options(vcpkg-test PRIVATE -DCATCH_CONFIG_ENABLE_BENCHMARKING)
endif()
+
+ find_program(CLANG_FORMAT clang-format)
+ if (CLANG_FORMAT)
+ file(GLOB_RECURSE VCPKG_FORMAT_SOURCES CONFIGURE_DEPENDS src/*.cpp include/pch.h include/vcpkg/*.h include/vcpkg-test/*.h)
+ add_custom_target(format COMMAND ${CLANG_FORMAT} -i -verbose ${VCPKG_FORMAT_SOURCES})
+ endif()
endif()
if(MSVC)
diff --git a/toolsrc/include/vcpkg-test/catch.h b/toolsrc/include/catch2/catch.hpp index 303f664ff..303f664ff 100644 --- a/toolsrc/include/vcpkg-test/catch.h +++ b/toolsrc/include/catch2/catch.hpp diff --git a/toolsrc/include/vcpkg-test/util.h b/toolsrc/include/vcpkg-test/util.h index 8a458a3e5..259b0ba7e 100644 --- a/toolsrc/include/vcpkg-test/util.h +++ b/toolsrc/include/vcpkg-test/util.h @@ -1,4 +1,4 @@ -#include <vcpkg-test/catch.h> +#include <catch2/catch.hpp> #include <vcpkg/pragmas.h> #include <vcpkg/base/files.h> diff --git a/toolsrc/include/vcpkg/base/chrono.h b/toolsrc/include/vcpkg/base/chrono.h index 89cd15273..118e9c382 100644 --- a/toolsrc/include/vcpkg/base/chrono.h +++ b/toolsrc/include/vcpkg/base/chrono.h @@ -56,7 +56,7 @@ namespace vcpkg::Chrono static Optional<CTime> get_current_date_time(); static Optional<CTime> parse(CStringView str); - constexpr CTime() noexcept : m_tm{0} {} + constexpr CTime() noexcept : m_tm{} {} explicit constexpr CTime(tm t) noexcept : m_tm{t} {} CTime add_hours(const int hours) const; diff --git a/toolsrc/include/vcpkg/base/graphs.h b/toolsrc/include/vcpkg/base/graphs.h index 9901a49a0..683735b1c 100644 --- a/toolsrc/include/vcpkg/base/graphs.h +++ b/toolsrc/include/vcpkg/base/graphs.h @@ -46,7 +46,7 @@ namespace vcpkg::Graphs if (!r) return; for (auto i = c.size(); i > 1; --i) { - auto j = r->random(static_cast<int>(i)); + std::size_t j = r->random(static_cast<int>(i)); if (j != i - 1) { std::swap(c[i - 1], c[j]); diff --git a/toolsrc/include/vcpkg/base/util.h b/toolsrc/include/vcpkg/base/util.h index 90c947aa9..40022a012 100644 --- a/toolsrc/include/vcpkg/base/util.h +++ b/toolsrc/include/vcpkg/base/util.h @@ -221,9 +221,8 @@ namespace vcpkg::Util } } - template<class T> - void unused(T&& param) + template<class... Ts> + void unused(const Ts&...) { - (void)param; } } diff --git a/toolsrc/src/vcpkg-test/arguments.cpp b/toolsrc/src/vcpkg-test/arguments.cpp index 3fe5fa420..326b07579 100644 --- a/toolsrc/src/vcpkg-test/arguments.cpp +++ b/toolsrc/src/vcpkg-test/arguments.cpp @@ -1,4 +1,4 @@ -#include <vcpkg-test/catch.h> +#include <catch2/catch.hpp> #include <vcpkg/vcpkgcmdarguments.h> diff --git a/toolsrc/src/vcpkg-test/catch.cpp b/toolsrc/src/vcpkg-test/catch.cpp index 8b5d1aa15..50331c644 100644 --- a/toolsrc/src/vcpkg-test/catch.cpp +++ b/toolsrc/src/vcpkg-test/catch.cpp @@ -1,5 +1,5 @@ #define CATCH_CONFIG_RUNNER -#include <vcpkg-test/catch.h> +#include <catch2/catch.hpp> #include <vcpkg/base/system.debug.h> diff --git a/toolsrc/src/vcpkg-test/chrono.cpp b/toolsrc/src/vcpkg-test/chrono.cpp index 306217ad0..fb8a0dee9 100644 --- a/toolsrc/src/vcpkg-test/chrono.cpp +++ b/toolsrc/src/vcpkg-test/chrono.cpp @@ -1,4 +1,4 @@ -#include <vcpkg-test/catch.h> +#include <catch2/catch.hpp> #include <vcpkg/base/chrono.h> diff --git a/toolsrc/src/vcpkg-test/dependencies.cpp b/toolsrc/src/vcpkg-test/dependencies.cpp index 5ed05cc07..2344bb990 100644 --- a/toolsrc/src/vcpkg-test/dependencies.cpp +++ b/toolsrc/src/vcpkg-test/dependencies.cpp @@ -1,4 +1,4 @@ -#include <vcpkg-test/catch.h> +#include <catch2/catch.hpp> #include <vcpkg/sourceparagraph.h> diff --git a/toolsrc/src/vcpkg-test/files.cpp b/toolsrc/src/vcpkg-test/files.cpp index d40edb3bd..d8bc5ba74 100644 --- a/toolsrc/src/vcpkg-test/files.cpp +++ b/toolsrc/src/vcpkg-test/files.cpp @@ -1,4 +1,4 @@ -#include <vcpkg-test/catch.h> +#include <catch2/catch.hpp> #include <vcpkg-test/util.h> #include <vcpkg/base/files.h> @@ -107,7 +107,7 @@ namespace CHECK_EC_ON_FILE(base, ec); } - for (int i = 0; i < width; ++i) + for (std::uint64_t i = 0; i < width; ++i) { create_directory_tree(urbg, fs, diff --git a/toolsrc/src/vcpkg-test/paragraph.cpp b/toolsrc/src/vcpkg-test/paragraph.cpp index a95879cfa..85c37851d 100644 --- a/toolsrc/src/vcpkg-test/paragraph.cpp +++ b/toolsrc/src/vcpkg-test/paragraph.cpp @@ -1,4 +1,4 @@ -#include <vcpkg-test/catch.h> +#include <catch2/catch.hpp> #include <vcpkg-test/util.h> #include <vcpkg/base/strings.h> diff --git a/toolsrc/src/vcpkg-test/plan.cpp b/toolsrc/src/vcpkg-test/plan.cpp index 049ef2066..e354b7551 100644 --- a/toolsrc/src/vcpkg-test/plan.cpp +++ b/toolsrc/src/vcpkg-test/plan.cpp @@ -1,4 +1,4 @@ -#include <vcpkg-test/catch.h> +#include <catch2/catch.hpp> #include <vcpkg-test/util.h> #include <vcpkg/dependencies.h> diff --git a/toolsrc/src/vcpkg-test/specifier.cpp b/toolsrc/src/vcpkg-test/specifier.cpp index 330a96d78..33df8ba83 100644 --- a/toolsrc/src/vcpkg-test/specifier.cpp +++ b/toolsrc/src/vcpkg-test/specifier.cpp @@ -1,4 +1,4 @@ -#include <vcpkg-test/catch.h> +#include <catch2/catch.hpp> #include <vcpkg/base/util.h> #include <vcpkg/packagespec.h> @@ -131,4 +131,4 @@ TEST_CASE ("specifier parsing", "[specifier]") REQUIRE(str == L"abc -x86-windows"); } #endif -}; +} diff --git a/toolsrc/src/vcpkg-test/statusparagraphs.cpp b/toolsrc/src/vcpkg-test/statusparagraphs.cpp index c0833e8ba..88b499118 100644 --- a/toolsrc/src/vcpkg-test/statusparagraphs.cpp +++ b/toolsrc/src/vcpkg-test/statusparagraphs.cpp @@ -1,4 +1,4 @@ -#include <vcpkg-test/catch.h> +#include <catch2/catch.hpp> #include <vcpkg-test/util.h> #include <vcpkg/base/util.h> diff --git a/toolsrc/src/vcpkg-test/strings.cpp b/toolsrc/src/vcpkg-test/strings.cpp index 6b744eee6..d58d1b172 100644 --- a/toolsrc/src/vcpkg-test/strings.cpp +++ b/toolsrc/src/vcpkg-test/strings.cpp @@ -1,4 +1,4 @@ -#include <vcpkg-test/catch.h> +#include <catch2/catch.hpp> #include <vcpkg/base/strings.h> diff --git a/toolsrc/src/vcpkg-test/supports.cpp b/toolsrc/src/vcpkg-test/supports.cpp index 8bd386da0..f4d8dc65a 100644 --- a/toolsrc/src/vcpkg-test/supports.cpp +++ b/toolsrc/src/vcpkg-test/supports.cpp @@ -1,4 +1,4 @@ -#include <vcpkg-test/catch.h> +#include <catch2/catch.hpp> #include <vcpkg/sourceparagraph.h> diff --git a/toolsrc/src/vcpkg-test/update.cpp b/toolsrc/src/vcpkg-test/update.cpp index 70b2f04c1..6f1a87d23 100644 --- a/toolsrc/src/vcpkg-test/update.cpp +++ b/toolsrc/src/vcpkg-test/update.cpp @@ -1,4 +1,4 @@ -#include <vcpkg-test/catch.h> +#include <catch2/catch.hpp> #include <vcpkg-test/util.h> #include <vcpkg/base/sortedvector.h> diff --git a/toolsrc/src/vcpkg-test/util.cpp b/toolsrc/src/vcpkg-test/util.cpp index a2343c21b..daa21567d 100644 --- a/toolsrc/src/vcpkg-test/util.cpp +++ b/toolsrc/src/vcpkg-test/util.cpp @@ -1,8 +1,9 @@ -#include <vcpkg-test/catch.h> +#include <catch2/catch.hpp> #include <vcpkg-test/util.h> #include <vcpkg/base/checks.h> #include <vcpkg/base/files.h> +#include <vcpkg/base/util.h> #include <vcpkg/statusparagraph.h> // used to get the implementation specific compiler flags (i.e., __cpp_lib_filesystem) @@ -153,7 +154,7 @@ namespace vcpkg::Test ec.assign(errno, std::system_category()); } #else - static_cast<void>(ec); + Util::unused(target, file, ec); vcpkg::Checks::exit_with_message(VCPKG_LINE_INFO, no_filesystem_message); #endif } @@ -175,7 +176,7 @@ namespace vcpkg::Test #elif FILESYSTEM_SYMLINK == FILESYSTEM_SYMLINK_UNIX ::vcpkg::Test::create_symlink(target, file, ec); #else - static_cast<void>(ec); + Util::unused(target, file, ec); vcpkg::Checks::exit_with_message(VCPKG_LINE_INFO, no_filesystem_message); #endif } diff --git a/toolsrc/src/vcpkg.cpp b/toolsrc/src/vcpkg.cpp index 3fdbd0d3e..9cd0ddf19 100644 --- a/toolsrc/src/vcpkg.cpp +++ b/toolsrc/src/vcpkg.cpp @@ -53,7 +53,7 @@ static constexpr int SURVEY_INTERVAL_IN_HOURS = 24 * 30 * 6; // Initial survey appears after 10 days. Therefore, subtract 24 hours/day * 10 days static constexpr int SURVEY_INITIAL_OFFSET_IN_HOURS = SURVEY_INTERVAL_IN_HOURS - 24 * 10; -void invalid_command(const std::string& cmd) +static void invalid_command(const std::string& cmd) { System::print2(System::Color::error, "invalid command: ", cmd, '\n'); Help::print_usage(); @@ -285,6 +285,8 @@ static std::string trim_path_from_command_line(const std::string& full_command_l #endif #if defined(_WIN32) +// note: this prevents a false positive for -Wmissing-prototypes on clang-cl +int wmain(int, const wchar_t* const*); int wmain(const int argc, const wchar_t* const* const argv) #else int main(const int argc, const char* const* const argv) diff --git a/toolsrc/src/vcpkg/base/hash.cpp b/toolsrc/src/vcpkg/base/hash.cpp index e9a7fa2ef..62a01ed17 100644 --- a/toolsrc/src/vcpkg/base/hash.cpp +++ b/toolsrc/src/vcpkg/base/hash.cpp @@ -1,5 +1,7 @@ #include "pch.h" +#include <vcpkg/base/hash.h> + #include <vcpkg/base/checks.h> #include <vcpkg/base/strings.h> #include <vcpkg/base/system.process.h> diff --git a/toolsrc/src/vcpkg/base/system.cpp b/toolsrc/src/vcpkg/base/system.cpp index 3d5c60088..d9c6349be 100644 --- a/toolsrc/src/vcpkg/base/system.cpp +++ b/toolsrc/src/vcpkg/base/system.cpp @@ -5,6 +5,7 @@ #include <vcpkg/base/system.debug.h> #include <vcpkg/base/system.h> #include <vcpkg/base/system.process.h> +#include <vcpkg/base/util.h> #include <ctime> @@ -381,6 +382,8 @@ namespace vcpkg "CreateProcessW() returned ", exit_code, " after ", static_cast<int>(timer.microseconds()), " us\n"); return static_cast<int>(exit_code); #else + // TODO: this should create a clean environment on Linux/macOS + Util::unused(extra_env, prepend_to_path); Debug::print("system(", cmd_line, ")\n"); fflush(nullptr); int rc = system(cmd_line.c_str()); @@ -549,10 +552,7 @@ namespace vcpkg return Strings::to_utf8(ret); } #else - Optional<std::string> System::get_registry_string(void* base_hkey, StringView sub_key, StringView valuename) - { - return nullopt; - } + Optional<std::string> System::get_registry_string(void*, StringView, StringView) { return nullopt; } #endif static const Optional<fs::path>& get_program_files() diff --git a/toolsrc/src/vcpkg/base/system.print.cpp b/toolsrc/src/vcpkg/base/system.print.cpp index c7c9981a7..fc8e4184c 100644 --- a/toolsrc/src/vcpkg/base/system.print.cpp +++ b/toolsrc/src/vcpkg/base/system.print.cpp @@ -1,6 +1,7 @@ #include "pch.h" #include <vcpkg/base/system.print.h> +#include <vcpkg/base/util.h> namespace vcpkg::System { @@ -21,6 +22,9 @@ namespace vcpkg::System System::print2(message); SetConsoleTextAttribute(console_handle, original_color); #else + // TODO: add color handling code + // it should probably use VT-220 codes + Util::unused(c); System::print2(message); #endif } diff --git a/toolsrc/src/vcpkg/build.cpp b/toolsrc/src/vcpkg/build.cpp index d7ba5fd18..2114b7415 100644 --- a/toolsrc/src/vcpkg/build.cpp +++ b/toolsrc/src/vcpkg/build.cpp @@ -184,7 +184,7 @@ namespace vcpkg::Build static const std::string LIBRARY_LINKAGE = "LibraryLinkage";
}
- CStringView to_vcvarsall_target(const std::string& cmake_system_name)
+ static CStringView to_vcvarsall_target(const std::string& cmake_system_name)
{
if (cmake_system_name.empty()) return "";
if (cmake_system_name == "Windows") return "";
@@ -193,7 +193,7 @@ namespace vcpkg::Build Checks::exit_with_message(VCPKG_LINE_INFO, "Unsupported vcvarsall target %s", cmake_system_name);
}
- CStringView to_vcvarsall_toolchain(const std::string& target_architecture, const Toolset& toolset)
+ static CStringView to_vcvarsall_toolchain(const std::string& target_architecture, const Toolset& toolset)
{
auto maybe_target_arch = System::to_cpu_architecture(target_architecture);
Checks::check_exit(
@@ -217,7 +217,7 @@ namespace vcpkg::Build }));
}
- std::unordered_map<std::string, std::string> make_env_passthrough(const PreBuildInfo& pre_build_info)
+ static auto make_env_passthrough(const PreBuildInfo& pre_build_info) -> std::unordered_map<std::string, std::string>
{
std::unordered_map<std::string, std::string> env;
diff --git a/toolsrc/src/vcpkg/commands.autocomplete.cpp b/toolsrc/src/vcpkg/commands.autocomplete.cpp index 3cf4dd98f..8449b7096 100644 --- a/toolsrc/src/vcpkg/commands.autocomplete.cpp +++ b/toolsrc/src/vcpkg/commands.autocomplete.cpp @@ -19,8 +19,8 @@ namespace vcpkg::Commands::Autocomplete Checks::exit_success(line_info); } - std::vector<std::string> combine_port_with_triplets(const std::string& port, - const std::vector<std::string>& triplets) + static std::vector<std::string> combine_port_with_triplets(const std::string& port, + const std::vector<std::string>& triplets) { return Util::fmap(triplets, [&](const std::string& triplet) { return Strings::format("%s:%s", port, triplet); }); diff --git a/toolsrc/src/vcpkg/commands.dependinfo.cpp b/toolsrc/src/vcpkg/commands.dependinfo.cpp index 8ca88dd56..faf207980 100644 --- a/toolsrc/src/vcpkg/commands.dependinfo.cpp +++ b/toolsrc/src/vcpkg/commands.dependinfo.cpp @@ -18,216 +18,222 @@ using vcpkg::Dependencies::PathsPortFileProvider; namespace vcpkg::Commands::DependInfo
{
- constexpr StringLiteral OPTION_DOT = "--dot";
- constexpr StringLiteral OPTION_DGML = "--dgml";
- constexpr StringLiteral OPTION_SHOW_DEPTH = "--show-depth";
- constexpr StringLiteral OPTION_MAX_RECURSE = "--max-recurse";
- constexpr StringLiteral OPTION_SORT = "--sort";
-
- constexpr int NO_RECURSE_LIMIT_VALUE = -1;
-
- constexpr std::array<CommandSwitch, 3> DEPEND_SWITCHES = {{{OPTION_DOT, "Creates graph on basis of dot"},
- {OPTION_DGML, "Creates graph on basis of dgml"},
- {OPTION_SHOW_DEPTH, "Show recursion depth in output"}}};
-
- constexpr std::array<CommandSetting, 2> DEPEND_SETTINGS = {
- {{OPTION_MAX_RECURSE, "Set max recursion depth, a value of -1 indicates no limit"},
- {OPTION_SORT,
- "Set sort order for the list of dependencies, accepted values are: lexicographical, topological (default), "
- "reverse"}}};
-
- const CommandStructure COMMAND_STRUCTURE = {
- Help::create_example_string("depend-info sqlite3"),
- 0,
- SIZE_MAX,
- {DEPEND_SWITCHES, DEPEND_SETTINGS},
- nullptr,
- };
-
- struct PackageDependInfo
+ namespace
{
- std::string package;
- int depth;
- std::set<std::string> features;
- std::vector<std::string> dependencies;
- };
+ constexpr StringLiteral OPTION_DOT = "--dot";
+ constexpr StringLiteral OPTION_DGML = "--dgml";
+ constexpr StringLiteral OPTION_SHOW_DEPTH = "--show-depth";
+ constexpr StringLiteral OPTION_MAX_RECURSE = "--max-recurse";
+ constexpr StringLiteral OPTION_SORT = "--sort";
+
+ constexpr int NO_RECURSE_LIMIT_VALUE = -1;
+
+ constexpr std::array<CommandSwitch, 3> DEPEND_SWITCHES = {
+ {{OPTION_DOT, "Creates graph on basis of dot"},
+ {OPTION_DGML, "Creates graph on basis of dgml"},
+ {OPTION_SHOW_DEPTH, "Show recursion depth in output"}}};
+
+ constexpr std::array<CommandSetting, 2> DEPEND_SETTINGS = {
+ {{OPTION_MAX_RECURSE, "Set max recursion depth, a value of -1 indicates no limit"},
+ {OPTION_SORT,
+ "Set sort order for the list of dependencies, accepted values are: lexicographical, topological "
+ "(default), "
+ "reverse"}}};
+
+ struct PackageDependInfo
+ {
+ std::string package;
+ int depth;
+ std::set<std::string> features;
+ std::vector<std::string> dependencies;
+ };
- enum SortMode
- {
- Lexicographical = 0,
- Topological,
- ReverseTopological,
- Default = Topological
- };
+ enum SortMode
+ {
+ Lexicographical = 0,
+ Topological,
+ ReverseTopological,
+ Default = Topological
+ };
- int get_max_depth(const ParsedArguments& options)
- {
- auto iter = options.settings.find(OPTION_MAX_RECURSE);
- if (iter != options.settings.end())
+ int get_max_depth(const ParsedArguments& options)
{
- std::string value = iter->second;
- try
+ auto iter = options.settings.find(OPTION_MAX_RECURSE);
+ if (iter != options.settings.end())
{
- return std::stoi(value);
- }
- catch (std::exception&)
- {
- Checks::exit_with_message(VCPKG_LINE_INFO, "Value of --max-depth must be an integer");
+ std::string value = iter->second;
+ try
+ {
+ return std::stoi(value);
+ }
+ catch (std::exception&)
+ {
+ Checks::exit_with_message(VCPKG_LINE_INFO, "Value of --max-depth must be an integer");
+ }
}
+ // No --max-depth set, default to no limit.
+ return NO_RECURSE_LIMIT_VALUE;
}
- // No --max-depth set, default to no limit.
- return NO_RECURSE_LIMIT_VALUE;
- }
- SortMode get_sort_mode(const ParsedArguments& options)
- {
- constexpr StringLiteral OPTION_SORT_LEXICOGRAPHICAL = "lexicographical";
- constexpr StringLiteral OPTION_SORT_TOPOLOGICAL = "topological";
- constexpr StringLiteral OPTION_SORT_REVERSE = "reverse";
+ SortMode get_sort_mode(const ParsedArguments& options)
+ {
+ constexpr StringLiteral OPTION_SORT_LEXICOGRAPHICAL = "lexicographical";
+ constexpr StringLiteral OPTION_SORT_TOPOLOGICAL = "topological";
+ constexpr StringLiteral OPTION_SORT_REVERSE = "reverse";
- static const std::map<std::string, SortMode> sortModesMap{{OPTION_SORT_LEXICOGRAPHICAL, Lexicographical},
- {OPTION_SORT_TOPOLOGICAL, Topological},
- {OPTION_SORT_REVERSE, ReverseTopological}};
+ static const std::map<std::string, SortMode> sortModesMap{{OPTION_SORT_LEXICOGRAPHICAL, Lexicographical},
+ {OPTION_SORT_TOPOLOGICAL, Topological},
+ {OPTION_SORT_REVERSE, ReverseTopological}};
- auto iter = options.settings.find(OPTION_SORT);
- if (iter != options.settings.end())
- {
- const std::string value = Strings::ascii_to_lowercase(std::string{iter->second});
- auto it = sortModesMap.find(value);
- if (it != sortModesMap.end())
+ auto iter = options.settings.find(OPTION_SORT);
+ if (iter != options.settings.end())
{
- return it->second;
+ const std::string value = Strings::ascii_to_lowercase(std::string{iter->second});
+ auto it = sortModesMap.find(value);
+ if (it != sortModesMap.end())
+ {
+ return it->second;
+ }
+ Checks::exit_with_message(VCPKG_LINE_INFO,
+ "Value of --sort must be one of `%s`, `%s`, or `%s`",
+ OPTION_SORT_LEXICOGRAPHICAL,
+ OPTION_SORT_TOPOLOGICAL,
+ OPTION_SORT_REVERSE);
}
- Checks::exit_with_message(VCPKG_LINE_INFO,
- "Value of --sort must be one of `%s`, `%s`, or `%s`",
- OPTION_SORT_LEXICOGRAPHICAL,
- OPTION_SORT_TOPOLOGICAL,
- OPTION_SORT_REVERSE);
+ return Default;
}
- return Default;
- }
- std::string create_dot_as_string(const std::vector<PackageDependInfo>& depend_info)
- {
- int empty_node_count = 0;
+ std::string create_dot_as_string(const std::vector<PackageDependInfo>& depend_info)
+ {
+ int empty_node_count = 0;
- std::string s;
- s.append("digraph G{ rankdir=LR; edge [minlen=3]; overlap=false;");
+ std::string s;
+ s.append("digraph G{ rankdir=LR; edge [minlen=3]; overlap=false;");
- for (const auto& package : depend_info)
- {
- if (package.dependencies.empty())
+ for (const auto& package : depend_info)
{
- empty_node_count++;
- continue;
- }
+ if (package.dependencies.empty())
+ {
+ empty_node_count++;
+ continue;
+ }
- const std::string name = Strings::replace_all(std::string{ package.package }, "-", "_");
- s.append(Strings::format("%s;", name));
- for (const auto &d : package.dependencies)
- {
- const std::string dependency_name = Strings::replace_all(std::string{ d }, "-", "_");
- s.append(Strings::format("%s -> %s;", name, dependency_name));
+ const std::string name = Strings::replace_all(std::string{package.package}, "-", "_");
+ s.append(Strings::format("%s;", name));
+ for (const auto& d : package.dependencies)
+ {
+ const std::string dependency_name = Strings::replace_all(std::string{d}, "-", "_");
+ s.append(Strings::format("%s -> %s;", name, dependency_name));
+ }
}
- }
-
- s.append(Strings::format("empty [label=\"%d singletons...\"]; }", empty_node_count));
- return s;
- }
- std::string create_dgml_as_string(const std::vector<PackageDependInfo>& depend_info)
- {
- std::string s;
- s.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
- s.append("<DirectedGraph xmlns=\"http://schemas.microsoft.com/vs/2009/dgml\">");
+ s.append(Strings::format("empty [label=\"%d singletons...\"]; }", empty_node_count));
+ return s;
+ }
- std::string nodes, links;
- for (const auto& package : depend_info)
+ std::string create_dgml_as_string(const std::vector<PackageDependInfo>& depend_info)
{
- const std::string name = package.package;
- nodes.append(Strings::format("<Node Id=\"%s\" />", name));
+ std::string s;
+ s.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
+ s.append("<DirectedGraph xmlns=\"http://schemas.microsoft.com/vs/2009/dgml\">");
- // Iterate over dependencies.
- for (const auto& d : package.dependencies)
+ std::string nodes, links;
+ for (const auto& package : depend_info)
{
- links.append(Strings::format("<Link Source=\"%s\" Target=\"%s\" />", name, d));
- }
- }
+ const std::string name = package.package;
+ nodes.append(Strings::format("<Node Id=\"%s\" />", name));
- s.append(Strings::format("<Nodes>%s</Nodes>", nodes));
+ // Iterate over dependencies.
+ for (const auto& d : package.dependencies)
+ {
+ links.append(Strings::format("<Link Source=\"%s\" Target=\"%s\" />", name, d));
+ }
+ }
- s.append(Strings::format("<Links>%s</Links>", links));
+ s.append(Strings::format("<Nodes>%s</Nodes>", nodes));
- s.append("</DirectedGraph>");
- return s;
- }
+ s.append(Strings::format("<Links>%s</Links>", links));
- std::string create_graph_as_string(const std::unordered_set<std::string>& switches,
- const std::vector<PackageDependInfo>& depend_info)
- {
- if (Util::Sets::contains(switches, OPTION_DOT))
- {
- return create_dot_as_string(depend_info);
+ s.append("</DirectedGraph>");
+ return s;
}
- else if (Util::Sets::contains(switches, OPTION_DGML))
+
+ std::string create_graph_as_string(const std::unordered_set<std::string>& switches,
+ const std::vector<PackageDependInfo>& depend_info)
{
- return create_dgml_as_string(depend_info);
+ if (Util::Sets::contains(switches, OPTION_DOT))
+ {
+ return create_dot_as_string(depend_info);
+ }
+ else if (Util::Sets::contains(switches, OPTION_DGML))
+ {
+ return create_dgml_as_string(depend_info);
+ }
+ return "";
}
- return "";
- }
- void assign_depth_to_dependencies(const std::string& package,
- const int depth,
- const int max_depth,
- std::map<std::string, PackageDependInfo>& dependencies_map)
- {
- auto iter = dependencies_map.find(package);
- Checks::check_exit(VCPKG_LINE_INFO, iter != dependencies_map.end(), "Package not found in dependency graph");
+ void assign_depth_to_dependencies(const std::string& package,
+ const int depth,
+ const int max_depth,
+ std::map<std::string, PackageDependInfo>& dependencies_map)
+ {
+ auto iter = dependencies_map.find(package);
+ Checks::check_exit(
+ VCPKG_LINE_INFO, iter != dependencies_map.end(), "Package not found in dependency graph");
- PackageDependInfo& info = iter->second;
+ PackageDependInfo& info = iter->second;
- if (depth > info.depth)
- {
- info.depth = depth;
- if (depth < max_depth || max_depth == NO_RECURSE_LIMIT_VALUE)
+ if (depth > info.depth)
{
- for (auto&& dependency : info.dependencies)
+ info.depth = depth;
+ if (depth < max_depth || max_depth == NO_RECURSE_LIMIT_VALUE)
{
- assign_depth_to_dependencies(dependency, depth + 1, max_depth, dependencies_map);
+ for (auto&& dependency : info.dependencies)
+ {
+ assign_depth_to_dependencies(dependency, depth + 1, max_depth, dependencies_map);
+ }
}
}
}
- };
- std::vector<PackageDependInfo> extract_depend_info(const std::vector<const InstallPlanAction*>& install_actions,
- const int max_depth)
- {
- std::map<std::string, PackageDependInfo> package_dependencies;
- for (const InstallPlanAction* pia : install_actions)
+ std::vector<PackageDependInfo> extract_depend_info(const std::vector<const InstallPlanAction*>& install_actions,
+ const int max_depth)
{
- const InstallPlanAction& install_action = *pia;
+ std::map<std::string, PackageDependInfo> package_dependencies;
+ for (const InstallPlanAction* pia : install_actions)
+ {
+ const InstallPlanAction& install_action = *pia;
- const std::vector<std::string> dependencies =
- Util::fmap(install_action.computed_dependencies, [](const PackageSpec& spec) { return spec.name(); });
+ const std::vector<std::string> dependencies = Util::fmap(
+ install_action.computed_dependencies, [](const PackageSpec& spec) { return spec.name(); });
- std::set<std::string> features{install_action.feature_list};
- features.erase("core");
+ std::set<std::string> features{install_action.feature_list};
+ features.erase("core");
- std::string port_name = install_action.spec.name();
+ std::string port_name = install_action.spec.name();
- PackageDependInfo info {port_name, -1, features, dependencies};
- package_dependencies.emplace(port_name, std::move(info));
- }
+ PackageDependInfo info{port_name, -1, features, dependencies};
+ package_dependencies.emplace(port_name, std::move(info));
+ }
- const InstallPlanAction& init = *install_actions.back();
- assign_depth_to_dependencies(init.spec.name(), 0, max_depth, package_dependencies);
+ const InstallPlanAction& init = *install_actions.back();
+ assign_depth_to_dependencies(init.spec.name(), 0, max_depth, package_dependencies);
- std::vector<PackageDependInfo> out =
- Util::fmap(package_dependencies, [](auto&& kvpair) -> PackageDependInfo { return kvpair.second; });
- Util::erase_remove_if(out, [](auto&& info) { return info.depth < 0; });
- return out;
+ std::vector<PackageDependInfo> out =
+ Util::fmap(package_dependencies, [](auto&& kvpair) -> PackageDependInfo { return kvpair.second; });
+ Util::erase_remove_if(out, [](auto&& info) { return info.depth < 0; });
+ return out;
+ }
}
+ const CommandStructure COMMAND_STRUCTURE = {
+ Help::create_example_string("depend-info sqlite3"),
+ 0,
+ SIZE_MAX,
+ {DEPEND_SWITCHES, DEPEND_SETTINGS},
+ nullptr,
+ };
+
void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths, const Triplet& default_triplet)
{
const ParsedArguments options = args.parse_arguments(COMMAND_STRUCTURE);
@@ -276,7 +282,6 @@ namespace vcpkg::Commands::DependInfo Checks::exit_success(VCPKG_LINE_INFO);
}
-
// TODO: Improve this code
auto lex = [](const PackageDependInfo& lhs, const PackageDependInfo& rhs) -> bool {
return lhs.package < rhs.package;
@@ -284,7 +289,7 @@ namespace vcpkg::Commands::DependInfo auto topo = [](const PackageDependInfo& lhs, const PackageDependInfo& rhs) -> bool {
return lhs.depth > rhs.depth;
};
- auto reverse = [topo](const PackageDependInfo& lhs, const PackageDependInfo& rhs) -> bool {
+ auto reverse = [](const PackageDependInfo& lhs, const PackageDependInfo& rhs) -> bool {
return lhs.depth < rhs.depth;
};
diff --git a/toolsrc/src/vcpkg/commands.edit.cpp b/toolsrc/src/vcpkg/commands.edit.cpp index f2f0b1569..6e98f5818 100644 --- a/toolsrc/src/vcpkg/commands.edit.cpp +++ b/toolsrc/src/vcpkg/commands.edit.cpp @@ -9,11 +9,11 @@ namespace vcpkg::Commands::Edit { +#if defined(_WIN32) static std::vector<fs::path> find_from_registry() { std::vector<fs::path> output; -#if defined(_WIN32) struct RegKey { HKEY root; @@ -42,9 +42,9 @@ namespace vcpkg::Commands::Edit output.push_back(install_path / "Code.exe"); } } -#endif return output; } +#endif static constexpr StringLiteral OPTION_BUILDTREES = "--buildtrees"; diff --git a/toolsrc/src/vcpkg/commands.exportifw.cpp b/toolsrc/src/vcpkg/commands.exportifw.cpp index 3d963a297..bc75069cd 100644 --- a/toolsrc/src/vcpkg/commands.exportifw.cpp +++ b/toolsrc/src/vcpkg/commands.exportifw.cpp @@ -13,86 +13,94 @@ namespace vcpkg::Export::IFW using Dependencies::ExportPlanType; using Install::InstallDir; - static std::string create_release_date() + namespace { - const tm date_time = Chrono::get_current_date_time_local(); + std::string create_release_date() + { + const tm date_time = Chrono::get_current_date_time_local(); - // Format is: YYYY-mm-dd - // 10 characters + 1 null terminating character will be written for a total of 11 chars - char mbstr[11]; - const size_t bytes_written = std::strftime(mbstr, sizeof(mbstr), "%Y-%m-%d", &date_time); - Checks::check_exit(VCPKG_LINE_INFO, - bytes_written == 10, - "Expected 10 bytes to be written, but %u were written", - bytes_written); - const std::string date_time_as_string(mbstr); - return date_time_as_string; - } + // Format is: YYYY-mm-dd + // 10 characters + 1 null terminating character will be written for a total of 11 chars + char mbstr[11]; + const size_t bytes_written = std::strftime(mbstr, sizeof(mbstr), "%Y-%m-%d", &date_time); + Checks::check_exit(VCPKG_LINE_INFO, + bytes_written == 10, + "Expected 10 bytes to be written, but %u were written", + bytes_written); + const std::string date_time_as_string(mbstr); + return date_time_as_string; + } - std::string safe_rich_from_plain_text(const std::string& text) - { - // match standalone ampersand, no HTML number or name - std::regex standalone_ampersand(R"###(&(?!(#[0-9]+|\w+);))###"); + std::string safe_rich_from_plain_text(const std::string& text) + { + // match standalone ampersand, no HTML number or name + std::regex standalone_ampersand(R"###(&(?!(#[0-9]+|\w+);))###"); - return std::regex_replace(text, standalone_ampersand, "&"); - } + return std::regex_replace(text, standalone_ampersand, "&"); + } - fs::path get_packages_dir_path(const std::string& export_id, const Options& ifw_options, const VcpkgPaths& paths) - { - return ifw_options.maybe_packages_dir_path.has_value() - ? fs::path(ifw_options.maybe_packages_dir_path.value_or_exit(VCPKG_LINE_INFO)) - : paths.root / (export_id + "-ifw-packages"); - } + fs::path get_packages_dir_path(const std::string& export_id, + const Options& ifw_options, + const VcpkgPaths& paths) + { + return ifw_options.maybe_packages_dir_path.has_value() + ? fs::path(ifw_options.maybe_packages_dir_path.value_or_exit(VCPKG_LINE_INFO)) + : paths.root / (export_id + "-ifw-packages"); + } - fs::path get_repository_dir_path(const std::string& export_id, const Options& ifw_options, const VcpkgPaths& paths) - { - return ifw_options.maybe_repository_dir_path.has_value() - ? fs::path(ifw_options.maybe_repository_dir_path.value_or_exit(VCPKG_LINE_INFO)) - : paths.root / (export_id + "-ifw-repository"); - } + fs::path get_repository_dir_path(const std::string& export_id, + const Options& ifw_options, + const VcpkgPaths& paths) + { + return ifw_options.maybe_repository_dir_path.has_value() + ? fs::path(ifw_options.maybe_repository_dir_path.value_or_exit(VCPKG_LINE_INFO)) + : paths.root / (export_id + "-ifw-repository"); + } - fs::path get_config_file_path(const std::string& export_id, const Options& ifw_options, const VcpkgPaths& paths) - { - return ifw_options.maybe_config_file_path.has_value() - ? fs::path(ifw_options.maybe_config_file_path.value_or_exit(VCPKG_LINE_INFO)) - : paths.root / (export_id + "-ifw-configuration.xml"); - } + fs::path get_config_file_path(const std::string& export_id, const Options& ifw_options, const VcpkgPaths& paths) + { + return ifw_options.maybe_config_file_path.has_value() + ? fs::path(ifw_options.maybe_config_file_path.value_or_exit(VCPKG_LINE_INFO)) + : paths.root / (export_id + "-ifw-configuration.xml"); + } - fs::path get_installer_file_path(const std::string& export_id, const Options& ifw_options, const VcpkgPaths& paths) - { - return ifw_options.maybe_installer_file_path.has_value() - ? fs::path(ifw_options.maybe_installer_file_path.value_or_exit(VCPKG_LINE_INFO)) - : paths.root / (export_id + "-ifw-installer.exe"); - } + fs::path get_installer_file_path(const std::string& export_id, + const Options& ifw_options, + const VcpkgPaths& paths) + { + return ifw_options.maybe_installer_file_path.has_value() + ? fs::path(ifw_options.maybe_installer_file_path.value_or_exit(VCPKG_LINE_INFO)) + : paths.root / (export_id + "-ifw-installer.exe"); + } - fs::path export_real_package(const fs::path& ifw_packages_dir_path, - const ExportPlanAction& action, - Files::Filesystem& fs) - { - std::error_code ec; + fs::path export_real_package(const fs::path& ifw_packages_dir_path, + const ExportPlanAction& action, + Files::Filesystem& fs) + { + std::error_code ec; - const BinaryParagraph& binary_paragraph = action.core_paragraph().value_or_exit(VCPKG_LINE_INFO); + const BinaryParagraph& binary_paragraph = action.core_paragraph().value_or_exit(VCPKG_LINE_INFO); - // Prepare meta dir - const fs::path package_xml_file_path = - ifw_packages_dir_path / - Strings::format("packages.%s.%s", action.spec.name(), action.spec.triplet().canonical_name()) / "meta" / - "package.xml"; - const fs::path package_xml_dir_path = package_xml_file_path.parent_path(); - fs.create_directories(package_xml_dir_path, ec); - Checks::check_exit(VCPKG_LINE_INFO, - !ec, - "Could not create directory for package file %s", - package_xml_file_path.generic_u8string()); + // Prepare meta dir + const fs::path package_xml_file_path = + ifw_packages_dir_path / + Strings::format("packages.%s.%s", action.spec.name(), action.spec.triplet().canonical_name()) / "meta" / + "package.xml"; + const fs::path package_xml_dir_path = package_xml_file_path.parent_path(); + fs.create_directories(package_xml_dir_path, ec); + Checks::check_exit(VCPKG_LINE_INFO, + !ec, + "Could not create directory for package file %s", + package_xml_file_path.generic_u8string()); - auto deps = Strings::join( - ",", binary_paragraph.depends, [](const std::string& dep) { return "packages." + dep + ":"; }); + auto deps = Strings::join( + ",", binary_paragraph.depends, [](const std::string& dep) { return "packages." + dep + ":"; }); - if (!deps.empty()) deps = "\n <Dependencies>" + deps + "</Dependencies>"; + if (!deps.empty()) deps = "\n <Dependencies>" + deps + "</Dependencies>"; - fs.write_contents(package_xml_file_path, - Strings::format( - R"###(<?xml version="1.0"?> + fs.write_contents(package_xml_file_path, + Strings::format( + R"###(<?xml version="1.0"?> <Package> <DisplayName>%s</DisplayName> <Version>%s</Version> @@ -101,111 +109,89 @@ namespace vcpkg::Export::IFW <Virtual>true</Virtual> </Package> )###", - action.spec.to_string(), - binary_paragraph.version, - create_release_date(), - action.spec.name(), - action.spec.triplet().canonical_name(), - deps), - VCPKG_LINE_INFO); - - // Return dir path for export package data - return ifw_packages_dir_path / - Strings::format("packages.%s.%s", action.spec.name(), action.spec.triplet().canonical_name()) / "data" / - "installed"; - } - - void export_unique_packages(const fs::path& raw_exported_dir_path, - std::map<std::string, const ExportPlanAction*> unique_packages, - Files::Filesystem& fs) - { - std::error_code ec; - - // packages + action.spec.to_string(), + binary_paragraph.version, + create_release_date(), + action.spec.name(), + action.spec.triplet().canonical_name(), + deps), + VCPKG_LINE_INFO); - fs::path package_xml_file_path = raw_exported_dir_path / "packages" / "meta" / "package.xml"; - fs::path package_xml_dir_path = package_xml_file_path.parent_path(); - fs.create_directories(package_xml_dir_path, ec); - Checks::check_exit(VCPKG_LINE_INFO, - !ec, - "Could not create directory for package file %s", - package_xml_file_path.generic_u8string()); - fs.write_contents(package_xml_file_path, - Strings::format( - R"###(<?xml version="1.0"?> -<Package> - <DisplayName>Packages</DisplayName> - <Version>1.0.0</Version> - <ReleaseDate>%s</ReleaseDate> -</Package> -)###", - create_release_date()), - VCPKG_LINE_INFO); + // Return dir path for export package data + return ifw_packages_dir_path / + Strings::format("packages.%s.%s", action.spec.name(), action.spec.triplet().canonical_name()) / + "data" / "installed"; + } - for (const auto& unique_package : unique_packages) + void export_unique_packages(const fs::path& raw_exported_dir_path, + std::map<std::string, const ExportPlanAction*> unique_packages, + Files::Filesystem& fs) { - const ExportPlanAction& action = *(unique_package.second); - const BinaryParagraph& binary_paragraph = action.core_paragraph().value_or_exit(VCPKG_LINE_INFO); + std::error_code ec; + + // packages - package_xml_file_path = - raw_exported_dir_path / Strings::format("packages.%s", unique_package.first) / "meta" / "package.xml"; - package_xml_dir_path = package_xml_file_path.parent_path(); + fs::path package_xml_file_path = raw_exported_dir_path / "packages" / "meta" / "package.xml"; + fs::path package_xml_dir_path = package_xml_file_path.parent_path(); fs.create_directories(package_xml_dir_path, ec); Checks::check_exit(VCPKG_LINE_INFO, !ec, "Could not create directory for package file %s", package_xml_file_path.generic_u8string()); - fs.write_contents(package_xml_file_path, Strings::format( R"###(<?xml version="1.0"?> <Package> - <DisplayName>%s</DisplayName> - <Description>%s</Description> - <Version>%s</Version> + <DisplayName>Packages</DisplayName> + <Version>1.0.0</Version> <ReleaseDate>%s</ReleaseDate> </Package> )###", - action.spec.name(), - safe_rich_from_plain_text(binary_paragraph.description), - binary_paragraph.version, create_release_date()), VCPKG_LINE_INFO); - } - } - - void export_unique_triplets(const fs::path& raw_exported_dir_path, - std::set<std::string> unique_triplets, - Files::Filesystem& fs) - { - std::error_code ec; - - // triplets - fs::path package_xml_file_path = raw_exported_dir_path / "triplets" / "meta" / "package.xml"; - fs::path package_xml_dir_path = package_xml_file_path.parent_path(); - fs.create_directories(package_xml_dir_path, ec); - Checks::check_exit(VCPKG_LINE_INFO, - !ec, - "Could not create directory for package file %s", - package_xml_file_path.generic_u8string()); - fs.write_contents(package_xml_file_path, - Strings::format( - R"###(<?xml version="1.0"?> + for (const auto& unique_package : unique_packages) + { + const ExportPlanAction& action = *(unique_package.second); + const BinaryParagraph& binary_paragraph = action.core_paragraph().value_or_exit(VCPKG_LINE_INFO); + + package_xml_file_path = raw_exported_dir_path / Strings::format("packages.%s", unique_package.first) / + "meta" / "package.xml"; + package_xml_dir_path = package_xml_file_path.parent_path(); + fs.create_directories(package_xml_dir_path, ec); + Checks::check_exit(VCPKG_LINE_INFO, + !ec, + "Could not create directory for package file %s", + package_xml_file_path.generic_u8string()); + + fs.write_contents(package_xml_file_path, + Strings::format( + R"###(<?xml version="1.0"?> <Package> - <DisplayName>Triplets</DisplayName> - <Version>1.0.0</Version> + <DisplayName>%s</DisplayName> + <Description>%s</Description> + <Version>%s</Version> <ReleaseDate>%s</ReleaseDate> </Package> )###", - create_release_date()), - VCPKG_LINE_INFO); + action.spec.name(), + safe_rich_from_plain_text(binary_paragraph.description), + binary_paragraph.version, + create_release_date()), + VCPKG_LINE_INFO); + } + } - for (const std::string& triplet : unique_triplets) + void export_unique_triplets(const fs::path& raw_exported_dir_path, + std::set<std::string> unique_triplets, + Files::Filesystem& fs) { - package_xml_file_path = - raw_exported_dir_path / Strings::format("triplets.%s", triplet) / "meta" / "package.xml"; - package_xml_dir_path = package_xml_file_path.parent_path(); + std::error_code ec; + + // triplets + + fs::path package_xml_file_path = raw_exported_dir_path / "triplets" / "meta" / "package.xml"; + fs::path package_xml_dir_path = package_xml_file_path.parent_path(); fs.create_directories(package_xml_dir_path, ec); Checks::check_exit(VCPKG_LINE_INFO, !ec, @@ -215,73 +201,95 @@ namespace vcpkg::Export::IFW Strings::format( R"###(<?xml version="1.0"?> <Package> - <DisplayName>%s</DisplayName> + <DisplayName>Triplets</DisplayName> <Version>1.0.0</Version> <ReleaseDate>%s</ReleaseDate> </Package> )###", - triplet, create_release_date()), VCPKG_LINE_INFO); + + for (const std::string& triplet : unique_triplets) + { + package_xml_file_path = + raw_exported_dir_path / Strings::format("triplets.%s", triplet) / "meta" / "package.xml"; + package_xml_dir_path = package_xml_file_path.parent_path(); + fs.create_directories(package_xml_dir_path, ec); + Checks::check_exit(VCPKG_LINE_INFO, + !ec, + "Could not create directory for package file %s", + package_xml_file_path.generic_u8string()); + fs.write_contents(package_xml_file_path, + Strings::format( + R"###(<?xml version="1.0"?> +<Package> + <DisplayName>%s</DisplayName> + <Version>1.0.0</Version> + <ReleaseDate>%s</ReleaseDate> +</Package> +)###", + triplet, + create_release_date()), + VCPKG_LINE_INFO); + } } - } - void export_integration(const fs::path& raw_exported_dir_path, Files::Filesystem& fs) - { - std::error_code ec; + void export_integration(const fs::path& raw_exported_dir_path, Files::Filesystem& fs) + { + std::error_code ec; - // integration - fs::path package_xml_file_path = raw_exported_dir_path / "integration" / "meta" / "package.xml"; - fs::path package_xml_dir_path = package_xml_file_path.parent_path(); - fs.create_directories(package_xml_dir_path, ec); - Checks::check_exit(VCPKG_LINE_INFO, - !ec, - "Could not create directory for package file %s", - package_xml_file_path.generic_u8string()); + // integration + fs::path package_xml_file_path = raw_exported_dir_path / "integration" / "meta" / "package.xml"; + fs::path package_xml_dir_path = package_xml_file_path.parent_path(); + fs.create_directories(package_xml_dir_path, ec); + Checks::check_exit(VCPKG_LINE_INFO, + !ec, + "Could not create directory for package file %s", + package_xml_file_path.generic_u8string()); - fs.write_contents(package_xml_file_path, - Strings::format( - R"###(<?xml version="1.0"?> + fs.write_contents(package_xml_file_path, + Strings::format( + R"###(<?xml version="1.0"?> <Package> <DisplayName>Integration</DisplayName> <Version>1.0.0</Version> <ReleaseDate>%s</ReleaseDate> </Package> )###", - create_release_date()), - VCPKG_LINE_INFO); - } + create_release_date()), + VCPKG_LINE_INFO); + } - void export_config(const std::string& export_id, const Options& ifw_options, const VcpkgPaths& paths) - { - std::error_code ec; - Files::Filesystem& fs = paths.get_filesystem(); + void export_config(const std::string& export_id, const Options& ifw_options, const VcpkgPaths& paths) + { + std::error_code ec; + Files::Filesystem& fs = paths.get_filesystem(); - const fs::path config_xml_file_path = get_config_file_path(export_id, ifw_options, paths); + const fs::path config_xml_file_path = get_config_file_path(export_id, ifw_options, paths); - fs::path config_xml_dir_path = config_xml_file_path.parent_path(); - fs.create_directories(config_xml_dir_path, ec); - Checks::check_exit(VCPKG_LINE_INFO, - !ec, - "Could not create directory for configuration file %s", - config_xml_file_path.generic_u8string()); + fs::path config_xml_dir_path = config_xml_file_path.parent_path(); + fs.create_directories(config_xml_dir_path, ec); + Checks::check_exit(VCPKG_LINE_INFO, + !ec, + "Could not create directory for configuration file %s", + config_xml_file_path.generic_u8string()); - std::string formatted_repo_url; - std::string ifw_repo_url = ifw_options.maybe_repository_url.value_or(""); - if (!ifw_repo_url.empty()) - { - formatted_repo_url = Strings::format(R"###( + std::string formatted_repo_url; + std::string ifw_repo_url = ifw_options.maybe_repository_url.value_or(""); + if (!ifw_repo_url.empty()) + { + formatted_repo_url = Strings::format(R"###( <RemoteRepositories> <Repository> <Url>%s</Url> </Repository> </RemoteRepositories>)###", - ifw_repo_url); - } + ifw_repo_url); + } - fs.write_contents(config_xml_file_path, - Strings::format( - R"###(<?xml version="1.0"?> + fs.write_contents(config_xml_file_path, + Strings::format( + R"###(<?xml version="1.0"?> <Installer> <Name>vcpkg</Name> <Version>1.0.0</Version> @@ -289,38 +297,38 @@ namespace vcpkg::Export::IFW <TargetDir>@RootDir@/src/vcpkg</TargetDir>%s </Installer> )###", - formatted_repo_url), - VCPKG_LINE_INFO); - } + formatted_repo_url), + VCPKG_LINE_INFO); + } - void export_maintenance_tool(const fs::path& ifw_packages_dir_path, const VcpkgPaths& paths) - { - System::print2("Exporting maintenance tool...\n"); + void export_maintenance_tool(const fs::path& ifw_packages_dir_path, const VcpkgPaths& paths) + { + System::print2("Exporting maintenance tool...\n"); - std::error_code ec; - Files::Filesystem& fs = paths.get_filesystem(); + std::error_code ec; + Files::Filesystem& fs = paths.get_filesystem(); - const fs::path& installerbase_exe = paths.get_tool_exe(Tools::IFW_INSTALLER_BASE); - fs::path tempmaintenancetool = ifw_packages_dir_path / "maintenance" / "data" / "tempmaintenancetool.exe"; - fs.create_directories(tempmaintenancetool.parent_path(), ec); - Checks::check_exit(VCPKG_LINE_INFO, - !ec, - "Could not create directory for package file %s", - tempmaintenancetool.generic_u8string()); - fs.copy_file(installerbase_exe, tempmaintenancetool, fs::copy_options::overwrite_existing, ec); - Checks::check_exit( - VCPKG_LINE_INFO, !ec, "Could not write package file %s", tempmaintenancetool.generic_u8string()); + const fs::path& installerbase_exe = paths.get_tool_exe(Tools::IFW_INSTALLER_BASE); + fs::path tempmaintenancetool = ifw_packages_dir_path / "maintenance" / "data" / "tempmaintenancetool.exe"; + fs.create_directories(tempmaintenancetool.parent_path(), ec); + Checks::check_exit(VCPKG_LINE_INFO, + !ec, + "Could not create directory for package file %s", + tempmaintenancetool.generic_u8string()); + fs.copy_file(installerbase_exe, tempmaintenancetool, fs::copy_options::overwrite_existing, ec); + Checks::check_exit( + VCPKG_LINE_INFO, !ec, "Could not write package file %s", tempmaintenancetool.generic_u8string()); - fs::path package_xml_file_path = ifw_packages_dir_path / "maintenance" / "meta" / "package.xml"; - fs::path package_xml_dir_path = package_xml_file_path.parent_path(); - fs.create_directories(package_xml_dir_path, ec); - Checks::check_exit(VCPKG_LINE_INFO, - !ec, - "Could not create directory for package file %s", - package_xml_file_path.generic_u8string()); - fs.write_contents(package_xml_file_path, - Strings::format( - R"###(<?xml version="1.0"?> + fs::path package_xml_file_path = ifw_packages_dir_path / "maintenance" / "meta" / "package.xml"; + fs::path package_xml_dir_path = package_xml_file_path.parent_path(); + fs.create_directories(package_xml_dir_path, ec); + Checks::check_exit(VCPKG_LINE_INFO, + !ec, + "Could not create directory for package file %s", + package_xml_file_path.generic_u8string()); + fs.write_contents(package_xml_file_path, + Strings::format( + R"###(<?xml version="1.0"?> <Package> <DisplayName>Maintenance Tool</DisplayName> <Description>Maintenance Tool</Description> @@ -332,82 +340,84 @@ namespace vcpkg::Export::IFW <ForcedInstallation>true</ForcedInstallation> </Package> )###", - create_release_date()), - VCPKG_LINE_INFO); - const fs::path script_source = paths.root / "scripts" / "ifw" / "maintenance.qs"; - const fs::path script_destination = ifw_packages_dir_path / "maintenance" / "meta" / "maintenance.qs"; - fs.copy_file(script_source, script_destination, fs::copy_options::overwrite_existing, ec); - Checks::check_exit( - VCPKG_LINE_INFO, !ec, "Could not write package file %s", script_destination.generic_u8string()); + create_release_date()), + VCPKG_LINE_INFO); + const fs::path script_source = paths.root / "scripts" / "ifw" / "maintenance.qs"; + const fs::path script_destination = ifw_packages_dir_path / "maintenance" / "meta" / "maintenance.qs"; + fs.copy_file(script_source, script_destination, fs::copy_options::overwrite_existing, ec); + Checks::check_exit( + VCPKG_LINE_INFO, !ec, "Could not write package file %s", script_destination.generic_u8string()); - System::print2("Exporting maintenance tool... done\n"); - } + System::print2("Exporting maintenance tool... done\n"); + } - void do_repository(const std::string& export_id, const Options& ifw_options, const VcpkgPaths& paths) - { - const fs::path& repogen_exe = paths.get_tool_exe(Tools::IFW_REPOGEN); - const fs::path packages_dir = get_packages_dir_path(export_id, ifw_options, paths); - const fs::path repository_dir = get_repository_dir_path(export_id, ifw_options, paths); + void do_repository(const std::string& export_id, const Options& ifw_options, const VcpkgPaths& paths) + { + const fs::path& repogen_exe = paths.get_tool_exe(Tools::IFW_REPOGEN); + const fs::path packages_dir = get_packages_dir_path(export_id, ifw_options, paths); + const fs::path repository_dir = get_repository_dir_path(export_id, ifw_options, paths); - System::print2("Generating repository ", repository_dir.generic_u8string(), "...\n"); + System::print2("Generating repository ", repository_dir.generic_u8string(), "...\n"); - std::error_code ec; - fs::path failure_point; - Files::Filesystem& fs = paths.get_filesystem(); + std::error_code ec; + fs::path failure_point; + Files::Filesystem& fs = paths.get_filesystem(); - fs.remove_all(repository_dir, ec, failure_point); - Checks::check_exit(VCPKG_LINE_INFO, - !ec, - "Could not remove outdated repository directory %s due to file %s", - repository_dir.generic_u8string(), - failure_point.string()); + fs.remove_all(repository_dir, ec, failure_point); + Checks::check_exit(VCPKG_LINE_INFO, + !ec, + "Could not remove outdated repository directory %s due to file %s", + repository_dir.generic_u8string(), + failure_point.string()); - const auto cmd_line = Strings::format(R"("%s" --packages "%s" "%s" > nul)", - repogen_exe.u8string(), - packages_dir.u8string(), - repository_dir.u8string()); + const auto cmd_line = Strings::format(R"("%s" --packages "%s" "%s" > nul)", + repogen_exe.u8string(), + packages_dir.u8string(), + repository_dir.u8string()); - const int exit_code = System::cmd_execute_clean(cmd_line); - Checks::check_exit(VCPKG_LINE_INFO, exit_code == 0, "Error: IFW repository generating failed"); + const int exit_code = System::cmd_execute_clean(cmd_line); + Checks::check_exit(VCPKG_LINE_INFO, exit_code == 0, "Error: IFW repository generating failed"); - System::printf( - System::Color::success, "Generating repository %s... done.\n", repository_dir.generic_u8string()); - } + System::printf( + System::Color::success, "Generating repository %s... done.\n", repository_dir.generic_u8string()); + } - void do_installer(const std::string& export_id, const Options& ifw_options, const VcpkgPaths& paths) - { - const fs::path& binarycreator_exe = paths.get_tool_exe(Tools::IFW_BINARYCREATOR); - const fs::path config_file = get_config_file_path(export_id, ifw_options, paths); - const fs::path packages_dir = get_packages_dir_path(export_id, ifw_options, paths); - const fs::path repository_dir = get_repository_dir_path(export_id, ifw_options, paths); - const fs::path installer_file = get_installer_file_path(export_id, ifw_options, paths); + void do_installer(const std::string& export_id, const Options& ifw_options, const VcpkgPaths& paths) + { + const fs::path& binarycreator_exe = paths.get_tool_exe(Tools::IFW_BINARYCREATOR); + const fs::path config_file = get_config_file_path(export_id, ifw_options, paths); + const fs::path packages_dir = get_packages_dir_path(export_id, ifw_options, paths); + const fs::path repository_dir = get_repository_dir_path(export_id, ifw_options, paths); + const fs::path installer_file = get_installer_file_path(export_id, ifw_options, paths); - System::printf("Generating installer %s...\n", installer_file.generic_u8string()); + System::printf("Generating installer %s...\n", installer_file.generic_u8string()); - std::string cmd_line; + std::string cmd_line; - std::string ifw_repo_url = ifw_options.maybe_repository_url.value_or(""); - if (!ifw_repo_url.empty()) - { - cmd_line = Strings::format(R"("%s" --online-only --config "%s" --repository "%s" "%s" > nul)", - binarycreator_exe.u8string(), - config_file.u8string(), - repository_dir.u8string(), - installer_file.u8string()); - } - else - { - cmd_line = Strings::format(R"("%s" --config "%s" --packages "%s" "%s" > nul)", - binarycreator_exe.u8string(), - config_file.u8string(), - packages_dir.u8string(), - installer_file.u8string()); - } + std::string ifw_repo_url = ifw_options.maybe_repository_url.value_or(""); + if (!ifw_repo_url.empty()) + { + cmd_line = Strings::format(R"("%s" --online-only --config "%s" --repository "%s" "%s" > nul)", + binarycreator_exe.u8string(), + config_file.u8string(), + repository_dir.u8string(), + installer_file.u8string()); + } + else + { + cmd_line = Strings::format(R"("%s" --config "%s" --packages "%s" "%s" > nul)", + binarycreator_exe.u8string(), + config_file.u8string(), + packages_dir.u8string(), + installer_file.u8string()); + } - const int exit_code = System::cmd_execute_clean(cmd_line); - Checks::check_exit(VCPKG_LINE_INFO, exit_code == 0, "Error: IFW installer generating failed"); + const int exit_code = System::cmd_execute_clean(cmd_line); + Checks::check_exit(VCPKG_LINE_INFO, exit_code == 0, "Error: IFW installer generating failed"); - System::printf(System::Color::success, "Generating installer %s... done.\n", installer_file.generic_u8string()); + System::printf( + System::Color::success, "Generating installer %s... done.\n", installer_file.generic_u8string()); + } } void do_export(const std::vector<ExportPlanAction>& export_plan, diff --git a/toolsrc/src/vcpkg/commands.xvsinstances.cpp b/toolsrc/src/vcpkg/commands.xvsinstances.cpp index 542ebd56c..a110bbb18 100644 --- a/toolsrc/src/vcpkg/commands.xvsinstances.cpp +++ b/toolsrc/src/vcpkg/commands.xvsinstances.cpp @@ -28,6 +28,7 @@ namespace vcpkg::Commands::X_VSInstances Checks::exit_success(VCPKG_LINE_INFO);
#else
+ Util::unused(args, paths);
Checks::exit_with_message(VCPKG_LINE_INFO, "This command is not supported on non-windows platforms.");
#endif
}
diff --git a/toolsrc/src/vcpkg/dependencies.cpp b/toolsrc/src/vcpkg/dependencies.cpp index 09f35d2b1..ab14934a2 100644 --- a/toolsrc/src/vcpkg/dependencies.cpp +++ b/toolsrc/src/vcpkg/dependencies.cpp @@ -13,45 +13,48 @@ namespace vcpkg::Dependencies { - struct ClusterInstalled + namespace { - InstalledPackageView ipv; - std::set<PackageSpec> remove_edges; - std::set<std::string> original_features; - }; + struct ClusterInstalled + { + InstalledPackageView ipv; + std::set<PackageSpec> remove_edges; + std::set<std::string> original_features; + }; - struct ClusterSource - { - const SourceControlFileLocation* scfl = nullptr; - std::unordered_map<std::string, std::vector<FeatureSpec>> build_edges; - }; + struct ClusterSource + { + const SourceControlFileLocation* scfl = nullptr; + std::unordered_map<std::string, std::vector<FeatureSpec>> build_edges; + }; - /// <summary> - /// Representation of a package and its features in a ClusterGraph. - /// </summary> - struct Cluster : Util::MoveOnlyBase - { - PackageSpec spec; + /// <summary> + /// Representation of a package and its features in a ClusterGraph. + /// </summary> + struct Cluster : Util::MoveOnlyBase + { + PackageSpec spec; - Optional<ClusterInstalled> installed; - Optional<ClusterSource> source; + Optional<ClusterInstalled> installed; + Optional<ClusterSource> source; - // Note: this map can contain "special" strings such as "" and "*" - std::unordered_map<std::string, bool> plus; - std::set<std::string> to_install_features; - bool minus = false; - bool transient_uninstalled = true; - RequestType request_type = RequestType::AUTO_SELECTED; - }; + // Note: this map can contain "special" strings such as "" and "*" + std::unordered_map<std::string, bool> plus; + std::set<std::string> to_install_features; + bool minus = false; + bool transient_uninstalled = true; + RequestType request_type = RequestType::AUTO_SELECTED; + }; - struct ClusterPtr - { - Cluster* ptr; + struct ClusterPtr + { + Cluster* ptr; - Cluster* operator->() const { return ptr; } - }; + Cluster* operator->() const { return ptr; } + }; - bool operator==(const ClusterPtr& l, const ClusterPtr& r) { return l.ptr == r.ptr; } + bool operator==(const ClusterPtr& l, const ClusterPtr& r) { return l.ptr == r.ptr; } + } } namespace std @@ -122,11 +125,11 @@ namespace vcpkg::Dependencies const PortFileProvider& m_provider; }; - std::string to_output_string(RequestType request_type, - const CStringView s, - const Build::BuildPackageOptions& options, - const fs::path& install_port_path, - const fs::path& default_port_path) + static std::string to_output_string(RequestType request_type, + const CStringView s, + const Build::BuildPackageOptions& options, + const fs::path& install_port_path, + const fs::path& default_port_path) { if (!default_port_path.empty() && !Strings::case_insensitive_ascii_starts_with(install_port_path.u8string(), default_port_path.u8string())) @@ -670,7 +673,7 @@ namespace vcpkg::Dependencies } } - //The feature was not previously installed. Mark the cluster + // The feature was not previously installed. Mark the cluster //(aka the entire port) to be removed before re-adding it. mark_minus(cluster, graph, graph_plan, prevent_default_features); diff --git a/toolsrc/src/vcpkg/export.cpp b/toolsrc/src/vcpkg/export.cpp index f306bf4e6..8f5034eee 100644 --- a/toolsrc/src/vcpkg/export.cpp +++ b/toolsrc/src/vcpkg/export.cpp @@ -360,6 +360,12 @@ namespace vcpkg::Export } }; +#if defined(_MSC_VER) && _MSC_VER <= 1900 +// there's a bug in VS 2015 that causes a bunch of "unreferenced local variable" warnings +#pragma warning(push) +#pragma warning(disable : 4189) +#endif + options_implies(OPTION_NUGET, ret.nuget, { @@ -376,6 +382,9 @@ namespace vcpkg::Export {OPTION_IFW_CONFIG_FILE_PATH, ret.ifw_options.maybe_config_file_path}, {OPTION_IFW_INSTALLER_FILE_PATH, ret.ifw_options.maybe_installer_file_path}, }); +#if defined(_MSC_VER) && _MSC_VER <= 1900 +#pragma warning(pop) +#endif return ret; } diff --git a/toolsrc/src/vcpkg/install.cpp b/toolsrc/src/vcpkg/install.cpp index f6330e408..1812f1624 100644 --- a/toolsrc/src/vcpkg/install.cpp +++ b/toolsrc/src/vcpkg/install.cpp @@ -174,7 +174,7 @@ namespace vcpkg::Install const std::vector<fs::path> package_file_paths = fs.get_files_recursive(package_dir); const size_t package_remove_char_count = package_dir.generic_string().size() + 1; // +1 for the slash auto package_files = Util::fmap(package_file_paths, [package_remove_char_count](const fs::path& path) { - return std::move(std::string(path.generic_string(), package_remove_char_count)); + return std::string(path.generic_string(), package_remove_char_count); }); return SortedVector<std::string>(std::move(package_files)); diff --git a/toolsrc/src/vcpkg/logicexpression.cpp b/toolsrc/src/vcpkg/logicexpression.cpp index 0cf08ee03..ccb8b00c4 100644 --- a/toolsrc/src/vcpkg/logicexpression.cpp +++ b/toolsrc/src/vcpkg/logicexpression.cpp @@ -54,9 +54,12 @@ namespace vcpkg { public: ExpressionParser(const std::string& str, const std::string& evaluation_context) - : raw_text(str), evaluation_context(evaluation_context) + : raw_text(str) + , evaluation_context(evaluation_context) + , current_iter(raw_text.begin()) + , current_char(get_current_char()) { - go_to_begin(); + skip_whitespace(); final_result = logic_expression(); @@ -77,16 +80,17 @@ namespace vcpkg bool has_error() const { return err == nullptr; } private: - bool final_result; - - std::string::const_iterator current_iter; const std::string& raw_text; + const std::string& evaluation_context; + std::string::const_iterator current_iter; char current_char; - const std::string& evaluation_context; + bool final_result; std::unique_ptr<ParseError> err; + char get_current_char() const { return (current_iter != raw_text.end() ? *current_iter : '\0'); } + void add_error(std::string message, int column = -1) { // avoid castcading errors by only saving the first @@ -105,16 +109,6 @@ namespace vcpkg int current_column() const { return static_cast<int>(current_iter - raw_text.begin()); } - void go_to_begin() - { - current_iter = raw_text.begin(); - current_char = (current_iter != raw_text.end() ? *current_iter : current_char); - - if (current_char == ' ' || current_char == '\t') - { - next_skip_whitespace(); - } - } void skip_to_end() { current_iter = raw_text.end(); @@ -126,7 +120,7 @@ namespace vcpkg if (current_char != '\0') { current_iter++; - current_char = (current_iter != raw_text.end() ? *current_iter : '\0'); + current_char = get_current_char(); } return current(); } diff --git a/toolsrc/src/vcpkg/metrics.cpp b/toolsrc/src/vcpkg/metrics.cpp index 9dd520ed6..11f613830 100644 --- a/toolsrc/src/vcpkg/metrics.cpp +++ b/toolsrc/src/vcpkg/metrics.cpp @@ -307,7 +307,9 @@ namespace vcpkg::Metrics void Metrics::upload(const std::string& payload) { -#if defined(_WIN32) +#if !defined(_WIN32) + Util::unused(payload); +#else HINTERNET connect = nullptr, request = nullptr; BOOL results = FALSE; diff --git a/toolsrc/src/vcpkg/paragraphs.cpp b/toolsrc/src/vcpkg/paragraphs.cpp index 1232b940a..9cb7caff1 100644 --- a/toolsrc/src/vcpkg/paragraphs.cpp +++ b/toolsrc/src/vcpkg/paragraphs.cpp @@ -164,7 +164,7 @@ namespace vcpkg::Paragraphs } }; - Expected<RawParagraph> parse_single_paragraph(const std::string& str) + static Expected<RawParagraph> parse_single_paragraph(const std::string& str) { const std::vector<RawParagraph> p = Parser(str.c_str(), str.c_str() + str.size()).get_paragraphs(); diff --git a/toolsrc/src/vcpkg/postbuildlint.cpp b/toolsrc/src/vcpkg/postbuildlint.cpp index c760a034f..a85d879fe 100644 --- a/toolsrc/src/vcpkg/postbuildlint.cpp +++ b/toolsrc/src/vcpkg/postbuildlint.cpp @@ -39,7 +39,7 @@ namespace vcpkg::PostBuildLint } }; - Span<const OutdatedDynamicCrt> get_outdated_dynamic_crts(const Optional<std::string>& toolset_version) + static Span<const OutdatedDynamicCrt> get_outdated_dynamic_crts(const Optional<std::string>& toolset_version) { static const std::vector<OutdatedDynamicCrt> V_NO_120 = { {"msvcp100.dll", R"(msvcp100\.dll)"}, @@ -462,7 +462,7 @@ namespace vcpkg::PostBuildLint return LintStatus::ERROR_DETECTED; } #endif - + Util::unused(expected_architecture, files); return LintStatus::SUCCESS; } diff --git a/toolsrc/src/vcpkg/statusparagraphs.cpp b/toolsrc/src/vcpkg/statusparagraphs.cpp index c642af59b..3c81728bb 100644 --- a/toolsrc/src/vcpkg/statusparagraphs.cpp +++ b/toolsrc/src/vcpkg/statusparagraphs.cpp @@ -7,8 +7,9 @@ namespace vcpkg { StatusParagraphs::StatusParagraphs() = default; - StatusParagraphs::StatusParagraphs(std::vector<std::unique_ptr<StatusParagraph>>&& ps) - : paragraphs(std::move(ps)){}; + StatusParagraphs::StatusParagraphs(std::vector<std::unique_ptr<StatusParagraph>>&& ps) : paragraphs(std::move(ps)) + { + } std::vector<std::unique_ptr<StatusParagraph>*> StatusParagraphs::find_all(const std::string& name, const Triplet& triplet) diff --git a/toolsrc/src/vcpkg/tools.cpp b/toolsrc/src/vcpkg/tools.cpp index 7d56854c6..9354493bd 100644 --- a/toolsrc/src/vcpkg/tools.cpp +++ b/toolsrc/src/vcpkg/tools.cpp @@ -274,6 +274,9 @@ namespace vcpkg const auto& program_files_32_bit = System::get_program_files_32_bit(); if (const auto pf = program_files_32_bit.get()) out_candidate_paths.push_back(*pf / "CMake" / "bin" / "cmake.exe"); +#else + // TODO: figure out if this should do anything on non-Windows + Util::unused(out_candidate_paths); #endif } virtual Optional<std::string> get_version(const fs::path& path_to_exe) const override @@ -362,6 +365,9 @@ Type 'NuGet help <command>' for help on a specific command. const auto& program_files_32_bit = System::get_program_files_32_bit(); if (const auto pf = program_files_32_bit.get()) out_candidate_paths.push_back(*pf / "git" / "cmd" / "git.exe"); +#else + // TODO: figure out if this should do anything on non-windows + Util::unused(out_candidate_paths); #endif } diff --git a/toolsrc/src/vcpkg/vcpkgpaths.cpp b/toolsrc/src/vcpkg/vcpkgpaths.cpp index bc46d2cfc..4f01ed03b 100644 --- a/toolsrc/src/vcpkg/vcpkgpaths.cpp +++ b/toolsrc/src/vcpkg/vcpkgpaths.cpp @@ -155,9 +155,9 @@ namespace vcpkg { return m_triplets_cache.get_lazy( triplet, [&]() -> auto { - for (auto&& triplet_dir : triplets_dirs) + for (const auto& triplet_dir : triplets_dirs) { - auto&& path = triplet_dir / (triplet.canonical_name() + ".cmake"); + auto path = triplet_dir / (triplet.canonical_name() + ".cmake"); if (this->get_filesystem().exists(path)) { return path; diff --git a/toolsrc/src/vcpkg/versiont.cpp b/toolsrc/src/vcpkg/versiont.cpp index d20e6b577..2c025fa1d 100644 --- a/toolsrc/src/vcpkg/versiont.cpp +++ b/toolsrc/src/vcpkg/versiont.cpp @@ -11,7 +11,6 @@ namespace vcpkg const std::string& VersionT::to_string() const { return value; } bool operator==(const VersionT& left, const VersionT& right) { return left.to_string() == right.to_string(); } bool operator!=(const VersionT& left, const VersionT& right) { return left.to_string() != right.to_string(); } - std::string to_printf_arg(const VersionT& version) { return version.to_string(); } VersionDiff::VersionDiff() noexcept : left(), right() {} VersionDiff::VersionDiff(const VersionT& left, const VersionT& right) : left(left), right(right) {} |
