diff --git a/include/vcpkg/base/optional.h b/include/vcpkg/base/optional.h index 12c192957c..c18619deb9 100644 --- a/include/vcpkg/base/optional.h +++ b/include/vcpkg/base/optional.h @@ -23,205 +23,246 @@ namespace vcpkg namespace details { + struct EngageTag + { + }; + + template> + struct OptionalStorageDtor + { + bool m_is_present; + union + { + char m_inactive; + T m_t; + }; + + constexpr OptionalStorageDtor() : m_is_present(false), m_inactive() { } + template + constexpr OptionalStorageDtor(EngageTag, + Args&&... args) noexcept(std::is_nothrow_constructible_v) + : m_is_present(true), m_t(std::forward(args)...) + { + } + }; + + template + struct OptionalStorageDtor + { + bool m_is_present; + union + { + char m_inactive; + T m_t; + }; + + constexpr OptionalStorageDtor() : m_is_present(false), m_inactive() { } + template + constexpr OptionalStorageDtor(EngageTag, + Args&&... args) noexcept(std::is_nothrow_constructible_v) + : m_is_present(true), m_t(std::forward(args)...) + { + } + + ~OptionalStorageDtor() + { + if (m_is_present) + { + m_t.~T(); + } + } + }; + template> - struct OptionalStorage + struct OptionalStorage : OptionalStorageDtor { - constexpr OptionalStorage() noexcept : m_is_present(false), m_inactive() { } + OptionalStorage() = default; constexpr OptionalStorage(const T& t) noexcept(std::is_nothrow_copy_constructible_v) - : m_is_present(true), m_t(t) + : OptionalStorageDtor(EngageTag{}, t) { } constexpr OptionalStorage(T&& t) noexcept(std::is_nothrow_move_constructible_v) - : m_is_present(true), m_t(std::move(t)) + : OptionalStorageDtor(EngageTag{}, std::move(t)) { } template>> explicit OptionalStorage(Optional&& t) noexcept(std::is_nothrow_constructible_v) - : m_is_present(false), m_inactive() + : OptionalStorageDtor() { if (auto p = t.get()) { - m_is_present = true; - new (&m_t) T(std::move(*p)); + this->m_is_present = true; + new (&this->m_t) T(std::move(*p)); } } template explicit OptionalStorage(const Optional& t) noexcept(std::is_nothrow_constructible_v) - : m_is_present(false), m_inactive() + : OptionalStorageDtor() { if (auto p = t.get()) { - m_is_present = true; - new (&m_t) T(*p); + this->m_is_present = true; + new (&this->m_t) T(*p); } } - ~OptionalStorage() - { - if (m_is_present) m_t.~T(); - } - OptionalStorage(const OptionalStorage& o) noexcept(std::is_nothrow_copy_constructible_v) - : m_is_present(o.m_is_present), m_inactive() + : OptionalStorageDtor() { - if (m_is_present) new (&m_t) T(o.m_t); + if (o.m_is_present) + { + this->m_is_present = true; + new (&this->m_t) T(o.m_t); + } } OptionalStorage(OptionalStorage&& o) noexcept(std::is_nothrow_move_constructible_v) - : m_is_present(o.m_is_present), m_inactive() + : OptionalStorageDtor() { - if (m_is_present) + if (o.m_is_present) { - new (&m_t) T(std::move(o.m_t)); + this->m_is_present = true; + new (&this->m_t) T(std::move(o.m_t)); } } OptionalStorage& operator=(const OptionalStorage& o) noexcept(std::is_nothrow_copy_constructible_v && std::is_nothrow_copy_assignable_v) { - if (m_is_present && o.m_is_present) + if (this->m_is_present && o.m_is_present) { - m_t = o.m_t; + this->m_t = o.m_t; } - else if (!m_is_present && o.m_is_present) + else if (!this->m_is_present && o.m_is_present) { - new (&m_t) T(o.m_t); - m_is_present = true; + new (&this->m_t) T(o.m_t); + this->m_is_present = true; } - else if (m_is_present && !o.m_is_present) + else if (this->m_is_present && !o.m_is_present) { destroy(); } + return *this; } OptionalStorage& operator=(OptionalStorage&& o) noexcept // enforces termination { - if (m_is_present && o.m_is_present) + if (this->m_is_present && o.m_is_present) { - m_t = std::move(o.m_t); + this->m_t = std::move(o.m_t); } - else if (!m_is_present && o.m_is_present) + else if (!this->m_is_present && o.m_is_present) { - new (&m_t) T(std::move(o.m_t)); - m_is_present = true; + new (&this->m_t) T(std::move(o.m_t)); + this->m_is_present = true; } - else if (m_is_present && !o.m_is_present) + else if (this->m_is_present && !o.m_is_present) { destroy(); } return *this; } - constexpr bool has_value() const noexcept { return m_is_present; } + constexpr bool has_value() const noexcept { return this->m_is_present; } const T& value() const noexcept { return this->m_t; } T& value() noexcept { return this->m_t; } - const T* get() const& noexcept { return m_is_present ? &m_t : nullptr; } - T* get() & noexcept { return m_is_present ? &m_t : nullptr; } + const T* get() const& noexcept { return this->m_is_present ? &this->m_t : nullptr; } + T* get() & noexcept { return this->m_is_present ? &this->m_t : nullptr; } const T* get() const&& = delete; T* get() && = delete; void destroy() noexcept // enforces termination { - m_is_present = false; - m_t.~T(); - m_inactive = '\0'; + this->m_is_present = false; + this->m_t.~T(); + this->m_inactive = '\0'; } template T& emplace(Args&&... args) noexcept(std::is_nothrow_constructible_v) { - if (m_is_present) destroy(); - new (&m_t) T(static_cast(args)...); - m_is_present = true; - return m_t; + if (this->m_is_present) destroy(); + new (&this->m_t) T(static_cast(args)...); + this->m_is_present = true; + return this->m_t; } - - private: - bool m_is_present; - union - { - char m_inactive; - T m_t; - }; }; template - struct OptionalStorage + struct OptionalStorage : OptionalStorageDtor { - constexpr OptionalStorage() noexcept : m_is_present(false), m_inactive() { } + OptionalStorage() = default; constexpr OptionalStorage(T&& t) noexcept(std::is_nothrow_move_constructible_v) - : m_is_present(true), m_t(std::move(t)) + : OptionalStorageDtor(EngageTag{}, std::move(t)) { } - - ~OptionalStorage() + template>> + explicit OptionalStorage(Optional&& t) noexcept(std::is_nothrow_constructible_v) + : OptionalStorageDtor() { - if (m_is_present) m_t.~T(); + if (auto p = t.get()) + { + this->m_is_present = true; + new (&this->m_t) T(std::move(*p)); + } } - OptionalStorage(OptionalStorage&& o) noexcept(std::is_nothrow_move_constructible_v) - : m_is_present(o.m_is_present), m_inactive() + : OptionalStorageDtor() { - if (m_is_present) + if (o.m_is_present) { - new (&m_t) T(std::move(o.m_t)); + this->m_is_present = true; + new (&this->m_t) T(std::move(o.m_t)); } } OptionalStorage& operator=(OptionalStorage&& o) noexcept // enforces termination { - if (m_is_present && o.m_is_present) + if (this->m_is_present && o.m_is_present) { - m_t = std::move(o.m_t); + this->m_t = std::move(o.m_t); } - else if (!m_is_present && o.m_is_present) + else if (!this->m_is_present && o.m_is_present) { - m_is_present = true; - new (&m_t) T(std::move(o.m_t)); + this->m_is_present = true; + new (&this->m_t) T(std::move(o.m_t)); } - else if (m_is_present && !o.m_is_present) + else if (this->m_is_present && !o.m_is_present) { destroy(); } + return *this; } - constexpr bool has_value() const noexcept { return m_is_present; } + constexpr bool has_value() const noexcept { return this->m_is_present; } const T& value() const noexcept { return this->m_t; } T& value() noexcept { return this->m_t; } - const T* get() const& noexcept { return m_is_present ? &m_t : nullptr; } - T* get() & noexcept { return m_is_present ? &m_t : nullptr; } + const T* get() const& noexcept { return this->m_is_present ? &this->m_t : nullptr; } + T* get() & noexcept { return this->m_is_present ? &this->m_t : nullptr; } const T* get() const&& = delete; T* get() && = delete; template T& emplace(Args&&... args) noexcept(std::is_nothrow_constructible_v) { - if (m_is_present) destroy(); - new (&m_t) T(static_cast(args)...); - m_is_present = true; - return m_t; + if (this->m_is_present) destroy(); + new (&this->m_t) T(static_cast(args)...); + this->m_is_present = true; + return this->m_t; } void destroy() noexcept { - m_is_present = false; - m_t.~T(); - m_inactive = '\0'; + this->m_is_present = false; + this->m_t.~T(); + this->m_inactive = '\0'; } - - private: - bool m_is_present; - union - { - char m_inactive; - T m_t; - }; }; template diff --git a/src/vcpkg/tools.cpp b/src/vcpkg/tools.cpp index 81cada54e3..dfdfdef11a 100644 --- a/src/vcpkg/tools.cpp +++ b/src/vcpkg/tools.cpp @@ -74,398 +74,409 @@ namespace vcpkg StringLiteral archiveName; }; - static Optional get_raw_tool_data(StringView toolname, CPUArchitecture arch, StringView os) + static constexpr ArchToolData tool_data_table[] = { + { + "python3", + "windows", + nullopt, + "3.11.8", + "python.exe", + "https://www.python.org/ftp/python/3.11.8/python-3.11.8-embed-win32.zip", + "c88ef02f0860000dbc59361cfe051e3e8dc7d208ed39bb5bc20a3e8b8711b578926e281a11941787ea61b2ef05b945ab313332" + "2dcb85b916f79ac4ada57f6309", + "python-3.11.8-embed-win32.zip", + }, + { + "python3_with_venv", + "windows", + nullopt, + "3.11.8", + "tools/python.exe", + "https://www.nuget.org/api/v2/package/python/3.11.8", + "8c1abd622fb2795fb87ab5208764fe13f7f4d69f2283b4237ea47b7c14b0989b5b4169f1ac1d3b1f417c6c2cc3d85ce151370d" + "ae8efc807c93e57cd67fa3c8cf", + "python-3.11.8.nupkg.zip", + }, + { + "cmake", + "windows", + nullopt, + "3.29.2", + "cmake-3.29.2-windows-i386/bin/cmake.exe", + "https://github.com/Kitware/CMake/releases/download/v3.29.2/cmake-3.29.2-windows-i386.zip", + "562de7b577c99fe347b00437d14ce375a8e5a60504909cb67d2f73c372d39a2f76d2b42b69e4aeb31a4879e1bcf6f7c2d41f2a" + "ce12180ea83ba7af48879d40ab", + "cmake-3.29.2-windows-i386.zip", + }, + { + "cmake", + "osx", + nullopt, + "3.29.2", + "cmake-3.29.2-macos-universal/CMake.app/Contents/bin/cmake", + "https://github.com/Kitware/CMake/releases/download/v3.29.2/cmake-3.29.2-macos-universal.tar.gz", + "26aab0163965f3d560dfd6b1f72c5e77192338237ebe286099fd62f243f1bbd4857b9193118386b801c00dc5cfbc5bc8af8481" + "4692fcfadcf56c7d2faab52533", + "cmake-3.29.2-macos-universal.tar.gz", + }, + { + "cmake", + "linux", + CPUArchitecture::ARM64, + "3.29.2", + "cmake-3.29.2-linux-aarch64/bin/cmake", + "https://github.com/Kitware/CMake/releases/download/v3.29.2/cmake-3.29.2-linux-aarch64.tar.gz", + "206b00604caf72f3dc644c7a5ac6a335814520fbf1512b9f2d4a5e8c26025d286bd106d2925ffbc874c754c518cbdb07f16919" + "16c39fcfd1202a47f592c8e3b0", + "cmake-3.29.2-linux-aarch64.tar.gz", + }, + { + "cmake", + "linux", + nullopt, + "3.29.2", + "cmake-3.29.2-linux-x86_64/bin/cmake", + "https://github.com/Kitware/CMake/releases/download/v3.29.2/cmake-3.29.2-linux-x86_64.tar.gz", + "d88082d582f1774a3d89efbf3f31a03b08a663c359d603d87ee7c4afd862d4164d2b0b9f0b32cece8efee3acfa86b44214cd4f" + "7606b99b8334183a05d5f06edc", + "cmake-3.29.2-linux-x86_64.tar.gz", + }, + { + "git", + "windows", + nullopt, + "2.7.4", + "mingw64/bin/git.exe", + "https://github.com/git-for-windows/git/releases/download/v2.43.0.windows.1/" + "PortableGit-2.43.0-64-bit.7z.exe", + "02ec40f55a6de18f305530e9415b6ce0a597359ebb9a58cf727ac84eceb0003b0f437941b76872b6568157a333c8e6e8d865a3" + "6faf874fd5f04774deb6a9387a", + "PortableGit-2.43.0-32-bit.7z.exe", + }, + { + "git", + "linux", + nullopt, + "2.7.4", + "", + "", + "", + "", + }, + { + "git", + "osx", + nullopt, + "2.7.4", + "", + "", + "", + "", + }, + { + "git", + "freebsd", + nullopt, + "2.7.4", + "", + "", + "", + "", + }, + { + "gsutil", + "windows", + nullopt, + "4.65", + "google-cloud-sdk/bin/gsutil.cmd", + "https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/" + "google-cloud-sdk-347.0.0-windows-x86_64-bundled-python.zip", + "e2792e17b132aad77f7c0b9fd26faf415e9437923d9227a9e6d253554e6843d29a6ddad0a7fb5e9aea4a130fd4c521e6ece884" + "4fd4a4f9e8d580348775425389", + "google-cloud-sdk-347.0.0-windows-x86_64-bundled-python.zip", + }, + { + "gsutil", + "osx", + nullopt, + "4.65", + "gsutil/gsutil", + "https://storage.googleapis.com/pub/gsutil_4.65.tar.gz", + "2c5c9dea48147f97180a491bbb9e24e8cbcd4f3452620e2f80338b781e4dfc90bb754e3bbfa05e1b990e44bff52d990d8c2dd5" + "1bc83d112339d8e6096a2f21c8", + "gsutil_4.65.tar.gz", + }, + { + "gsutil", + "linux", + nullopt, + "4.65", + "gsutil/gsutil", + "https://storage.googleapis.com/pub/gsutil_4.65.tar.gz", + "2c5c9dea48147f97180a491bbb9e24e8cbcd4f3452620e2f80338b781e4dfc90bb754e3bbfa05e1b990e44bff52d990d8c2dd5" + "1bc83d112339d8e6096a2f21c8", + "gsutil_4.65.tar.gz", + }, + { + "vswhere", + "windows", + nullopt, + "3.1.7", + "vswhere.exe", + "https://github.com/microsoft/vswhere/releases/download/3.1.7/vswhere.exe", + "40c534eb27f079c15c9782f53f82c12dabfede4d3d85f0edf8a855c2b0d5e12921a96506b37c210beab3c33220f8ff098447ad" + "054e82d8c2603964975fc12076", + "", + }, + { + "nuget", + "windows", + nullopt, + "6.10.0", + "nuget.exe", + "https://dist.nuget.org/win-x86-commandline/v6.10.0/nuget.exe", + "71d7307bb89de2df3811419c561efa00618a4c68e6ce481b0bdfc94c7c6c6d126a54eb26a0015686fabf99f109744ca41fead9" + "9e97139cdc86dde16a5ec3e7cf", + "", + }, + { + "nuget", + "linux", + nullopt, + "6.10.0", + "nuget.exe", + "https://dist.nuget.org/win-x86-commandline/v6.10.0/nuget.exe", + "71d7307bb89de2df3811419c561efa00618a4c68e6ce481b0bdfc94c7c6c6d126a54eb26a0015686fabf99f109744ca41fead9" + "9e97139cdc86dde16a5ec3e7cf", + "", + }, + { + "nuget", + "osx", + nullopt, + "6.10.0", + "nuget.exe", + "https://dist.nuget.org/win-x86-commandline/v6.10.0/nuget.exe", + "71d7307bb89de2df3811419c561efa00618a4c68e6ce481b0bdfc94c7c6c6d126a54eb26a0015686fabf99f109744ca41fead9" + "9e97139cdc86dde16a5ec3e7cf", + "", + }, + { + "coscli", + "windows", + nullopt, + "0.11.0", + "coscli-windows.exe", + "https://github.com/tencentyun/coscli/releases/download/v0.11.0-beta/coscli-windows.exe", + "38a521ec80cdb6944124f4233d7e71eed8cc9f9be2c0c736269915d21c3718ea8131e4516bb6eeada6df331f5fa8f47a299907" + "e50ee9edbe0114444520974d06", + "", + }, + { + "coscli", + "linux", + nullopt, + "0.11.0", + "coscli-linux", + "https://github.com/tencentyun/coscli/releases/download/v0.11.0-beta/coscli-linux", + "9c930a1d308e9581a0e2fdfe3751ea7fe13d6068df90ca6465740ec3eda034202ef71ec54c99e90015ff81aa68aa1489567db5" + "e411e222eb7258704bdac7e924", + "", + }, + { + "coscli", + "osx", + nullopt, + "0.11.0", + "coscli-mac", + "https://github.com/tencentyun/coscli/releases/download/v0.11.0-beta/coscli-mac", + "9556335bfc8bc14bace6dfced45fa77fb07c80f08aa975e047a54efda1d19852aae0ea68a5bc7f04fbd88e3edce5a73512a612" + "16b1c5ff4cade224de4a9ab8db", + "", + }, + { + "installerbase", + "windows", + nullopt, + "4.4.0", + "QtInstallerFramework-win-x86/bin/installerbase.exe", + "https://download.qt.io/official_releases/qt-installer-framework/4.4.0/" + "installer-framework-opensource-src-4.4.0.zip", + "fc713f54bfe2781cb232cd0ae8eddb96833ec178d53a55ec0b01886aa048b13441eb49a1f33282e8eab7259cfe512c890d50b8" + "e632d3dbf501a0bf1fd83de947", + "installer-framework-opensource-src-4.4.0.zip", + }, + { + "7zip_msi", + "windows", + nullopt, + "24.08", + "Files/7-Zip/7z.exe", + "https://github.com/ip7z/7zip/releases/download/24.08/7z2408-x64.msi", + "3259bf5e251382333c9d18a3fc01d83491fb41bc4ac4ddb25a02918494594c1074482b6608189a8a89e343d78e34d57420cdef" + "f1d7ace5acfdcaacc8776f1be8", + "7z2408-x64.msi", + }, + { + "7zip", + "windows", + nullopt, + "24.08", + "7za.exe", + "https://github.com/ip7z/7zip/releases/download/24.08/7z2408-extra.7z", + "35f55236fccfb576ca014e29d0c35f4a213e53f06683bd2e82f869ed02506e230c8dd623c01d0207244d6a997031f737903456" + "b7ad4a44db1717f0a17a78602e", + "7z2408-extra.7z", + }, + { + "7zr", + "windows", + nullopt, + "24.08", + "7zr.exe", + "https://github.com/ip7z/7zip/releases/download/24.08/7zr.exe", + "424196f2acf5b89807f4038683acc50e7604223fc630245af6bab0e0df923f8b1c49cb09ac709086568c214c3f53dcb7d6c32e" + "8a54af222a3ff78cfab9c51670", + "", + }, + { + "aria2", + "windows", + nullopt, + "1.37.0", + "aria2-1.37.0-win-64bit-build1/aria2c.exe", + "https://github.com/aria2/aria2/releases/download/release-1.37.0/aria2-1.37.0-win-64bit-build1.zip", + "6d78405da9cf5639dbe8174787002161b8124d73880fb57cc8c0a3a63982f84e46df4e626990c58f23452965ad925f0d37cb91" + "47e99b25c3d7ca0ea49602f34d", + "aria2-1.37.0-win-64bit-build1.zip", + }, + { + "aria2", + "osx", + nullopt, + "1.35.0", + "aria2-1.35.0/bin/aria2c", + "https://github.com/aria2/aria2/releases/download/release-1.35.0/aria2-1.35.0-osx-darwin.tar.bz2", + "3bb32b7d55347d1af37c6f4ebf0e20b38ce51c37a1baf92f7ad1762000539a03413dd679a6d902fdb1805fa71917300c9692ac" + "eee012eb06ecdff10491137aec", + "aria2-1.35.0-osx-darwin.tar.bz2", + }, + { + "ninja", + "windows", + nullopt, + "1.11.1", + "ninja.exe", + "https://github.com/ninja-build/ninja/releases/download/v1.11.1/ninja-win.zip", + "a700e794c32eb67b9f87040db7f1ba3a8e891636696fc54d416b01661c2421ff46fa517c97fd904adacdf8e621df3e68ea3801" + "05b909ae8b6651a78ae7eb3199", + "ninja-win-1.11.1.zip", + }, + { + "ninja", + "linux", + nullopt, + "1.11.1", + "ninja", + "https://github.com/ninja-build/ninja/releases/download/v1.11.1/ninja-linux.zip", + "6403dac9196baffcff614fa73ea530752997c8db6bbfbaa0446b4b09d7327e2aa6e8615d1283c961d3bf0df497e85ba8660414" + "9f1505ee75f89d600245a45dde", + "ninja-linux-1.11.1.zip", + }, + { + "ninja", + "osx", + nullopt, + "1.11.1", + "ninja", + "https://github.com/ninja-build/ninja/releases/download/v1.11.1/ninja-mac.zip", + "dad33b0918c60bbf5107951a936175b1610b4894a408f4ba4b47a2f5b328fc982a52a2aed6a0cb75028ee4765af5083bea6661" + "1c37516826eb0c851366bb4427", + "ninja-mac-1.11.1.zip", + }, + { + "powershell-core", + "windows", + nullopt, + "7.2.23", + "pwsh.exe", + "https://github.com/PowerShell/PowerShell/releases/download/v7.2.23/PowerShell-7.2.23-win-x64.zip", + "b374a878df02980d54e17ad7cfc9021e331748c3770f586be61356c257494d1b33899c1167d09a35c210bc084474aefdff972f" + "672d16afb43be0562b3589285a", + "PowerShell-7.2.23-win-x64.zip", + }, + { + "node", + "windows", + nullopt, + "16.15.1", + "node-v16.15.1-win-x64/node.exe", + "https://nodejs.org/dist/v16.15.1/node-v16.15.1-win-x64.7z", + "7ec4bfe2ea6034e1461e306b6372d62c0c5d1060c453ba76a73a5cec38ac26b5952a744caa9071455329caa58eb0a96d26c688" + "54c8915c17610ff27b0cf2c1cf", + "node-v16.15.1-win-x64.7z", + }, + { + "node", + "linux", + nullopt, + "16.15.1", + "node-v16.15.1-linux-x64/bin/node", + "https://nodejs.org/dist/v16.15.1/node-v16.15.1-linux-x64.tar.gz", + "5ad3b4b9caeaa8d31503efa99f5a593118a267dec9d4181d019732126ba248ce9a901207115b3f6b899eb5b3f0373c7f77ea95" + "cc92ac625cddf437ee9b8b8919", + "node-v16.15.1-linux-x64.tar.gz", + }, + { + "node", + "osx", + nullopt, + "16.15.1", + "node-v16.15.1-darwin-x64/bin/node", + "https://nodejs.org/dist/v16.15.1/node-v16.15.1-darwin-x64.tar.gz", + "90d0612bbe5467b6cf385c91a68b8daad0057e3e0ccacea44567f5b95b14f7481cb79784185ab1463b4bd990e092ff0f910957" + "6d1a1934b84e1c816582929611", + "node-v16.15.1-darwin-x64.tar.gz", + }, + }; + + static const ArchToolData* get_raw_tool_data(StringView toolname, CPUArchitecture arch, StringView os) { - const std::size_t NUM_TOOLS = 33; - ArchToolData tool_data[NUM_TOOLS] = { - { - "python3", - "windows", - nullopt, - "3.11.8", - "python.exe", - "https://www.python.org/ftp/python/3.11.8/python-3.11.8-embed-win32.zip", - "c88ef02f0860000dbc59361cfe051e3e8dc7d208ed39bb5bc20a3e8b8711b578926e281a11941787ea61b2ef05b945ab313332" - "2dcb85b916f79ac4ada57f6309", - "python-3.11.8-embed-win32.zip", - }, - { - "python3_with_venv", - "windows", - nullopt, - "3.11.8", - "tools/python.exe", - "https://www.nuget.org/api/v2/package/python/3.11.8", - "8c1abd622fb2795fb87ab5208764fe13f7f4d69f2283b4237ea47b7c14b0989b5b4169f1ac1d3b1f417c6c2cc3d85ce151370d" - "ae8efc807c93e57cd67fa3c8cf", - "python-3.11.8.nupkg.zip", - }, - { - "cmake", - "windows", - nullopt, - "3.29.2", - "cmake-3.29.2-windows-i386/bin/cmake.exe", - "https://github.com/Kitware/CMake/releases/download/v3.29.2/cmake-3.29.2-windows-i386.zip", - "562de7b577c99fe347b00437d14ce375a8e5a60504909cb67d2f73c372d39a2f76d2b42b69e4aeb31a4879e1bcf6f7c2d41f2a" - "ce12180ea83ba7af48879d40ab", - "cmake-3.29.2-windows-i386.zip", - }, - { - "cmake", - "osx", - nullopt, - "3.29.2", - "cmake-3.29.2-macos-universal/CMake.app/Contents/bin/cmake", - "https://github.com/Kitware/CMake/releases/download/v3.29.2/cmake-3.29.2-macos-universal.tar.gz", - "26aab0163965f3d560dfd6b1f72c5e77192338237ebe286099fd62f243f1bbd4857b9193118386b801c00dc5cfbc5bc8af8481" - "4692fcfadcf56c7d2faab52533", - "cmake-3.29.2-macos-universal.tar.gz", - }, - { - "cmake", - "linux", - CPUArchitecture::ARM64, - "3.29.2", - "cmake-3.29.2-linux-aarch64/bin/cmake", - "https://github.com/Kitware/CMake/releases/download/v3.29.2/cmake-3.29.2-linux-aarch64.tar.gz", - "206b00604caf72f3dc644c7a5ac6a335814520fbf1512b9f2d4a5e8c26025d286bd106d2925ffbc874c754c518cbdb07f16919" - "16c39fcfd1202a47f592c8e3b0", - "cmake-3.29.2-linux-aarch64.tar.gz", - }, - { - "cmake", - "linux", - nullopt, - "3.29.2", - "cmake-3.29.2-linux-x86_64/bin/cmake", - "https://github.com/Kitware/CMake/releases/download/v3.29.2/cmake-3.29.2-linux-x86_64.tar.gz", - "d88082d582f1774a3d89efbf3f31a03b08a663c359d603d87ee7c4afd862d4164d2b0b9f0b32cece8efee3acfa86b44214cd4f" - "7606b99b8334183a05d5f06edc", - "cmake-3.29.2-linux-x86_64.tar.gz", - }, - { - "git", - "windows", - nullopt, - "2.7.4", - "mingw64/bin/git.exe", - "https://github.com/git-for-windows/git/releases/download/v2.43.0.windows.1/" - "PortableGit-2.43.0-64-bit.7z.exe", - "02ec40f55a6de18f305530e9415b6ce0a597359ebb9a58cf727ac84eceb0003b0f437941b76872b6568157a333c8e6e8d865a3" - "6faf874fd5f04774deb6a9387a", - "PortableGit-2.43.0-32-bit.7z.exe", - }, - { - "git", - "linux", - nullopt, - "2.7.4", - "", - "", - "", - "", - }, - { - "git", - "osx", - nullopt, - "2.7.4", - "", - "", - "", - "", - }, - { - "git", - "freebsd", - nullopt, - "2.7.4", - "", - "", - "", - "", - }, - { - "gsutil", - "windows", - nullopt, - "4.65", - "google-cloud-sdk/bin/gsutil.cmd", - "https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/" - "google-cloud-sdk-347.0.0-windows-x86_64-bundled-python.zip", - "e2792e17b132aad77f7c0b9fd26faf415e9437923d9227a9e6d253554e6843d29a6ddad0a7fb5e9aea4a130fd4c521e6ece884" - "4fd4a4f9e8d580348775425389", - "google-cloud-sdk-347.0.0-windows-x86_64-bundled-python.zip", - }, - { - "gsutil", - "osx", - nullopt, - "4.65", - "gsutil/gsutil", - "https://storage.googleapis.com/pub/gsutil_4.65.tar.gz", - "2c5c9dea48147f97180a491bbb9e24e8cbcd4f3452620e2f80338b781e4dfc90bb754e3bbfa05e1b990e44bff52d990d8c2dd5" - "1bc83d112339d8e6096a2f21c8", - "gsutil_4.65.tar.gz", - }, - { - "gsutil", - "linux", - nullopt, - "4.65", - "gsutil/gsutil", - "https://storage.googleapis.com/pub/gsutil_4.65.tar.gz", - "2c5c9dea48147f97180a491bbb9e24e8cbcd4f3452620e2f80338b781e4dfc90bb754e3bbfa05e1b990e44bff52d990d8c2dd5" - "1bc83d112339d8e6096a2f21c8", - "gsutil_4.65.tar.gz", - }, - { - "vswhere", - "windows", - nullopt, - "3.1.7", - "vswhere.exe", - "https://github.com/microsoft/vswhere/releases/download/3.1.7/vswhere.exe", - "40c534eb27f079c15c9782f53f82c12dabfede4d3d85f0edf8a855c2b0d5e12921a96506b37c210beab3c33220f8ff098447ad" - "054e82d8c2603964975fc12076", - "", - }, - { - "nuget", - "windows", - nullopt, - "6.10.0", - "nuget.exe", - "https://dist.nuget.org/win-x86-commandline/v6.10.0/nuget.exe", - "71d7307bb89de2df3811419c561efa00618a4c68e6ce481b0bdfc94c7c6c6d126a54eb26a0015686fabf99f109744ca41fead9" - "9e97139cdc86dde16a5ec3e7cf", - "", - }, - { - "nuget", - "linux", - nullopt, - "6.10.0", - "nuget.exe", - "https://dist.nuget.org/win-x86-commandline/v6.10.0/nuget.exe", - "71d7307bb89de2df3811419c561efa00618a4c68e6ce481b0bdfc94c7c6c6d126a54eb26a0015686fabf99f109744ca41fead9" - "9e97139cdc86dde16a5ec3e7cf", - "", - }, - { - "nuget", - "osx", - nullopt, - "6.10.0", - "nuget.exe", - "https://dist.nuget.org/win-x86-commandline/v6.10.0/nuget.exe", - "71d7307bb89de2df3811419c561efa00618a4c68e6ce481b0bdfc94c7c6c6d126a54eb26a0015686fabf99f109744ca41fead9" - "9e97139cdc86dde16a5ec3e7cf", - "", - }, - { - "coscli", - "windows", - nullopt, - "0.11.0", - "coscli-windows.exe", - "https://github.com/tencentyun/coscli/releases/download/v0.11.0-beta/coscli-windows.exe", - "38a521ec80cdb6944124f4233d7e71eed8cc9f9be2c0c736269915d21c3718ea8131e4516bb6eeada6df331f5fa8f47a299907" - "e50ee9edbe0114444520974d06", - "", - }, - { - "coscli", - "linux", - nullopt, - "0.11.0", - "coscli-linux", - "https://github.com/tencentyun/coscli/releases/download/v0.11.0-beta/coscli-linux", - "9c930a1d308e9581a0e2fdfe3751ea7fe13d6068df90ca6465740ec3eda034202ef71ec54c99e90015ff81aa68aa1489567db5" - "e411e222eb7258704bdac7e924", - "", - }, - { - "coscli", - "osx", - nullopt, - "0.11.0", - "coscli-mac", - "https://github.com/tencentyun/coscli/releases/download/v0.11.0-beta/coscli-mac", - "9556335bfc8bc14bace6dfced45fa77fb07c80f08aa975e047a54efda1d19852aae0ea68a5bc7f04fbd88e3edce5a73512a612" - "16b1c5ff4cade224de4a9ab8db", - "", - }, - { - "installerbase", - "windows", - nullopt, - "4.4.0", - "QtInstallerFramework-win-x86/bin/installerbase.exe", - "https://download.qt.io/official_releases/qt-installer-framework/4.4.0/" - "installer-framework-opensource-src-4.4.0.zip", - "fc713f54bfe2781cb232cd0ae8eddb96833ec178d53a55ec0b01886aa048b13441eb49a1f33282e8eab7259cfe512c890d50b8" - "e632d3dbf501a0bf1fd83de947", - "installer-framework-opensource-src-4.4.0.zip", - }, - { - "7zip_msi", - "windows", - nullopt, - "24.08", - "Files/7-Zip/7z.exe", - "https://github.com/ip7z/7zip/releases/download/24.08/7z2408-x64.msi", - "3259bf5e251382333c9d18a3fc01d83491fb41bc4ac4ddb25a02918494594c1074482b6608189a8a89e343d78e34d57420cdef" - "f1d7ace5acfdcaacc8776f1be8", - "7z2408-x64.msi", - }, - { - "7zip", - "windows", - nullopt, - "24.08", - "7za.exe", - "https://github.com/ip7z/7zip/releases/download/24.08/7z2408-extra.7z", - "35f55236fccfb576ca014e29d0c35f4a213e53f06683bd2e82f869ed02506e230c8dd623c01d0207244d6a997031f737903456" - "b7ad4a44db1717f0a17a78602e", - "7z2408-extra.7z", - }, - { - "7zr", - "windows", - nullopt, - "24.08", - "7zr.exe", - "https://github.com/ip7z/7zip/releases/download/24.08/7zr.exe", - "424196f2acf5b89807f4038683acc50e7604223fc630245af6bab0e0df923f8b1c49cb09ac709086568c214c3f53dcb7d6c32e" - "8a54af222a3ff78cfab9c51670", - "", - }, - { - "aria2", - "windows", - nullopt, - "1.37.0", - "aria2-1.37.0-win-64bit-build1/aria2c.exe", - "https://github.com/aria2/aria2/releases/download/release-1.37.0/aria2-1.37.0-win-64bit-build1.zip", - "6d78405da9cf5639dbe8174787002161b8124d73880fb57cc8c0a3a63982f84e46df4e626990c58f23452965ad925f0d37cb91" - "47e99b25c3d7ca0ea49602f34d", - "aria2-1.37.0-win-64bit-build1.zip", - }, - { - "aria2", - "osx", - nullopt, - "1.35.0", - "aria2-1.35.0/bin/aria2c", - "https://github.com/aria2/aria2/releases/download/release-1.35.0/aria2-1.35.0-osx-darwin.tar.bz2", - "3bb32b7d55347d1af37c6f4ebf0e20b38ce51c37a1baf92f7ad1762000539a03413dd679a6d902fdb1805fa71917300c9692ac" - "eee012eb06ecdff10491137aec", - "aria2-1.35.0-osx-darwin.tar.bz2", - }, - { - "ninja", - "windows", - nullopt, - "1.11.1", - "ninja.exe", - "https://github.com/ninja-build/ninja/releases/download/v1.11.1/ninja-win.zip", - "a700e794c32eb67b9f87040db7f1ba3a8e891636696fc54d416b01661c2421ff46fa517c97fd904adacdf8e621df3e68ea3801" - "05b909ae8b6651a78ae7eb3199", - "ninja-win-1.11.1.zip", - }, - { - "ninja", - "linux", - nullopt, - "1.11.1", - "ninja", - "https://github.com/ninja-build/ninja/releases/download/v1.11.1/ninja-linux.zip", - "6403dac9196baffcff614fa73ea530752997c8db6bbfbaa0446b4b09d7327e2aa6e8615d1283c961d3bf0df497e85ba8660414" - "9f1505ee75f89d600245a45dde", - "ninja-linux-1.11.1.zip", - }, - { - "ninja", - "osx", - nullopt, - "1.11.1", - "ninja", - "https://github.com/ninja-build/ninja/releases/download/v1.11.1/ninja-mac.zip", - "dad33b0918c60bbf5107951a936175b1610b4894a408f4ba4b47a2f5b328fc982a52a2aed6a0cb75028ee4765af5083bea6661" - "1c37516826eb0c851366bb4427", - "ninja-mac-1.11.1.zip", - }, - { - "powershell-core", - "windows", - nullopt, - "7.2.23", - "pwsh.exe", - "https://github.com/PowerShell/PowerShell/releases/download/v7.2.23/PowerShell-7.2.23-win-x64.zip", - "b374a878df02980d54e17ad7cfc9021e331748c3770f586be61356c257494d1b33899c1167d09a35c210bc084474aefdff972f" - "672d16afb43be0562b3589285a", - "PowerShell-7.2.23-win-x64.zip", - }, - { - "node", - "windows", - nullopt, - "16.15.1", - "node-v16.15.1-win-x64/node.exe", - "https://nodejs.org/dist/v16.15.1/node-v16.15.1-win-x64.7z", - "7ec4bfe2ea6034e1461e306b6372d62c0c5d1060c453ba76a73a5cec38ac26b5952a744caa9071455329caa58eb0a96d26c688" - "54c8915c17610ff27b0cf2c1cf", - "node-v16.15.1-win-x64.7z", - }, - { - "node", - "linux", - nullopt, - "16.15.1", - "node-v16.15.1-linux-x64/bin/node", - "https://nodejs.org/dist/v16.15.1/node-v16.15.1-linux-x64.tar.gz", - "5ad3b4b9caeaa8d31503efa99f5a593118a267dec9d4181d019732126ba248ce9a901207115b3f6b899eb5b3f0373c7f77ea95" - "cc92ac625cddf437ee9b8b8919", - "node-v16.15.1-linux-x64.tar.gz", - }, - { - "node", - "osx", - nullopt, - "16.15.1", - "node-v16.15.1-darwin-x64/bin/node", - "https://nodejs.org/dist/v16.15.1/node-v16.15.1-darwin-x64.tar.gz", - "90d0612bbe5467b6cf385c91a68b8daad0057e3e0ccacea44567f5b95b14f7481cb79784185ab1463b4bd990e092ff0f910957" - "6d1a1934b84e1c816582929611", - "node-v16.15.1-darwin-x64.tar.gz", - }}; - - size_t default_tool = 0; - bool existsDefaultTool = false; - for (std::size_t i = 0; i < NUM_TOOLS; i++) - { - // if possible, find a tool with matching tool name, architecture, and os - // otherwise, choose a tool with only matching name and os and nullopt - // as architecture (this is the default tool) - const ArchToolData& d = tool_data[i]; - if (d.tool == toolname && d.arch.has_value() && d.arch.value_or_exit(VCPKG_LINE_INFO) == arch && d.os == os) - { - return d; - } - else if (d.tool == toolname && d.os == os && !d.arch.has_value()) + const ArchToolData* default_tool = nullptr; + for (auto&& d : tool_data_table) + { + if (d.tool == toolname && d.os == os) { - default_tool = i; - existsDefaultTool = true; + // if the tool data record declares an architecture matching the one we're looking for, that's an exact + // match and we've found the right one + if (auto d_arch = d.arch.get()) + { + if (*d_arch == arch) + { + return &d; + } + } + else + { + // if the tool data record does not declare an architecture, we merely record a 'default tool' in + // case a more specific entry naming an architecture is seen + if (default_tool) + { + Checks::unreachable(VCPKG_LINE_INFO, + "there should be only one tool entry with an undeclared architecture"); + } + + default_tool = &d; + } } } - if (existsDefaultTool) + + if (default_tool) { - return tool_data[default_tool]; + return default_tool; } - return nullopt; + return nullptr; } static Optional get_tool_data(StringView tool) @@ -484,37 +495,36 @@ namespace vcpkg #else return nullopt; #endif - if (!data.has_value()) + if (!data) { return nullopt; } - auto& d = data.value_or_exit(VCPKG_LINE_INFO); - const Optional> version = parse_tool_version_string(d.version); + const Optional> version = parse_tool_version_string(data->version); Checks::msg_check_exit(VCPKG_LINE_INFO, version.has_value(), msgFailedToParseVersionXML, msg::tool_name = tool, - msg::version = d.version); + msg::version = data->version); - Path tool_dir_name = fmt::format("{}-{}-{}", tool, d.version, d.os); + Path tool_dir_name = fmt::format("{}-{}-{}", tool, data->version, data->os); Path download_subpath; - if (!d.archiveName.empty()) + if (!data->archiveName.empty()) { - download_subpath = d.archiveName; + download_subpath = data->archiveName; } - else if (!d.exeRelativePath.empty()) + else if (!data->exeRelativePath.empty()) { - download_subpath = Strings::concat(StringView{d.sha512}.substr(0, 8), '-', d.exeRelativePath); + download_subpath = Strings::concat(StringView{data->sha512}.substr(0, 8), '-', data->exeRelativePath); } return ToolData{tool.to_string(), *version.get(), - d.exeRelativePath, - std::string(d.url), + data->exeRelativePath, + data->url.to_string(), download_subpath, - !d.archiveName.empty(), + !data->archiveName.empty(), tool_dir_name, - std::string(d.sha512)}; + data->sha512.to_string()}; } struct PathAndVersion