From 300e21d59ebfe42e118cf4e97887f0680fbcfa2f Mon Sep 17 00:00:00 2001 From: Nicole Mazzuca Date: Fri, 9 Aug 2019 11:16:35 -0700 Subject: [PATCH] [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) --- scripts/bootstrap.sh | 2 +- toolsrc/CMakeLists.txt | 91 ++- .../{vcpkg-test/catch.h => catch2/catch.hpp} | 0 toolsrc/include/vcpkg-test/util.h | 2 +- toolsrc/include/vcpkg/base/chrono.h | 2 +- toolsrc/include/vcpkg/base/graphs.h | 2 +- toolsrc/include/vcpkg/base/util.h | 5 +- toolsrc/src/vcpkg-test/arguments.cpp | 2 +- toolsrc/src/vcpkg-test/catch.cpp | 2 +- toolsrc/src/vcpkg-test/chrono.cpp | 2 +- toolsrc/src/vcpkg-test/dependencies.cpp | 2 +- toolsrc/src/vcpkg-test/files.cpp | 4 +- toolsrc/src/vcpkg-test/paragraph.cpp | 2 +- toolsrc/src/vcpkg-test/plan.cpp | 2 +- toolsrc/src/vcpkg-test/specifier.cpp | 4 +- toolsrc/src/vcpkg-test/statusparagraphs.cpp | 2 +- toolsrc/src/vcpkg-test/strings.cpp | 2 +- toolsrc/src/vcpkg-test/supports.cpp | 2 +- toolsrc/src/vcpkg-test/update.cpp | 2 +- toolsrc/src/vcpkg-test/util.cpp | 7 +- toolsrc/src/vcpkg.cpp | 4 +- toolsrc/src/vcpkg/base/hash.cpp | 2 + toolsrc/src/vcpkg/base/system.cpp | 8 +- toolsrc/src/vcpkg/base/system.print.cpp | 4 + toolsrc/src/vcpkg/build.cpp | 6 +- toolsrc/src/vcpkg/commands.autocomplete.cpp | 4 +- toolsrc/src/vcpkg/commands.dependinfo.cpp | 405 ++++++------ toolsrc/src/vcpkg/commands.edit.cpp | 4 +- toolsrc/src/vcpkg/commands.exportifw.cpp | 594 +++++++++--------- toolsrc/src/vcpkg/commands.xvsinstances.cpp | 1 + toolsrc/src/vcpkg/dependencies.cpp | 77 +-- toolsrc/src/vcpkg/export.cpp | 9 + toolsrc/src/vcpkg/install.cpp | 2 +- toolsrc/src/vcpkg/logicexpression.cpp | 28 +- toolsrc/src/vcpkg/metrics.cpp | 4 +- toolsrc/src/vcpkg/paragraphs.cpp | 2 +- toolsrc/src/vcpkg/postbuildlint.cpp | 4 +- toolsrc/src/vcpkg/statusparagraphs.cpp | 5 +- toolsrc/src/vcpkg/tools.cpp | 6 + toolsrc/src/vcpkg/vcpkgpaths.cpp | 4 +- toolsrc/src/vcpkg/versiont.cpp | 1 - 41 files changed, 687 insertions(+), 626 deletions(-) rename toolsrc/include/{vcpkg-test/catch.h => catch2/catch.hpp} (100%) 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_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 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 $) + 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} $) - 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 similarity index 100% rename from toolsrc/include/vcpkg-test/catch.h rename to 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 +#include #include #include 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 get_current_date_time(); static Optional 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(i)); + std::size_t j = r->random(static_cast(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 - void unused(T&& param) + template + 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 +#include #include 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 +#include #include 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 +#include #include 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 +#include #include 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 +#include #include #include @@ -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 +#include #include #include 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 +#include #include #include 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 +#include #include #include @@ -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 +#include #include #include 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 +#include #include 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 +#include #include 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 +#include #include #include 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 +#include #include #include #include +#include #include // 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(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(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 + #include #include #include 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 #include #include +#include #include @@ -381,6 +382,8 @@ namespace vcpkg "CreateProcessW() returned ", exit_code, " after ", static_cast(timer.microseconds()), " us\n"); return static_cast(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 System::get_registry_string(void* base_hkey, StringView sub_key, StringView valuename) - { - return nullopt; - } + Optional System::get_registry_string(void*, StringView, StringView) { return nullopt; } #endif static const Optional& 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 +#include 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 make_env_passthrough(const PreBuildInfo& pre_build_info) + static auto make_env_passthrough(const PreBuildInfo& pre_build_info) -> std::unordered_map { std::unordered_map 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 combine_port_with_triplets(const std::string& port, - const std::vector& triplets) + static std::vector combine_port_with_triplets(const std::string& port, + const std::vector& 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,23 +18,213 @@ 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"; + namespace + { + 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 int NO_RECURSE_LIMIT_VALUE = -1; - constexpr std::array 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 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 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"}}}; + constexpr std::array 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 features; + std::vector dependencies; + }; + + 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()) + { + 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; + } + + 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 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()) + { + 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); + } + return Default; + } + + std::string create_dot_as_string(const std::vector& depend_info) + { + int empty_node_count = 0; + + std::string s; + s.append("digraph G{ rankdir=LR; edge [minlen=3]; overlap=false;"); + + for (const auto& package : depend_info) + { + 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)); + } + } + + s.append(Strings::format("empty [label=\"%d singletons...\"]; }", empty_node_count)); + return s; + } + + std::string create_dgml_as_string(const std::vector& depend_info) + { + std::string s; + s.append(""); + s.append(""); + + std::string nodes, links; + for (const auto& package : depend_info) + { + const std::string name = package.package; + nodes.append(Strings::format("", name)); + + // Iterate over dependencies. + for (const auto& d : package.dependencies) + { + links.append(Strings::format("", name, d)); + } + } + + s.append(Strings::format("%s", nodes)); + + s.append(Strings::format("%s", links)); + + s.append(""); + return s; + } + + std::string create_graph_as_string(const std::unordered_set& switches, + const std::vector& 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 ""; + } + + void assign_depth_to_dependencies(const std::string& package, + const int depth, + const int max_depth, + std::map& 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; + + if (depth > info.depth) + { + info.depth = depth; + if (depth < max_depth || max_depth == NO_RECURSE_LIMIT_VALUE) + { + for (auto&& dependency : info.dependencies) + { + assign_depth_to_dependencies(dependency, depth + 1, max_depth, dependencies_map); + } + } + } + } + + std::vector extract_depend_info(const std::vector& install_actions, + const int max_depth) + { + std::map package_dependencies; + for (const InstallPlanAction* pia : install_actions) + { + const InstallPlanAction& install_action = *pia; + + const std::vector dependencies = Util::fmap( + install_action.computed_dependencies, [](const PackageSpec& spec) { return spec.name(); }); + + std::set features{install_action.feature_list}; + features.erase("core"); + + std::string port_name = install_action.spec.name(); + + 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); + + std::vector 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"), @@ -44,190 +234,6 @@ namespace vcpkg::Commands::DependInfo nullptr, }; - struct PackageDependInfo - { - std::string package; - int depth; - std::set features; - std::vector dependencies; - }; - - 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()) - { - 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; - } - - 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 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()) - { - 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); - } - return Default; - } - - std::string create_dot_as_string(const std::vector& depend_info) - { - int empty_node_count = 0; - - std::string s; - s.append("digraph G{ rankdir=LR; edge [minlen=3]; overlap=false;"); - - for (const auto& package : depend_info) - { - 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)); - } - } - - s.append(Strings::format("empty [label=\"%d singletons...\"]; }", empty_node_count)); - return s; - } - - std::string create_dgml_as_string(const std::vector& depend_info) - { - std::string s; - s.append(""); - s.append(""); - - std::string nodes, links; - for (const auto& package : depend_info) - { - const std::string name = package.package; - nodes.append(Strings::format("", name)); - - // Iterate over dependencies. - for (const auto& d : package.dependencies) - { - links.append(Strings::format("", name, d)); - } - } - - s.append(Strings::format("%s", nodes)); - - s.append(Strings::format("%s", links)); - - s.append(""); - return s; - } - - std::string create_graph_as_string(const std::unordered_set& switches, - const std::vector& 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 ""; - } - - void assign_depth_to_dependencies(const std::string& package, - const int depth, - const int max_depth, - std::map& 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; - - if (depth > info.depth) - { - info.depth = depth; - if (depth < max_depth || max_depth == NO_RECURSE_LIMIT_VALUE) - { - for (auto&& dependency : info.dependencies) - { - assign_depth_to_dependencies(dependency, depth + 1, max_depth, dependencies_map); - } - } - } - }; - - std::vector extract_depend_info(const std::vector& install_actions, - const int max_depth) - { - std::map package_dependencies; - for (const InstallPlanAction* pia : install_actions) - { - const InstallPlanAction& install_action = *pia; - - const std::vector dependencies = - Util::fmap(install_action.computed_dependencies, [](const PackageSpec& spec) { return spec.name(); }); - - std::set features{install_action.feature_list}; - features.erase("core"); - - std::string port_name = install_action.spec.name(); - - 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); - - std::vector out = - Util::fmap(package_dependencies, [](auto&& kvpair) -> PackageDependInfo { return kvpair.second; }); - Util::erase_remove_if(out, [](auto&& info) { return info.depth < 0; }); - return out; - } - 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 find_from_registry() { std::vector 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 " + deps + ""; + if (!deps.empty()) deps = "\n " + deps + ""; - fs.write_contents(package_xml_file_path, - Strings::format( - R"###( + fs.write_contents(package_xml_file_path, + Strings::format( + R"###( %s %s @@ -101,64 +109,64 @@ namespace vcpkg::Export::IFW true )###", - action.spec.to_string(), - binary_paragraph.version, - create_release_date(), - action.spec.name(), - action.spec.triplet().canonical_name(), - deps), - VCPKG_LINE_INFO); + 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"; - } + // 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 unique_packages, - Files::Filesystem& fs) - { - std::error_code ec; + void export_unique_packages(const fs::path& raw_exported_dir_path, + std::map unique_packages, + Files::Filesystem& fs) + { + std::error_code ec; - // packages + // packages - 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"###( + 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"###( Packages 1.0.0 %s )###", - create_release_date()), - VCPKG_LINE_INFO); + create_release_date()), + VCPKG_LINE_INFO); - 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); + 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()); + 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"###( + fs.write_contents(package_xml_file_path, + Strings::format( + R"###( %s %s @@ -166,46 +174,24 @@ namespace vcpkg::Export::IFW %s )###", - action.spec.name(), - safe_rich_from_plain_text(binary_paragraph.description), - binary_paragraph.version, - 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); + } } - } - void export_unique_triplets(const fs::path& raw_exported_dir_path, - std::set 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"###( - - Triplets - 1.0.0 - %s - -)###", - 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 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, @@ -214,74 +200,96 @@ namespace vcpkg::Export::IFW fs.write_contents(package_xml_file_path, Strings::format( R"###( + + Triplets + 1.0.0 + %s + +)###", + 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"###( %s 1.0.0 %s )###", - triplet, - create_release_date()), - VCPKG_LINE_INFO); + 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"###( + fs.write_contents(package_xml_file_path, + Strings::format( + R"###( Integration 1.0.0 %s )###", - 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(); - - 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()); - - std::string formatted_repo_url; - std::string ifw_repo_url = ifw_options.maybe_repository_url.value_or(""); - if (!ifw_repo_url.empty()) + void export_config(const std::string& export_id, const Options& ifw_options, const VcpkgPaths& paths) { - formatted_repo_url = Strings::format(R"###( + 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); + + 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"###( %s )###", - ifw_repo_url); - } + ifw_repo_url); + } - fs.write_contents(config_xml_file_path, - Strings::format( - R"###( + fs.write_contents(config_xml_file_path, + Strings::format( + R"###( vcpkg 1.0.0 @@ -289,38 +297,38 @@ namespace vcpkg::Export::IFW @RootDir@/src/vcpkg%s )###", - 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"###( + 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"###( Maintenance Tool Maintenance Tool @@ -332,82 +340,84 @@ namespace vcpkg::Export::IFW true )###", - 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"); - } - - 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"); - - 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()); - - 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"); - - 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); - - System::printf("Generating installer %s...\n", installer_file.generic_u8string()); - - 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()); + System::print2("Exporting maintenance tool... done\n"); } - const int exit_code = System::cmd_execute_clean(cmd_line); - Checks::check_exit(VCPKG_LINE_INFO, exit_code == 0, "Error: IFW installer generating failed"); + 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::printf(System::Color::success, "Generating installer %s... done.\n", installer_file.generic_u8string()); + System::print2("Generating repository ", repository_dir.generic_u8string(), "...\n"); + + 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()); + + 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"); + + 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); + + System::printf("Generating installer %s...\n", installer_file.generic_u8string()); + + 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()); + } + + 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()); + } } void do_export(const std::vector& 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 remove_edges; - std::set original_features; - }; + struct ClusterInstalled + { + InstalledPackageView ipv; + std::set remove_edges; + std::set original_features; + }; - struct ClusterSource - { - const SourceControlFileLocation* scfl = nullptr; - std::unordered_map> build_edges; - }; + struct ClusterSource + { + const SourceControlFileLocation* scfl = nullptr; + std::unordered_map> build_edges; + }; - /// - /// Representation of a package and its features in a ClusterGraph. - /// - struct Cluster : Util::MoveOnlyBase - { - PackageSpec spec; + /// + /// Representation of a package and its features in a ClusterGraph. + /// + struct Cluster : Util::MoveOnlyBase + { + PackageSpec spec; - Optional installed; - Optional source; + Optional installed; + Optional source; - // Note: this map can contain "special" strings such as "" and "*" - std::unordered_map plus; - std::set 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 plus; + std::set 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 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::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 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(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 parse_single_paragraph(const std::string& str) + static Expected parse_single_paragraph(const std::string& str) { const std::vector 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 get_outdated_dynamic_crts(const Optional& toolset_version) + static Span get_outdated_dynamic_crts(const Optional& toolset_version) { static const std::vector 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>&& ps) - : paragraphs(std::move(ps)){}; + StatusParagraphs::StatusParagraphs(std::vector>&& ps) : paragraphs(std::move(ps)) + { + } std::vector*> 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 get_version(const fs::path& path_to_exe) const override @@ -362,6 +365,9 @@ Type 'NuGet help ' 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) {}