diff --git a/scripts/azure-pipelines/azure-pipelines.yml b/scripts/azure-pipelines/azure-pipelines.yml index a0d9f3953f1a44..f97a3a01e7c5b3 100644 --- a/scripts/azure-pipelines/azure-pipelines.yml +++ b/scripts/azure-pipelines/azure-pipelines.yml @@ -6,6 +6,10 @@ variables: linux-pool: 'PrLin-2020-05-07' jobs: + - template: windows/run-tests.yml + parameters: + poolName: $(windows-pool) + - template: windows/azure-pipelines.yml parameters: triplet: x86-windows diff --git a/scripts/azure-pipelines/linux/azure-pipelines.yml b/scripts/azure-pipelines/linux/azure-pipelines.yml index 58e82efef48f0e..7120a9323a6650 100644 --- a/scripts/azure-pipelines/linux/azure-pipelines.yml +++ b/scripts/azure-pipelines/linux/azure-pipelines.yml @@ -24,6 +24,9 @@ jobs: displayName: 'Build vcpkg' inputs: filePath: bootstrap-vcpkg.sh + arguments: "-buildTests" + - bash: toolsrc/build.rel/vcpkg-test + displayName: 'Run vcpkg tests' - powershell: | $skipList = ./scripts/azure-pipelines/generate-skip-list.ps1 -Triplet "x64-linux" -BaselineFile "$(System.DefaultWorkingDirectory)/scripts/ci.baseline.txt" mkdir $(System.ArtifactsDirectory)/xml-results diff --git a/scripts/azure-pipelines/osx/azure-pipelines.yml b/scripts/azure-pipelines/osx/azure-pipelines.yml index 912339dfdb8a09..2427a899e732ba 100644 --- a/scripts/azure-pipelines/osx/azure-pipelines.yml +++ b/scripts/azure-pipelines/osx/azure-pipelines.yml @@ -30,7 +30,9 @@ jobs: displayName: 'Build vcpkg' inputs: filePath: bootstrap-vcpkg.sh - arguments: '-allowAppleClang' + arguments: '-buildTests' + - bash: toolsrc/build.rel/vcpkg-test + displayName: 'Run vcpkg tests' - powershell: | $skip_list = ./scripts/azure-pipelines/generate-skip-list.ps1 -Triplet "x64-osx" -BaselineFile "$(System.DefaultWorkingDirectory)/scripts/ci.baseline.txt" mkdir $(System.ArtifactsDirectory)/xml-results diff --git a/scripts/azure-pipelines/windows/run-tests.yml b/scripts/azure-pipelines/windows/run-tests.yml new file mode 100644 index 00000000000000..e6c27f70dec156 --- /dev/null +++ b/scripts/azure-pipelines/windows/run-tests.yml @@ -0,0 +1,25 @@ +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: MIT +# +# Builds and runs vcpkg-test.exe for PRs and CIs. + +jobs: +- job: windows_tests + pool: + name: ${{ parameters.poolName }} + steps: + - task: CmdLine@2 + displayName: "Build and Test vcpkg" + inputs: + script: | + :: TRANSITION, get these tools on the VMs next time we roll them + call .\bootstrap-vcpkg.bat + .\vcpkg.exe fetch cmake + .\vcpkg.exe fetch ninja + set PATH=downloads\tools\cmake-3.14.0-windows\cmake-3.14.0-win32-x86\bin;downloads\tools\ninja-1.10.0-windows;%PATH% + call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\Tools\VsDevCmd.bat" -arch=x86 -host_arch=x86 + rmdir /s /q build.x86.debug > nul 2> nul + cmake.exe -G Ninja -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTING=ON -DVCPKG_DEVELOPMENT_WARNINGS=ON -DVCPKG_WARNINGS_AS_ERRORS=ON -DVCPKG_BUILD_FUZZING=ON -B build.x86.debug -S toolsrc + ninja.exe -C build.x86.debug + build.x86.debug\vcpkg-test.exe + failOnStderr: true diff --git a/scripts/bootstrap.sh b/scripts/bootstrap.sh index c3ba881d84ae79..8567fd552392ad 100644 --- a/scripts/bootstrap.sh +++ b/scripts/bootstrap.sh @@ -18,6 +18,7 @@ fi vcpkgDisableMetrics="OFF" vcpkgUseSystem=false vcpkgAllowAppleClang=false +vcpkgBuildTests="OFF" for var in "$@" do if [ "$var" = "-disableMetrics" -o "$var" = "--disableMetrics" ]; then @@ -26,6 +27,8 @@ do vcpkgUseSystem=true elif [ "$var" = "-allowAppleClang" -o "$var" = "--allowAppleClang" ]; then vcpkgAllowAppleClang=true + elif [ "$var" = "-buildTests" ]; then + vcpkgBuildTests="ON" elif [ "$var" = "-help" -o "$var" = "--help" ]; then echo "Usage: ./bootstrap-vcpkg.sh [options]" echo @@ -240,7 +243,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" "-DVCPKG_DEVELOPMENT_WARNINGS=OFF" "-DVCPKG_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=$vcpkgBuildTests" "-DVCPKG_DEVELOPMENT_WARNINGS=OFF" "-DVCPKG_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 5f8dfa657d1f69..e940cdf16baa0f 100644 --- a/toolsrc/CMakeLists.txt +++ b/toolsrc/CMakeLists.txt @@ -51,7 +51,7 @@ if(MSVC) if(VCPKG_DEVELOPMENT_WARNINGS) string(REGEX REPLACE "[-/]W[0-4]" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") - add_compile_options(-W4) + add_compile_options(-W4 -analyze) if(VCPKG_COMPILER STREQUAL "clang") add_compile_options(-Wmissing-prototypes -Wno-missing-field-initializers) endif() diff --git a/toolsrc/include/catch2/catch.hpp b/toolsrc/include/catch2/catch.hpp index 303f664ffc3b05..f471a2ec68a3dd 100644 --- a/toolsrc/include/catch2/catch.hpp +++ b/toolsrc/include/catch2/catch.hpp @@ -11282,10 +11282,10 @@ namespace Catch { Capturer::Capturer( StringRef macroName, SourceLineInfo const& lineInfo, ResultWas::OfType resultType, StringRef names ) { auto trimmed = [&] (size_t start, size_t end) { - while (names[start] == ',' || isspace(names[start])) { + while (names[start] == ',' || isspace(static_cast(names[start]))) { ++start; } - while (names[end] == ',' || isspace(names[end])) { + while (names[end] == ',' || isspace(static_cast(names[end]))) { --end; } return names.substr(start, end - start + 1); diff --git a/toolsrc/include/pch.h b/toolsrc/include/pch.h index bdc13aedf5e41b..03e3f59f7a1a23 100644 --- a/toolsrc/include/pch.h +++ b/toolsrc/include/pch.h @@ -1,6 +1,6 @@ #pragma once -#include +#include #if defined(_WIN32) #define NOMINMAX diff --git a/toolsrc/include/vcpkg-test/util.h b/toolsrc/include/vcpkg-test/util.h index c15846d05da235..b6ea4b01de2a1b 100644 --- a/toolsrc/include/vcpkg-test/util.h +++ b/toolsrc/include/vcpkg-test/util.h @@ -1,5 +1,5 @@ #include -#include +#include #include #include diff --git a/toolsrc/include/vcpkg/base/json.h b/toolsrc/include/vcpkg/base/json.h index 3da7ed7760c926..2a1808857e3b4f 100644 --- a/toolsrc/include/vcpkg/base/json.h +++ b/toolsrc/include/vcpkg/base/json.h @@ -5,9 +5,9 @@ #include #include -#include #include #include +#include #include #include #include @@ -148,11 +148,6 @@ namespace vcpkg::Json return this->underlying_[idx]; } - void sort(const std::function& lt) - { - std::sort(this->begin(), this->end(), std::ref(lt)); - } - Array clone() const noexcept; iterator begin() { return underlying_.begin(); } @@ -205,8 +200,6 @@ namespace vcpkg::Json std::size_t size() const noexcept { return this->underlying_.size(); } - void sort_keys(const std::function& lt) noexcept; - Object clone() const noexcept; struct const_iterator diff --git a/toolsrc/include/vcpkg/base/optional.h b/toolsrc/include/vcpkg/base/optional.h index 50586ecc8d2528..0d77f4b0362242 100644 --- a/toolsrc/include/vcpkg/base/optional.h +++ b/toolsrc/include/vcpkg/base/optional.h @@ -1,5 +1,7 @@ #pragma once +#include + #include #include @@ -19,9 +21,7 @@ namespace vcpkg template::value> struct OptionalStorage { -#if defined(_WIN32) -#pragma warning(suppress : 26495) -#endif + VCPKG_MSVC_WARNING(suppress : 26495) constexpr OptionalStorage() noexcept : m_is_present(false), m_inactive() {} constexpr OptionalStorage(const T& t) : m_is_present(true), m_t(t) {} constexpr OptionalStorage(T&& t) : m_is_present(true), m_t(std::move(t)) {} @@ -31,17 +31,13 @@ namespace vcpkg if (m_is_present) m_t.~T(); } -#if defined(_WIN32) -#pragma warning(suppress : 26495) -#endif + VCPKG_MSVC_WARNING(suppress : 26495) OptionalStorage(const OptionalStorage& o) : m_is_present(o.m_is_present), m_inactive() { if (m_is_present) new (&m_t) T(o.m_t); } -#if defined(_WIN32) -#pragma warning(suppress : 26495) -#endif + VCPKG_MSVC_WARNING(suppress : 26495) OptionalStorage(OptionalStorage&& o) noexcept : m_is_present(o.m_is_present), m_inactive() { if (m_is_present) @@ -109,9 +105,7 @@ namespace vcpkg template struct OptionalStorage { -#if defined(_WIN32) -#pragma warning(suppress : 26495) -#endif + VCPKG_MSVC_WARNING(suppress : 26495) constexpr OptionalStorage() noexcept : m_is_present(false), m_inactive() {} constexpr OptionalStorage(T&& t) : m_is_present(true), m_t(std::move(t)) {} @@ -120,9 +114,7 @@ namespace vcpkg if (m_is_present) m_t.~T(); } -#if defined(_WIN32) -#pragma warning(suppress : 26495) -#endif + VCPKG_MSVC_WARNING(suppress : 26495) OptionalStorage(OptionalStorage&& o) noexcept : m_is_present(o.m_is_present), m_inactive() { if (m_is_present) diff --git a/toolsrc/include/vcpkg/pragmas.h b/toolsrc/include/vcpkg/base/pragmas.h similarity index 60% rename from toolsrc/include/vcpkg/pragmas.h rename to toolsrc/include/vcpkg/base/pragmas.h index 69b958fff10eca..97d01955ecfba7 100644 --- a/toolsrc/include/vcpkg/pragmas.h +++ b/toolsrc/include/vcpkg/base/pragmas.h @@ -14,3 +14,19 @@ // [[nodiscard]] is not recognized before GCC version 7 #pragma GCC diagnostic ignored "-Wattributes" #endif + +#if defined(_MSC_VER) +#include +#endif + +#ifndef _Analysis_assume_ +#define _Analysis_assume_(...) +#endif + +#ifdef _MSC_VER +#define VCPKG_MSVC_WARNING(...) __pragma(warning(__VA_ARGS__)) +#define GCC_DIAGNOSTIC(...) +#else +#define VCPKG_MSVC_WARNING(...) +#define GCC_DIAGNOSTIC(...) _Pragma("diagnostic " #__VA_ARGS__) +#endif diff --git a/toolsrc/include/vcpkg/base/strings.h b/toolsrc/include/vcpkg/base/strings.h index 481e686d11088a..d80e040ee4abb1 100644 --- a/toolsrc/include/vcpkg/base/strings.h +++ b/toolsrc/include/vcpkg/base/strings.h @@ -1,11 +1,12 @@ #pragma once +#include + #include #include #include #include #include -#include #include diff --git a/toolsrc/include/vcpkg/dependencies.h b/toolsrc/include/vcpkg/dependencies.h index 26ba9a67c7342e..d2eca440879f3b 100644 --- a/toolsrc/include/vcpkg/dependencies.h +++ b/toolsrc/include/vcpkg/dependencies.h @@ -10,6 +10,7 @@ #include #include +#include #include namespace vcpkg::Graphs @@ -50,7 +51,7 @@ namespace vcpkg::Dependencies InstallPlanAction(const PackageSpec& spec, const SourceControlFileLocation& scfl, const RequestType& request_type, - std::unordered_map>&& dependencies); + std::map>&& dependencies); std::string displayname() const; const std::string& public_abi() const; @@ -64,7 +65,7 @@ namespace vcpkg::Dependencies RequestType request_type; Build::BuildPackageOptions build_options; - std::unordered_map> feature_dependencies; + std::map> feature_dependencies; std::vector package_dependencies; std::vector feature_list; diff --git a/toolsrc/include/vcpkg/statusparagraph.h b/toolsrc/include/vcpkg/statusparagraph.h index 2c6d34865fbf36..fdcb5337d8c572 100644 --- a/toolsrc/include/vcpkg/statusparagraph.h +++ b/toolsrc/include/vcpkg/statusparagraph.h @@ -2,7 +2,7 @@ #include -#include +#include namespace vcpkg { @@ -56,7 +56,7 @@ namespace vcpkg const PackageSpec& spec() const { return core->package.spec; } std::vector dependencies() const; - std::unordered_map> feature_dependencies() const; + std::map> feature_dependencies() const; const StatusParagraph* core; std::vector features; diff --git a/toolsrc/src/vcpkg-test/plan.cpp b/toolsrc/src/vcpkg-test/plan.cpp index 75e8acd5817936..a39c2b4a475ad2 100644 --- a/toolsrc/src/vcpkg-test/plan.cpp +++ b/toolsrc/src/vcpkg-test/plan.cpp @@ -369,9 +369,8 @@ TEST_CASE ("basic feature test 7", "[plan]") remove_plan_check(plan.remove_actions.at(0), "x"); remove_plan_check(plan.remove_actions.at(1), "b"); - // TODO: order here may change but A < X, and B anywhere - features_check(plan.install_actions.at(0), "b", {"core", "b1"}); - features_check(plan.install_actions.at(1), "a", {"core"}); + features_check(plan.install_actions.at(0), "a", {"core"}); + features_check(plan.install_actions.at(1), "b", {"core", "b1"}); features_check(plan.install_actions.at(2), "x", {"core"}); } diff --git a/toolsrc/src/vcpkg-test/system.cpp b/toolsrc/src/vcpkg-test/system.cpp index 70424f0b54c8df..6b9dfaf953c7e0 100644 --- a/toolsrc/src/vcpkg-test/system.cpp +++ b/toolsrc/src/vcpkg-test/system.cpp @@ -1,3 +1,4 @@ +#define _POSIX_C_SOURCE 200112L #include #include @@ -27,7 +28,7 @@ using vcpkg::System::CPUArchitecture; namespace { - void set_environment_variable(StringView varname, Optional value) + void set_environment_variable(ZStringView varname, Optional value) { #if defined(_WIN32) const auto w_varname = vcpkg::Strings::to_utf16(varname); @@ -45,19 +46,14 @@ namespace check_exit(VCPKG_LINE_INFO, exit_code != 0); #else // ^^^ defined(_WIN32) / !defined(_WIN32) vvv - std::string tmp; - tmp.append(varname.data(), varname.size()); - tmp.push_back('='); if (auto v = value.get()) { - tmp.append(*v); + check_exit(VCPKG_LINE_INFO, setenv(varname.c_str(), v->c_str(), 1) == 0); + } + else + { + check_exit(VCPKG_LINE_INFO, unsetenv(varname.c_str()) == 0); } - - // putenv expects the string to never go out of scope - char* env_string = new char[tmp.size() + 1]; // overflow checked by tmp's null allocation - memcpy(env_string, tmp.data(), tmp.size()); - const int exit_code = putenv(env_string); - check_exit(VCPKG_LINE_INFO, exit_code == 0); #endif // defined(_WIN32) } diff --git a/toolsrc/src/vcpkg-test/util.cpp b/toolsrc/src/vcpkg-test/util.cpp index c615f6bb2b9760..8ead355f140bdb 100644 --- a/toolsrc/src/vcpkg-test/util.cpp +++ b/toolsrc/src/vcpkg-test/util.cpp @@ -126,7 +126,7 @@ namespace vcpkg::Test if (status == ERROR_SUCCESS && data == 1) { return AllowSymlinks::Yes; } else { - std::clog << "Symlinks are not allowed on this system\n"; + std::cout << "Symlinks are not allowed on this system\n"; return AllowSymlinks::No; } #endif diff --git a/toolsrc/src/vcpkg.cpp b/toolsrc/src/vcpkg.cpp index 39f5889158d87e..a249a3d9d0acd6 100644 --- a/toolsrc/src/vcpkg.cpp +++ b/toolsrc/src/vcpkg.cpp @@ -1,14 +1,7 @@ -#if defined(_MSC_VER) && _MSC_VER < 1911 -// [[nodiscard]] is not recognized before VS 2017 version 15.3 -#pragma warning(disable : 5030) -#endif - -#if defined(__GNUC__) && __GNUC__ < 7 -// [[nodiscard]] is not recognized before GCC version 7 -#pragma GCC diagnostic ignored "-Wattributes" -#endif +#include #if defined(_WIN32) +#define NOMINMAX #define WIN32_LEAN_AND_MEAN #include diff --git a/toolsrc/src/vcpkg/base/downloads.cpp b/toolsrc/src/vcpkg/base/downloads.cpp index 995e2d4f39dd3b..c46fe428834195 100644 --- a/toolsrc/src/vcpkg/base/downloads.cpp +++ b/toolsrc/src/vcpkg/base/downloads.cpp @@ -33,6 +33,7 @@ namespace vcpkg::Downloads url_path, target_file_path, std::to_string(err)); + _Analysis_assume_(f != nullptr); auto hSession = WinHttpOpen(L"vcpkg/1.0", IsWindows8Point1OrGreater() ? WINHTTP_ACCESS_TYPE_AUTOMATIC_PROXY diff --git a/toolsrc/src/vcpkg/base/files.cpp b/toolsrc/src/vcpkg/base/files.cpp index 8e554e4bc3dbd7..2d12b175793e9c 100644 --- a/toolsrc/src/vcpkg/base/files.cpp +++ b/toolsrc/src/vcpkg/base/files.cpp @@ -73,7 +73,7 @@ namespace vcpkg::Files constexpr auto all_write = perms::group_write | perms::owner_write | perms::others_write; permissions = perms::all & ~all_write; } - else if (ft != file_type::none && ft != file_type::none) + else if (ft != file_type::none) { permissions = perms::all; } diff --git a/toolsrc/src/vcpkg/base/strings.cpp b/toolsrc/src/vcpkg/base/strings.cpp index 46e78a36346783..d9dc4c088f575b 100644 --- a/toolsrc/src/vcpkg/base/strings.cpp +++ b/toolsrc/src/vcpkg/base/strings.cpp @@ -7,7 +7,7 @@ namespace vcpkg::Strings::details { // To disambiguate between two overloads - static bool is_space(const char c) { return std::isspace(c) != 0; } + static bool is_space(const char c) { return std::isspace(static_cast(c)) != 0; } // Avoids C4244 warnings because of char<->int conversion that occur when using std::tolower() static char tolower_char(const char c) { return (c < 'A' || c > 'Z') ? c : c - 'A' + 'a'; } diff --git a/toolsrc/src/vcpkg/base/system.process.cpp b/toolsrc/src/vcpkg/base/system.process.cpp index 4c7f712e5e1175..74c4390cc44a78 100644 --- a/toolsrc/src/vcpkg/base/system.process.cpp +++ b/toolsrc/src/vcpkg/base/system.process.cpp @@ -30,7 +30,7 @@ namespace vcpkg { struct CtrlCStateMachine { - CtrlCStateMachine() : m_number_of_external_processes(0), m_global_job(NULL), m_in_interactive(0) {} + CtrlCStateMachine() : m_number_of_external_processes(0), m_global_job(NULL), m_in_interactive(0) { } void transition_to_spawn_process() noexcept { @@ -327,29 +327,47 @@ namespace vcpkg #if defined(_WIN32) struct ProcessInfo { - constexpr ProcessInfo() : proc_info{} {} + constexpr ProcessInfo() noexcept : proc_info{} { } + ProcessInfo(ProcessInfo&& other) noexcept : proc_info(other.proc_info) + { + other.proc_info.hProcess = nullptr; + other.proc_info.hThread = nullptr; + } + ~ProcessInfo() + { + if (proc_info.hThread) + { + CloseHandle(proc_info.hThread); + } + if (proc_info.hProcess) + { + CloseHandle(proc_info.hProcess); + } + } + + ProcessInfo& operator=(ProcessInfo&& other) noexcept + { + ProcessInfo{std::move(other)}.swap(*this); + return *this; + } - unsigned int wait_and_close_handles() + void swap(ProcessInfo& other) noexcept { - CloseHandle(proc_info.hThread); + std::swap(proc_info.hProcess, other.proc_info.hProcess); + std::swap(proc_info.hThread, other.proc_info.hThread); + } + + friend void swap(ProcessInfo& lhs, ProcessInfo& rhs) noexcept { lhs.swap(rhs); } + unsigned int wait() + { const DWORD result = WaitForSingleObject(proc_info.hProcess, INFINITE); Checks::check_exit(VCPKG_LINE_INFO, result != WAIT_FAILED, "WaitForSingleObject failed"); - DWORD exit_code = 0; GetExitCodeProcess(proc_info.hProcess, &exit_code); - - CloseHandle(proc_info.hProcess); - return exit_code; } - void close_handles() - { - CloseHandle(proc_info.hThread); - CloseHandle(proc_info.hProcess); - } - PROCESS_INFORMATION proc_info; }; @@ -365,16 +383,23 @@ namespace vcpkg // Flush stdout before launching external process fflush(nullptr); - bool succeeded = TRUE == CreateProcessW(nullptr, - Strings::to_utf16(cmd_line).data(), - nullptr, - nullptr, - TRUE, - IDLE_PRIORITY_CLASS | CREATE_UNICODE_ENVIRONMENT | dwCreationFlags, - (void*)(env.m_env_data.empty() ? nullptr : env.m_env_data.data()), - nullptr, - &startup_info, - &process_info.proc_info); + +VCPKG_MSVC_WARNING(suppress : 6335) // Leaking process information handle 'process_info.proc_info.hProcess' + // /analyze can't tell that we transferred ownership here + bool succeeded = + TRUE == CreateProcessW(nullptr, + Strings::to_utf16(cmd_line).data(), + nullptr, + nullptr, + TRUE, + IDLE_PRIORITY_CLASS | CREATE_UNICODE_ENVIRONMENT | dwCreationFlags, + env.m_env_data.empty() + ? nullptr + : const_cast(static_cast(env.m_env_data.data())), + nullptr, + &startup_info, + &process_info.proc_info); + if (succeeded) return process_info; else @@ -413,7 +438,7 @@ namespace vcpkg CloseHandle(child_stdout); - return proc_info.wait_and_close_handles(); + return proc_info.wait(); } }; @@ -467,11 +492,7 @@ namespace vcpkg auto timer = Chrono::ElapsedTimer::create_started(); auto process_info = windows_create_process(cmd_line, {}, DETACHED_PROCESS | CREATE_BREAKAWAY_FROM_JOB); - if (auto p = process_info.get()) - { - p->close_handles(); - } - else + if (!process_info.get()) { Debug::print("cmd_execute_no_wait() failed with error code ", process_info.error(), "\n"); } @@ -523,7 +544,7 @@ namespace vcpkg auto proc_info = windows_create_process(cmd_line, env, NULL); auto long_exit_code = [&]() -> unsigned long { if (auto p = proc_info.get()) - return p->wait_and_close_handles(); + return p->wait(); else return proc_info.error(); }(); @@ -646,6 +667,6 @@ namespace vcpkg SetConsoleCtrlHandler(reinterpret_cast(ctrl_handler), TRUE); } #else - void System::register_console_ctrl_handler() {} + void System::register_console_ctrl_handler() { } #endif } diff --git a/toolsrc/src/vcpkg/binarycaching.cpp b/toolsrc/src/vcpkg/binarycaching.cpp index 87738c039c42d6..2ad061e2cd5639 100644 --- a/toolsrc/src/vcpkg/binarycaching.cpp +++ b/toolsrc/src/vcpkg/binarycaching.cpp @@ -288,12 +288,12 @@ ExpectedS> vcpkg::create_binary_provider_from_c auto n = match_until([](char32_t ch) { return ch == ',' || ch == '`' || ch == ';'; }); Strings::append(segment, n); auto ch = cur(); - if (ch == '\0' || ch == ',' || ch == ';') + if (ch == Unicode::end_of_file || ch == ',' || ch == ';') break; else if (ch == '`') { ch = next(); - if (ch == '\0') + if (ch == Unicode::end_of_file) add_error("unexpected eof: trailing unescaped backticks (`) are not allowed"); else Unicode::utf8_append_code_point(segment, ch); @@ -305,7 +305,7 @@ ExpectedS> vcpkg::create_binary_provider_from_c segments.emplace_back(std::move(loc), std::move(segment)); auto ch = cur(); - if (ch == '\0' || ch == ';') + if (ch == Unicode::end_of_file || ch == ';') break; else if (ch == ',') { diff --git a/toolsrc/src/vcpkg/binaryparagraph.cpp b/toolsrc/src/vcpkg/binaryparagraph.cpp index ad18b71c6c5dd6..305ae2ae901888 100644 --- a/toolsrc/src/vcpkg/binaryparagraph.cpp +++ b/toolsrc/src/vcpkg/binaryparagraph.cpp @@ -89,9 +89,11 @@ namespace vcpkg , version(spgh.version) , description(spgh.description) , maintainer(spgh.maintainer) + , feature() + , default_features(spgh.default_features) + , depends() , abi(abi_tag) , type(spgh.type) - , default_features(spgh.default_features) { this->depends = Util::fmap(deps, [](const FeatureSpec& spec) { return spec.spec().name(); }); Util::sort_unique_erase(this->depends); @@ -106,8 +108,10 @@ namespace vcpkg , description(fpgh.description) , maintainer() , feature(fpgh.name) - , type(spgh.type) , default_features() + , depends() + , abi() + , type(spgh.type) { this->depends = Util::fmap(deps, [](const FeatureSpec& spec) { return spec.spec().name(); }); Util::sort_unique_erase(this->depends); diff --git a/toolsrc/src/vcpkg/build.cpp b/toolsrc/src/vcpkg/build.cpp index 5d40e8c2437483..a1a5209704b2de 100644 --- a/toolsrc/src/vcpkg/build.cpp +++ b/toolsrc/src/vcpkg/build.cpp @@ -90,6 +90,7 @@ namespace vcpkg::Build::Command } Checks::check_exit(VCPKG_LINE_INFO, action != nullptr); + _Analysis_assume_(action != nullptr); action->build_options = build_package_options; @@ -149,6 +150,7 @@ namespace vcpkg::Build::Command const auto* scfl = provider.get_control_file(port_name).get(); Checks::check_exit(VCPKG_LINE_INFO, scfl != nullptr, "Error: Couldn't find port '%s'", port_name); + _Analysis_assume_(scfl != nullptr); perform_and_exit_ex(spec, *scfl, provider, *binaryprovider, paths); } diff --git a/toolsrc/src/vcpkg/commands.integrate.cpp b/toolsrc/src/vcpkg/commands.integrate.cpp index b427cb2475139d..e2ae967aab2f26 100644 --- a/toolsrc/src/vcpkg/commands.integrate.cpp +++ b/toolsrc/src/vcpkg/commands.integrate.cpp @@ -79,7 +79,7 @@ namespace vcpkg::Commands::Integrate dir_id.erase(1, 1); // Erasing the ":" // NuGet id cannot have invalid characters. We will only use alphanumeric and dot. - Util::erase_remove_if(dir_id, [](char c) { return !isalnum(c) && (c != '.'); }); + Util::erase_remove_if(dir_id, [](char c) { return !isalnum(static_cast(c)) && (c != '.'); }); const std::string nuget_id = "vcpkg." + dir_id; return nuget_id; diff --git a/toolsrc/src/vcpkg/dependencies.cpp b/toolsrc/src/vcpkg/dependencies.cpp index 316429515e4de2..c57f44c0e00974 100644 --- a/toolsrc/src/vcpkg/dependencies.cpp +++ b/toolsrc/src/vcpkg/dependencies.cpp @@ -39,7 +39,7 @@ namespace vcpkg::Dependencies struct ClusterInstallInfo { - std::unordered_map> build_edges; + std::map> build_edges; bool defaults_requested = false; }; @@ -294,7 +294,7 @@ namespace vcpkg::Dependencies auto end() const { return m_graph.end(); } private: - std::unordered_map m_graph; + std::map m_graph; const PortFileProvider::PortFileProvider& m_port_provider; }; @@ -352,7 +352,7 @@ namespace vcpkg::Dependencies InstallPlanAction::InstallPlanAction(const PackageSpec& spec, const SourceControlFileLocation& scfl, const RequestType& request_type, - std::unordered_map>&& dependencies) + std::map>&& dependencies) : spec(spec) , source_control_file_location(scfl) , plan_type(InstallPlanType::BUILD_AND_INSTALL) @@ -857,7 +857,7 @@ namespace vcpkg::Dependencies { auto&& scfl = p_cluster->m_scfl; - std::unordered_map> computed_edges; + std::map> computed_edges; for (auto&& kv : info_ptr->build_edges) { std::set fspecs; diff --git a/toolsrc/src/vcpkg/metrics.cpp b/toolsrc/src/vcpkg/metrics.cpp index 253ea121d66641..d85d58cd391e25 100644 --- a/toolsrc/src/vcpkg/metrics.cpp +++ b/toolsrc/src/vcpkg/metrics.cpp @@ -248,7 +248,7 @@ namespace vcpkg::Metrics ; static bool g_should_print_metrics = false; - bool get_compiled_metrics_enabled() { return VCPKG_DISABLE_METRICS == 0; } + bool get_compiled_metrics_enabled() { return !VCPKG_DISABLE_METRICS; } std::string get_MAC_user() { diff --git a/toolsrc/src/vcpkg/statusparagraph.cpp b/toolsrc/src/vcpkg/statusparagraph.cpp index ef8715ec2794b2..2f29fb6c6dd60a 100644 --- a/toolsrc/src/vcpkg/statusparagraph.cpp +++ b/toolsrc/src/vcpkg/statusparagraph.cpp @@ -86,11 +86,11 @@ namespace vcpkg } } - std::unordered_map> InstalledPackageView::feature_dependencies() const + std::map> InstalledPackageView::feature_dependencies() const { auto extract_deps = [&](const std::string& name) { return FeatureSpec{{name, spec().triplet()}, "core"}; }; - std::unordered_map> deps; + std::map> deps; deps.emplace("core", Util::fmap(core->package.depends, extract_deps)); diff --git a/toolsrc/vcpkglib/vcpkglib.vcxproj b/toolsrc/vcpkglib/vcpkglib.vcxproj index 38e0ade4092ec5..803ecb09086b16 100644 --- a/toolsrc/vcpkglib/vcpkglib.vcxproj +++ b/toolsrc/vcpkglib/vcpkglib.vcxproj @@ -158,6 +158,7 @@ + @@ -196,7 +197,6 @@ - diff --git a/toolsrc/vcpkglib/vcpkglib.vcxproj.filters b/toolsrc/vcpkglib/vcpkglib.vcxproj.filters index c663d0b8df7067..f0b8eb2e48a307 100644 --- a/toolsrc/vcpkglib/vcpkglib.vcxproj.filters +++ b/toolsrc/vcpkglib/vcpkglib.vcxproj.filters @@ -422,6 +422,9 @@ Header Files\vcpkg\base + + Header Files\vcpkg\base + Header Files\vcpkg\base @@ -440,9 +443,6 @@ Header Files\vcpkg - - Header Files\vcpkg - Header Files\vcpkg