diff options
| author | ras0219 <533828+ras0219@users.noreply.github.com> | 2020-08-14 09:53:04 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-08-14 09:53:04 -0700 |
| commit | 0c2117845e1f2e3c260b74af8d60f315343b094e (patch) | |
| tree | 9a0e321a6a30a897803228f1d69d1936b7b3b039 | |
| parent | 2cdf1cad7aa9944a4c8edb90cb3656560c7b56d1 (diff) | |
| download | vcpkg-0c2117845e1f2e3c260b74af8d60f315343b094e.tar.gz vcpkg-0c2117845e1f2e3c260b74af8d60f315343b094e.zip | |
[vcpkg] Reduce dependencies and contents of vcpkgpaths.h (#12876)
* [vcpkg] Remove globally-constructed pre-defined Triplets from vcpkg.exe
The tool should be as triplet-agnostic as possible, which leaves little room for special, pre-defined names like this. However, tests do have use of them: moved into test assets.
* [vcpkg] Move predefined tools strings vcpkgpaths.h -> tools.h
* [vcpkg] Add forward declarations to vcpkgpaths.h to reduce header deps
* Merge from origin/master
Co-authored-by: Robert Schumacher <roschuma@microsoft.com>
26 files changed, 180 insertions, 176 deletions
diff --git a/toolsrc/include/vcpkg-test/util.h b/toolsrc/include/vcpkg-test/util.h index 5170c846a..d2c512f9b 100644 --- a/toolsrc/include/vcpkg-test/util.h +++ b/toolsrc/include/vcpkg-test/util.h @@ -64,6 +64,12 @@ namespace vcpkg::Test const char* depends = "", const char* triplet = "x86-windows"); + extern const Triplet X86_WINDOWS; + extern const Triplet X64_WINDOWS; + extern const Triplet X86_UWP; + extern const Triplet ARM_UWP; + extern const Triplet X64_ANDROID; + /// <summary> /// Map of source control files by their package name. /// </summary> @@ -71,7 +77,7 @@ namespace vcpkg::Test { std::unordered_map<std::string, SourceControlFileLocation> map; Triplet triplet; - PackageSpecMap(Triplet t = Triplet::X86_WINDOWS) noexcept : triplet(t) { } + PackageSpecMap(Triplet t = X86_WINDOWS) noexcept : triplet(t) { } PackageSpec emplace(const char* name, const char* depends = "", diff --git a/toolsrc/include/vcpkg/tools.h b/toolsrc/include/vcpkg/tools.h index b57ca2918..d5c0a5c23 100644 --- a/toolsrc/include/vcpkg/tools.h +++ b/toolsrc/include/vcpkg/tools.h @@ -9,6 +9,21 @@ namespace vcpkg { struct VcpkgPaths; + namespace Tools + { + static const std::string SEVEN_ZIP = "7zip"; + static const std::string SEVEN_ZIP_ALT = "7z"; + static const std::string MAVEN = "mvn"; + static const std::string CMAKE = "cmake"; + static const std::string GIT = "git"; + static const std::string MONO = "mono"; + static const std::string NINJA = "ninja"; + static const std::string NUGET = "nuget"; + static const std::string IFW_INSTALLER_BASE = "ifw_installerbase"; + static const std::string IFW_BINARYCREATOR = "ifw_binarycreator"; + static const std::string IFW_REPOGEN = "ifw_repogen"; + } + struct ToolCache { virtual ~ToolCache() { } diff --git a/toolsrc/include/vcpkg/triplet.h b/toolsrc/include/vcpkg/triplet.h index 736b22a2d..42d99dc3e 100644 --- a/toolsrc/include/vcpkg/triplet.h +++ b/toolsrc/include/vcpkg/triplet.h @@ -3,13 +3,12 @@ #include <vcpkg/base/optional.h> #include <vcpkg/base/system.h> -#include <vcpkg/vcpkgcmdarguments.h> - #include <string> namespace vcpkg { struct TripletInstance; + struct VcpkgCmdArguments; struct Triplet { @@ -18,20 +17,6 @@ namespace vcpkg static Triplet from_canonical_name(std::string&& triplet_as_string); - static const Triplet X86_WINDOWS; - static const Triplet X64_WINDOWS; - static const Triplet ARM_WINDOWS; - static const Triplet ARM64_WINDOWS; - static const Triplet X86_UWP; - static const Triplet X64_UWP; - static const Triplet ARM_UWP; - static const Triplet ARM64_UWP; - - static const Triplet ARM_ANDROID; - static const Triplet ARM64_ANDROID; - static const Triplet X86_ANDROID; - static const Triplet X64_ANDROID; - const std::string& canonical_name() const; const std::string& to_string() const; void to_string(std::string& out) const; diff --git a/toolsrc/include/vcpkg/vcpkgpaths.h b/toolsrc/include/vcpkg/vcpkgpaths.h index 594407c4b..721b59606 100644 --- a/toolsrc/include/vcpkg/vcpkgpaths.h +++ b/toolsrc/include/vcpkg/vcpkgpaths.h @@ -4,30 +4,11 @@ #include <vcpkg/base/files.h> #include <vcpkg/base/lazy.h> #include <vcpkg/base/optional.h> +#include <vcpkg/base/system.h> #include <vcpkg/base/util.h> -#include <vcpkg/binaryparagraph.h> -#include <vcpkg/packagespec.h> -#include <vcpkg/tools.h> -#include <vcpkg/vcpkgcmdarguments.h> - namespace vcpkg { - namespace Tools - { - static const std::string SEVEN_ZIP = "7zip"; - static const std::string SEVEN_ZIP_ALT = "7z"; - static const std::string MAVEN = "mvn"; - static const std::string CMAKE = "cmake"; - static const std::string GIT = "git"; - static const std::string MONO = "mono"; - static const std::string NINJA = "ninja"; - static const std::string NUGET = "nuget"; - static const std::string IFW_INSTALLER_BASE = "ifw_installerbase"; - static const std::string IFW_BINARYCREATOR = "ifw_binarycreator"; - static const std::string IFW_REPOGEN = "ifw_repogen"; - } - struct ToolsetArchOption { CStringView name; @@ -61,6 +42,11 @@ namespace vcpkg struct VcpkgPathsImpl; } + struct BinaryParagraph; + struct VcpkgCmdArguments; + struct PackageSpec; + struct Triplet; + struct VcpkgPaths : Util::MoveOnlyBase { struct TripletFile diff --git a/toolsrc/src/vcpkg-test/binarycaching.cpp b/toolsrc/src/vcpkg-test/binarycaching.cpp index a8204f9c2..55532d14d 100644 --- a/toolsrc/src/vcpkg-test/binarycaching.cpp +++ b/toolsrc/src/vcpkg-test/binarycaching.cpp @@ -11,6 +11,8 @@ #include <string> +#include <vcpkg-test/util.h> + using namespace vcpkg; TEST_CASE ("reformat_version semver-ish", "[reformat_version]") @@ -65,7 +67,7 @@ Build-Depends: bzip REQUIRE(maybe_scf.has_value()); SourceControlFileLocation scfl{std::move(*maybe_scf.get()), fs::path()}; - Dependencies::InstallPlanAction ipa(PackageSpec{"zlib2", Triplet::X64_WINDOWS}, + Dependencies::InstallPlanAction ipa(PackageSpec{"zlib2", Test::X64_WINDOWS}, scfl, Dependencies::RequestType::USER_REQUESTED, {{"a", {}}, {"b", {}}}); @@ -177,7 +179,7 @@ Description: a spiffy compression library wrapper REQUIRE(maybe_scf.has_value()); SourceControlFileLocation scfl{std::move(*maybe_scf.get()), fs::path()}; plan.install_actions.push_back(Dependencies::InstallPlanAction()); - plan.install_actions[0].spec = PackageSpec("zlib", Triplet::X64_ANDROID); + plan.install_actions[0].spec = PackageSpec("zlib", Test::X64_ANDROID); plan.install_actions[0].source_control_file_location = scfl; plan.install_actions[0].abi_info = Build::AbiInfo{}; plan.install_actions[0].abi_info.get()->package_abi = "packageabi"; @@ -200,7 +202,7 @@ Description: a spiffy compression library wrapper REQUIRE(maybe_scf2.has_value()); SourceControlFileLocation scfl2{std::move(*maybe_scf2.get()), fs::path()}; plan.install_actions.push_back(Dependencies::InstallPlanAction()); - plan.install_actions[1].spec = PackageSpec("zlib2", Triplet::X64_ANDROID); + plan.install_actions[1].spec = PackageSpec("zlib2", Test::X64_ANDROID); plan.install_actions[1].source_control_file_location = scfl2; plan.install_actions[1].abi_info = Build::AbiInfo{}; plan.install_actions[1].abi_info.get()->package_abi = "packageabi2"; diff --git a/toolsrc/src/vcpkg-test/dependencies.cpp b/toolsrc/src/vcpkg-test/dependencies.cpp index 1951a6128..ef39bd1ef 100644 --- a/toolsrc/src/vcpkg-test/dependencies.cpp +++ b/toolsrc/src/vcpkg-test/dependencies.cpp @@ -33,12 +33,12 @@ TEST_CASE ("filter depends", "[dependencies]") auto deps_ = parse_dependencies_list("liba (!uwp), libb, libc (uwp)"); REQUIRE(deps_); auto& deps = *deps_.get(); - auto v = filter_dependencies(deps, Triplet::X64_WINDOWS, x64_win_cmake_vars); + auto v = filter_dependencies(deps, Test::X64_WINDOWS, x64_win_cmake_vars); REQUIRE(v.size() == 2); REQUIRE(v.at(0).package_spec.name() == "liba"); REQUIRE(v.at(1).package_spec.name() == "libb"); - auto v2 = filter_dependencies(deps, Triplet::ARM_UWP, arm_uwp_cmake_vars); + auto v2 = filter_dependencies(deps, Test::ARM_UWP, arm_uwp_cmake_vars); REQUIRE(v.size() == 2); REQUIRE(v2.at(0).package_spec.name() == "libb"); REQUIRE(v2.at(1).package_spec.name() == "libc"); @@ -101,7 +101,7 @@ TEST_CASE ("resolve_deps_as_top_level", "[dependencies]") var_provider.dep_info_vars[{"a", t_linux}].emplace("VCPKG_CMAKE_SYSTEM_NAME", "Linux"); { auto deps = vcpkg::Dependencies::resolve_deps_as_top_level( - *spec_map.map.at("a").source_control_file, Triplet::X86_WINDOWS, {}, var_provider); + *spec_map.map.at("a").source_control_file, Test::X86_WINDOWS, {}, var_provider); REQUIRE(deps.size() == 1); REQUIRE(deps.at(0) == spec_b); } @@ -114,7 +114,7 @@ TEST_CASE ("resolve_deps_as_top_level", "[dependencies]") { // without defaults auto deps = vcpkg::Dependencies::resolve_deps_as_top_level( - *spec_map.map.at("c").source_control_file, Triplet::X86_WINDOWS, {}, var_provider); + *spec_map.map.at("c").source_control_file, Test::X86_WINDOWS, {}, var_provider); REQUIRE(deps.size() == 1); REQUIRE(deps.at(0) == spec_b); } @@ -122,21 +122,21 @@ TEST_CASE ("resolve_deps_as_top_level", "[dependencies]") { // with defaults of c (c1) auto deps = vcpkg::Dependencies::resolve_deps_as_top_level( - *spec_map.map.at("c").source_control_file, Triplet::X86_WINDOWS, {"default"}, var_provider); + *spec_map.map.at("c").source_control_file, Test::X86_WINDOWS, {"default"}, var_provider); REQUIRE(deps.size() == 1); REQUIRE(deps.at(0) == spec_b_with_b1); } { // with c1 auto deps = vcpkg::Dependencies::resolve_deps_as_top_level( - *spec_map.map.at("c").source_control_file, Triplet::X86_WINDOWS, {"c1"}, var_provider); + *spec_map.map.at("c").source_control_file, Test::X86_WINDOWS, {"c1"}, var_provider); REQUIRE(deps.size() == 1); REQUIRE(deps.at(0) == spec_b_with_b1); } { // with c2 implying c1 auto deps = vcpkg::Dependencies::resolve_deps_as_top_level( - *spec_map.map.at("c").source_control_file, Triplet::X86_WINDOWS, {"c2"}, var_provider); + *spec_map.map.at("c").source_control_file, Test::X86_WINDOWS, {"c2"}, var_provider); REQUIRE(deps.size() == 2); REQUIRE(deps.at(0) == spec_a); REQUIRE(deps.at(1) == spec_b_with_b1); @@ -144,7 +144,7 @@ TEST_CASE ("resolve_deps_as_top_level", "[dependencies]") { // d -> c[core] auto deps = vcpkg::Dependencies::resolve_deps_as_top_level( - *spec_map.map.at("d").source_control_file, Triplet::X86_WINDOWS, {}, var_provider); + *spec_map.map.at("d").source_control_file, Test::X86_WINDOWS, {}, var_provider); REQUIRE(deps.size() == 1); REQUIRE(deps.at(0) == spec_c); } diff --git a/toolsrc/src/vcpkg-test/manifests.cpp b/toolsrc/src/vcpkg-test/manifests.cpp index 4b450b7be..95a0b149b 100644 --- a/toolsrc/src/vcpkg-test/manifests.cpp +++ b/toolsrc/src/vcpkg-test/manifests.cpp @@ -5,6 +5,7 @@ #include <vcpkg/paragraphs.h> #include <vcpkg/sourceparagraph.h> +#include <vcpkg/vcpkgcmdarguments.h> #include <vcpkg-test/util.h> diff --git a/toolsrc/src/vcpkg-test/plan.cpp b/toolsrc/src/vcpkg-test/plan.cpp index 09c377ecc..55c6740da 100644 --- a/toolsrc/src/vcpkg-test/plan.cpp +++ b/toolsrc/src/vcpkg-test/plan.cpp @@ -28,7 +28,7 @@ using Test::PackageSpecMap; static void features_check(Dependencies::InstallPlanAction& plan, std::string pkg_name, std::vector<std::string> expected_features, - Triplet triplet = Triplet::X86_WINDOWS) + Triplet triplet = Test::X86_WINDOWS) { const auto& feature_list = plan.feature_list; @@ -54,7 +54,7 @@ static void features_check(Dependencies::InstallPlanAction& plan, /// </summary> static void remove_plan_check(Dependencies::RemovePlanAction& plan, std::string pkg_name, - Triplet triplet = Triplet::X86_WINDOWS) + Triplet triplet = Test::X86_WINDOWS) { REQUIRE(plan.spec.triplet().to_string() == triplet.to_string()); REQUIRE(pkg_name == plan.spec.name()); @@ -381,14 +381,14 @@ TEST_CASE ("basic feature test 8", "[plan]") std::vector<std::unique_ptr<StatusParagraph>> status_paragraphs; status_paragraphs.push_back(make_status_pgh("a")); status_paragraphs.push_back(make_status_pgh("a")); - status_paragraphs.back()->package.spec = PackageSpec("a", Triplet::X64_WINDOWS); + status_paragraphs.back()->package.spec = PackageSpec("a", Test::X64_WINDOWS); - PackageSpecMap spec_map(Triplet::X64_WINDOWS); + PackageSpecMap spec_map(Test::X64_WINDOWS); auto spec_a_64 = FullPackageSpec{spec_map.emplace("a", "b", {{"a1", ""}}), {"core"}}; auto spec_b_64 = FullPackageSpec{spec_map.emplace("b")}; auto spec_c_64 = FullPackageSpec{spec_map.emplace("c", "a[a1]"), {"core"}}; - spec_map.triplet = Triplet::X86_WINDOWS; + spec_map.triplet = Test::X86_WINDOWS; auto spec_a_86 = FullPackageSpec{spec_map.emplace("a", "b", {{"a1", ""}}), {"core"}}; auto spec_b_86 = FullPackageSpec{spec_map.emplace("b")}; auto spec_c_86 = FullPackageSpec{spec_map.emplace("c", "a[a1]"), {"core"}}; @@ -401,14 +401,14 @@ TEST_CASE ("basic feature test 8", "[plan]") {spec_c_64, spec_a_86, spec_a_64, spec_c_86}, StatusParagraphs(std::move(status_paragraphs))); - remove_plan_check(plan.remove_actions.at(0), "a", Triplet::X64_WINDOWS); + remove_plan_check(plan.remove_actions.at(0), "a", Test::X64_WINDOWS); remove_plan_check(plan.remove_actions.at(1), "a"); auto& install_plan = plan.install_actions; - features_check(install_plan.at(0), "b", {"core"}, Triplet::X64_WINDOWS); - features_check(install_plan.at(1), "a", {"a1", "core"}, Triplet::X64_WINDOWS); + features_check(install_plan.at(0), "b", {"core"}, Test::X64_WINDOWS); + features_check(install_plan.at(1), "a", {"a1", "core"}, Test::X64_WINDOWS); features_check(install_plan.at(2), "b", {"core"}); features_check(install_plan.at(3), "a", {"a1", "core"}); - features_check(install_plan.at(4), "c", {"core"}, Triplet::X64_WINDOWS); + features_check(install_plan.at(4), "c", {"core"}, Test::X64_WINDOWS); features_check(install_plan.at(5), "c", {"core"}); } @@ -416,10 +416,10 @@ TEST_CASE ("install all features test", "[plan]") { std::vector<std::unique_ptr<StatusParagraph>> status_paragraphs; - PackageSpecMap spec_map(Triplet::X64_WINDOWS); + PackageSpecMap spec_map(Test::X64_WINDOWS); auto spec_a_64 = FullPackageSpec{spec_map.emplace("a", "", {{"0", ""}, {"1", ""}}), {"core"}}; - auto install_specs = FullPackageSpec::from_string("a[*]", Triplet::X64_WINDOWS); + auto install_specs = FullPackageSpec::from_string("a[*]", Test::X64_WINDOWS); REQUIRE(install_specs.has_value()); if (!install_specs.has_value()) return; @@ -432,7 +432,7 @@ TEST_CASE ("install all features test", "[plan]") StatusParagraphs(std::move(status_paragraphs))); REQUIRE(install_plan.size() == 1); - features_check(install_plan.install_actions.at(0), "a", {"0", "1", "core"}, Triplet::X64_WINDOWS); + features_check(install_plan.install_actions.at(0), "a", {"0", "1", "core"}, Test::X64_WINDOWS); } TEST_CASE ("install default features test 1", "[plan]") @@ -440,11 +440,11 @@ TEST_CASE ("install default features test 1", "[plan]") std::vector<std::unique_ptr<StatusParagraph>> status_paragraphs; // Add a port "a" with default features "1" and features "0" and "1". - PackageSpecMap spec_map(Triplet::X64_WINDOWS); + PackageSpecMap spec_map(Test::X64_WINDOWS); spec_map.emplace("a", "", {{"0", ""}, {"1", ""}}, {"1"}); // Install "a" (without explicit feature specification) - auto install_specs = FullPackageSpec::from_string("a", Triplet::X64_WINDOWS); + auto install_specs = FullPackageSpec::from_string("a", Test::X64_WINDOWS); PortFileProvider::MapPortFileProvider map_port{spec_map.map}; MockCMakeVarProvider var_provider; @@ -456,23 +456,23 @@ TEST_CASE ("install default features test 1", "[plan]") // Expect the default feature "1" to be installed, but not "0" REQUIRE(install_plan.size() == 1); - features_check(install_plan.install_actions.at(0), "a", {"1", "core"}, Triplet::X64_WINDOWS); + features_check(install_plan.install_actions.at(0), "a", {"1", "core"}, Test::X64_WINDOWS); } TEST_CASE ("install default features test 2", "[plan]") { std::vector<std::unique_ptr<StatusParagraph>> status_paragraphs; status_paragraphs.push_back(make_status_pgh("a")); - status_paragraphs.back()->package.spec = PackageSpec("a", Triplet::X64_WINDOWS); + status_paragraphs.back()->package.spec = PackageSpec("a", Test::X64_WINDOWS); // Add a port "a" of which "core" is already installed, but we will // install the default features "explicitly" // "a" has two features, of which "a1" is default. - PackageSpecMap spec_map(Triplet::X64_WINDOWS); + PackageSpecMap spec_map(Test::X64_WINDOWS); spec_map.emplace("a", "", {{"a0", ""}, {"a1", ""}}, {"a1"}); // Install "a" (without explicit feature specification) - auto install_specs = FullPackageSpec::from_string("a", Triplet::X64_WINDOWS); + auto install_specs = FullPackageSpec::from_string("a", Test::X64_WINDOWS); PortFileProvider::MapPortFileProvider map_port{spec_map.map}; MockCMakeVarProvider var_provider; @@ -485,8 +485,8 @@ TEST_CASE ("install default features test 2", "[plan]") // Expect "a" to get removed for rebuild and then installed with default // features. REQUIRE(install_plan.size() == 2); - remove_plan_check(install_plan.remove_actions.at(0), "a", Triplet::X64_WINDOWS); - features_check(install_plan.install_actions.at(0), "a", {"a1", "core"}, Triplet::X64_WINDOWS); + remove_plan_check(install_plan.remove_actions.at(0), "a", Test::X64_WINDOWS); + features_check(install_plan.install_actions.at(0), "a", {"a1", "core"}, Test::X64_WINDOWS); } TEST_CASE ("install default features test 3", "[plan]") @@ -494,11 +494,11 @@ TEST_CASE ("install default features test 3", "[plan]") std::vector<std::unique_ptr<StatusParagraph>> status_paragraphs; // "a" has two features, of which "a1" is default. - PackageSpecMap spec_map(Triplet::X64_WINDOWS); + PackageSpecMap spec_map(Test::X64_WINDOWS); spec_map.emplace("a", "", {{"a0", ""}, {"a1", ""}}, {"a1"}); // Explicitly install "a" without default features - auto install_specs = FullPackageSpec::from_string("a[core]", Triplet::X64_WINDOWS); + auto install_specs = FullPackageSpec::from_string("a[core]", Test::X64_WINDOWS); PortFileProvider::MapPortFileProvider map_port{spec_map.map}; MockCMakeVarProvider var_provider; @@ -510,7 +510,7 @@ TEST_CASE ("install default features test 3", "[plan]") // Expect the default feature not to get installed. REQUIRE(install_plan.size() == 1); - features_check(install_plan.install_actions.at(0), "a", {"core"}, Triplet::X64_WINDOWS); + features_check(install_plan.install_actions.at(0), "a", {"core"}, Test::X64_WINDOWS); } TEST_CASE ("install default features of dependency test 1", "[plan]") @@ -518,13 +518,13 @@ TEST_CASE ("install default features of dependency test 1", "[plan]") std::vector<std::unique_ptr<StatusParagraph>> status_paragraphs; // Add a port "a" which depends on the core of "b" - PackageSpecMap spec_map(Triplet::X64_WINDOWS); + PackageSpecMap spec_map(Test::X64_WINDOWS); spec_map.emplace("a", "b[core]"); // "b" has two features, of which "b1" is default. spec_map.emplace("b", "", {{"b0", ""}, {"b1", ""}}, {"b1"}); // Install "a" (without explicit feature specification) - auto install_specs = FullPackageSpec::from_string("a", Triplet::X64_WINDOWS); + auto install_specs = FullPackageSpec::from_string("a", Test::X64_WINDOWS); PortFileProvider::MapPortFileProvider map_port{spec_map.map}; MockCMakeVarProvider var_provider; @@ -536,8 +536,8 @@ TEST_CASE ("install default features of dependency test 1", "[plan]") // Expect "a" to get installed and defaults of "b" through the dependency, // as no explicit features of "b" are installed by the user. REQUIRE(install_plan.size() == 2); - features_check(install_plan.install_actions.at(0), "b", {"b1", "core"}, Triplet::X64_WINDOWS); - features_check(install_plan.install_actions.at(1), "a", {"core"}, Triplet::X64_WINDOWS); + features_check(install_plan.install_actions.at(0), "b", {"b1", "core"}, Test::X64_WINDOWS); + features_check(install_plan.install_actions.at(1), "a", {"core"}, Test::X64_WINDOWS); } TEST_CASE ("do not install default features of dependency test 1", "[plan]") @@ -545,14 +545,14 @@ TEST_CASE ("do not install default features of dependency test 1", "[plan]") std::vector<std::unique_ptr<StatusParagraph>> status_paragraphs; // Add a port "a" which depends on the core of "b" - PackageSpecMap spec_map(Triplet::X64_WINDOWS); + PackageSpecMap spec_map(Test::X64_WINDOWS); spec_map.emplace("a", "b[core]"); // "b" has two features, of which "b1" is default. spec_map.emplace("b", "", {{"b0", ""}, {"b1", ""}}, {"b1"}); // Install "a" (without explicit feature specification) - auto spec_a = FullPackageSpec::from_string("a", Triplet::X64_WINDOWS); - auto spec_b = FullPackageSpec::from_string("b[core]", Triplet::X64_WINDOWS); + auto spec_a = FullPackageSpec::from_string("a", Test::X64_WINDOWS); + auto spec_b = FullPackageSpec::from_string("b[core]", Test::X64_WINDOWS); PortFileProvider::MapPortFileProvider map_port{spec_map.map}; MockCMakeVarProvider var_provider; @@ -565,8 +565,8 @@ TEST_CASE ("do not install default features of dependency test 1", "[plan]") // Expect "a" to get installed and defaults of "b" through the dependency, // as no explicit features of "b" are installed by the user. REQUIRE(install_plan.size() == 2); - features_check(install_plan.install_actions.at(0), "b", {"core"}, Triplet::X64_WINDOWS); - features_check(install_plan.install_actions.at(1), "a", {"core"}, Triplet::X64_WINDOWS); + features_check(install_plan.install_actions.at(0), "b", {"core"}, Test::X64_WINDOWS); + features_check(install_plan.install_actions.at(1), "a", {"core"}, Test::X64_WINDOWS); } TEST_CASE ("install default features of dependency test 2", "[plan]") @@ -574,14 +574,14 @@ TEST_CASE ("install default features of dependency test 2", "[plan]") std::vector<std::unique_ptr<StatusParagraph>> status_paragraphs; // Add a port "a" which depends on the default features of "b" - PackageSpecMap spec_map(Triplet::X64_WINDOWS); + PackageSpecMap spec_map(Test::X64_WINDOWS); spec_map.emplace("a", "b"); // "b" has two features, of which "b1" is default. spec_map.emplace("b", "", {{"b0", ""}, {"b1", ""}}, {"b1"}); // Install "a" (without explicit feature specification) - auto spec_a = FullPackageSpec::from_string("a", Triplet::X64_WINDOWS); - auto spec_b = FullPackageSpec::from_string("b[core]", Triplet::X64_WINDOWS); + auto spec_a = FullPackageSpec::from_string("a", Test::X64_WINDOWS); + auto spec_b = FullPackageSpec::from_string("b[core]", Test::X64_WINDOWS); PortFileProvider::MapPortFileProvider map_port{spec_map.map}; MockCMakeVarProvider var_provider; @@ -593,14 +593,14 @@ TEST_CASE ("install default features of dependency test 2", "[plan]") // Expect "a" to get installed and defaults of "b" through the dependency REQUIRE(install_plan.size() == 2); - features_check(install_plan.install_actions.at(0), "b", {"b1", "core"}, Triplet::X64_WINDOWS); - features_check(install_plan.install_actions.at(1), "a", {"core"}, Triplet::X64_WINDOWS); + features_check(install_plan.install_actions.at(0), "b", {"b1", "core"}, Test::X64_WINDOWS); + features_check(install_plan.install_actions.at(1), "a", {"core"}, Test::X64_WINDOWS); } TEST_CASE ("do not install default features of existing dependency", "[plan]") { // Add a port "a" which depends on the core of "b" - PackageSpecMap spec_map(Triplet::X64_WINDOWS); + PackageSpecMap spec_map(Test::X64_WINDOWS); spec_map.emplace("a", "b[core]"); // "b" has two features, of which "b1" is default. spec_map.emplace("b", "", {{"b0", ""}, {"b1", ""}}, {"b1"}); @@ -608,10 +608,10 @@ TEST_CASE ("do not install default features of existing dependency", "[plan]") std::vector<std::unique_ptr<StatusParagraph>> status_paragraphs; // "b[core]" is already installed status_paragraphs.push_back(make_status_pgh("b")); - status_paragraphs.back()->package.spec = PackageSpec("b", Triplet::X64_WINDOWS); + status_paragraphs.back()->package.spec = PackageSpec("b", Test::X64_WINDOWS); // Install "a" (without explicit feature specification) - auto install_specs = FullPackageSpec::from_string("a", Triplet::X64_WINDOWS); + auto install_specs = FullPackageSpec::from_string("a", Test::X64_WINDOWS); PortFileProvider::MapPortFileProvider map_port{spec_map.map}; MockCMakeVarProvider var_provider; @@ -622,13 +622,13 @@ TEST_CASE ("do not install default features of existing dependency", "[plan]") // Expect "a" to get installed, but not require rebuilding "b" REQUIRE(install_plan.size() == 1); - features_check(install_plan.install_actions.at(0), "a", {"core"}, Triplet::X64_WINDOWS); + features_check(install_plan.install_actions.at(0), "a", {"core"}, Test::X64_WINDOWS); } TEST_CASE ("install default features of existing dependency", "[plan]") { // Add a port "a" which depends on the default features of "b" - PackageSpecMap spec_map(Triplet::X64_WINDOWS); + PackageSpecMap spec_map(Test::X64_WINDOWS); spec_map.emplace("a", "b"); // "b" has a default feature spec_map.emplace("b", "", {{"b1", ""}}, {"b1"}); @@ -636,10 +636,10 @@ TEST_CASE ("install default features of existing dependency", "[plan]") std::vector<std::unique_ptr<StatusParagraph>> status_paragraphs; // "b[core]" is already installed status_paragraphs.push_back(make_status_pgh("b", "", "b1")); - status_paragraphs.back()->package.spec = PackageSpec("b", Triplet::X64_WINDOWS); + status_paragraphs.back()->package.spec = PackageSpec("b", Test::X64_WINDOWS); // Install "a" (without explicit feature specification) - auto install_specs = FullPackageSpec::from_string("a", Triplet::X64_WINDOWS); + auto install_specs = FullPackageSpec::from_string("a", Test::X64_WINDOWS); PortFileProvider::MapPortFileProvider map_port{spec_map.map}; MockCMakeVarProvider var_provider; @@ -650,24 +650,24 @@ TEST_CASE ("install default features of existing dependency", "[plan]") // Expect "b" to be rebuilt REQUIRE(install_plan.install_actions.size() == 2); - features_check(install_plan.install_actions.at(0), "b", {"core", "b1"}, Triplet::X64_WINDOWS); + features_check(install_plan.install_actions.at(0), "b", {"core", "b1"}, Test::X64_WINDOWS); } TEST_CASE ("install default features of dependency test 3", "[plan]") { std::vector<std::unique_ptr<StatusParagraph>> status_paragraphs; status_paragraphs.push_back(make_status_pgh("b")); - status_paragraphs.back()->package.spec = PackageSpec("b", Triplet::X64_WINDOWS); + status_paragraphs.back()->package.spec = PackageSpec("b", Test::X64_WINDOWS); // Add a port "a" which depends on the core of "b", which was already // installed explicitly - PackageSpecMap spec_map(Triplet::X64_WINDOWS); + PackageSpecMap spec_map(Test::X64_WINDOWS); spec_map.emplace("a", "b[core]"); // "b" has two features, of which "b1" is default. spec_map.emplace("b", "", {{"b0", ""}, {"b1", ""}}, {"b1"}); // Install "a" (without explicit feature specification) - auto install_specs = FullPackageSpec::from_string("a", Triplet::X64_WINDOWS); + auto install_specs = FullPackageSpec::from_string("a", Test::X64_WINDOWS); PortFileProvider::MapPortFileProvider map_port{spec_map.map}; MockCMakeVarProvider var_provider; @@ -679,7 +679,7 @@ TEST_CASE ("install default features of dependency test 3", "[plan]") // Expect "a" to get installed, not the defaults of "b", as the required // dependencies are already there, installed explicitly by the user. REQUIRE(install_plan.size() == 1); - features_check(install_plan.install_actions.at(0), "a", {"core"}, Triplet::X64_WINDOWS); + features_check(install_plan.install_actions.at(0), "a", {"core"}, Test::X64_WINDOWS); } TEST_CASE ("install plan action dependencies", "[plan]") @@ -688,13 +688,13 @@ TEST_CASE ("install plan action dependencies", "[plan]") // Add a port "a" which depends on the core of "b", which was already // installed explicitly - PackageSpecMap spec_map(Triplet::X64_WINDOWS); + PackageSpecMap spec_map(Test::X64_WINDOWS); auto spec_c = spec_map.emplace("c"); auto spec_b = spec_map.emplace("b", "c"); spec_map.emplace("a", "b"); // Install "a" (without explicit feature specification) - auto install_specs = FullPackageSpec::from_string("a", Triplet::X64_WINDOWS); + auto install_specs = FullPackageSpec::from_string("a", Test::X64_WINDOWS); PortFileProvider::MapPortFileProvider map_port{spec_map.map}; MockCMakeVarProvider var_provider; @@ -704,13 +704,13 @@ TEST_CASE ("install plan action dependencies", "[plan]") StatusParagraphs(std::move(status_paragraphs))); REQUIRE(install_plan.size() == 3); - features_check(install_plan.install_actions.at(0), "c", {"core"}, Triplet::X64_WINDOWS); + features_check(install_plan.install_actions.at(0), "c", {"core"}, Test::X64_WINDOWS); // TODO: Figure out what to do with these tests - features_check(install_plan.install_actions.at(1), "b", {"core"}, Triplet::X64_WINDOWS); + features_check(install_plan.install_actions.at(1), "b", {"core"}, Test::X64_WINDOWS); // REQUIRE(install_plan.at(1).install_action.get()->computed_dependencies == std::vector<PackageSpec>{spec_c}); - features_check(install_plan.install_actions.at(2), "a", {"core"}, Triplet::X64_WINDOWS); + features_check(install_plan.install_actions.at(2), "a", {"core"}, Test::X64_WINDOWS); // REQUIRE(install_plan.at(2).install_action.get()->computed_dependencies == std::vector<PackageSpec>{spec_b}); } @@ -720,13 +720,13 @@ TEST_CASE ("install plan action dependencies 2", "[plan]") // Add a port "a" which depends on the core of "b", which was already // installed explicitly - PackageSpecMap spec_map(Triplet::X64_WINDOWS); + PackageSpecMap spec_map(Test::X64_WINDOWS); auto spec_c = spec_map.emplace("c"); auto spec_b = spec_map.emplace("b", "c"); spec_map.emplace("a", "c, b"); // Install "a" (without explicit feature specification) - auto install_specs = FullPackageSpec::from_string("a", Triplet::X64_WINDOWS); + auto install_specs = FullPackageSpec::from_string("a", Test::X64_WINDOWS); PortFileProvider::MapPortFileProvider map_port{spec_map.map}; MockCMakeVarProvider var_provider; @@ -736,12 +736,12 @@ TEST_CASE ("install plan action dependencies 2", "[plan]") StatusParagraphs(std::move(status_paragraphs))); REQUIRE(install_plan.size() == 3); - features_check(install_plan.install_actions.at(0), "c", {"core"}, Triplet::X64_WINDOWS); + features_check(install_plan.install_actions.at(0), "c", {"core"}, Test::X64_WINDOWS); - features_check(install_plan.install_actions.at(1), "b", {"core"}, Triplet::X64_WINDOWS); + features_check(install_plan.install_actions.at(1), "b", {"core"}, Test::X64_WINDOWS); // REQUIRE(install_plan.at(1).install_action.get()->computed_dependencies == std::vector<PackageSpec>{spec_c}); - features_check(install_plan.install_actions.at(2), "a", {"core"}, Triplet::X64_WINDOWS); + features_check(install_plan.install_actions.at(2), "a", {"core"}, Test::X64_WINDOWS); // REQUIRE(install_plan.at(2).install_action.get()->computed_dependencies == std::vector<PackageSpec>{spec_b, // spec_c}); } @@ -752,11 +752,11 @@ TEST_CASE ("install plan action dependencies 3", "[plan]") // Add a port "a" which depends on the core of "b", which was already // installed explicitly - PackageSpecMap spec_map(Triplet::X64_WINDOWS); + PackageSpecMap spec_map(Test::X64_WINDOWS); spec_map.emplace("a", "", {{"0", ""}, {"1", "a[0]"}}, {"1"}); // Install "a" (without explicit feature specification) - auto install_specs = FullPackageSpec::from_string("a", Triplet::X64_WINDOWS); + auto install_specs = FullPackageSpec::from_string("a", Test::X64_WINDOWS); PortFileProvider::MapPortFileProvider map_port{spec_map.map}; MockCMakeVarProvider var_provider; @@ -766,7 +766,7 @@ TEST_CASE ("install plan action dependencies 3", "[plan]") StatusParagraphs(std::move(status_paragraphs))); REQUIRE(install_plan.size() == 1); - features_check(install_plan.install_actions.at(0), "a", {"1", "0", "core"}, Triplet::X64_WINDOWS); + features_check(install_plan.install_actions.at(0), "a", {"1", "0", "core"}, Test::X64_WINDOWS); // REQUIRE(install_plan.at(0).install_action.get()->computed_dependencies == std::vector<PackageSpec>{}); } @@ -827,7 +827,7 @@ TEST_CASE ("upgrade with default features 2", "[plan]") StatusParagraphs status_db(std::move(pghs)); - PackageSpecMap spec_map(Triplet::X64_WINDOWS); + PackageSpecMap spec_map(Test::X64_WINDOWS); auto spec_a = spec_map.emplace("a", "b[core]"); auto spec_b = spec_map.emplace("b", "", {{"b0", ""}, {"b1", ""}}, {"b0", "b1"}); @@ -837,10 +837,10 @@ TEST_CASE ("upgrade with default features 2", "[plan]") // The upgrade should install the new default feature b1 but not b0 REQUIRE(plan.size() == 4); - remove_plan_check(plan.remove_actions.at(0), "a", Triplet::X64_WINDOWS); - remove_plan_check(plan.remove_actions.at(1), "b", Triplet::X64_WINDOWS); - features_check(plan.install_actions.at(0), "b", {"core", "b1"}, Triplet::X64_WINDOWS); - features_check(plan.install_actions.at(1), "a", {"core"}, Triplet::X64_WINDOWS); + remove_plan_check(plan.remove_actions.at(0), "a", Test::X64_WINDOWS); + remove_plan_check(plan.remove_actions.at(1), "b", Test::X64_WINDOWS); + features_check(plan.install_actions.at(0), "b", {"core", "b1"}, Test::X64_WINDOWS); + features_check(plan.install_actions.at(1), "a", {"core"}, Test::X64_WINDOWS); } TEST_CASE ("upgrade with default features 3", "[plan]") @@ -852,7 +852,7 @@ TEST_CASE ("upgrade with default features 3", "[plan]") StatusParagraphs status_db(std::move(pghs)); - PackageSpecMap spec_map(Triplet::X64_WINDOWS); + PackageSpecMap spec_map(Test::X64_WINDOWS); auto spec_a = spec_map.emplace("a", "b[core]"); spec_map.emplace("b", "", {{"b0", ""}, {"b1", ""}}, {"b0"}); @@ -862,9 +862,9 @@ TEST_CASE ("upgrade with default features 3", "[plan]") // The upgrade should install the default feature REQUIRE(plan.size() == 3); - remove_plan_check(plan.remove_actions.at(0), "a", Triplet::X64_WINDOWS); - features_check(plan.install_actions.at(0), "b", {"b0", "core"}, Triplet::X64_WINDOWS); - features_check(plan.install_actions.at(1), "a", {"core"}, Triplet::X64_WINDOWS); + remove_plan_check(plan.remove_actions.at(0), "a", Test::X64_WINDOWS); + features_check(plan.install_actions.at(0), "b", {"b0", "core"}, Test::X64_WINDOWS); + features_check(plan.install_actions.at(1), "a", {"core"}, Test::X64_WINDOWS); } TEST_CASE ("upgrade with new default feature", "[plan]") @@ -883,20 +883,20 @@ TEST_CASE ("upgrade with new default feature", "[plan]") // The upgrade should install the new default feature but not the old default feature 0 REQUIRE(plan.size() == 2); - remove_plan_check(plan.remove_actions.at(0), "a", Triplet::X86_WINDOWS); - features_check(plan.install_actions.at(0), "a", {"core", "1"}, Triplet::X86_WINDOWS); + remove_plan_check(plan.remove_actions.at(0), "a", Test::X86_WINDOWS); + features_check(plan.install_actions.at(0), "a", {"core", "1"}, Test::X86_WINDOWS); } TEST_CASE ("transitive features test", "[plan]") { std::vector<std::unique_ptr<StatusParagraph>> status_paragraphs; - PackageSpecMap spec_map(Triplet::X64_WINDOWS); + PackageSpecMap spec_map(Test::X64_WINDOWS); auto spec_a_64 = FullPackageSpec{spec_map.emplace("a", "b", {{"0", "b[0]"}}), {"core"}}; auto spec_b_64 = FullPackageSpec{spec_map.emplace("b", "c", {{"0", "c[0]"}}), {"core"}}; auto spec_c_64 = FullPackageSpec{spec_map.emplace("c", "", {{"0", ""}}), {"core"}}; - auto install_specs = FullPackageSpec::from_string("a[*]", Triplet::X64_WINDOWS); + auto install_specs = FullPackageSpec::from_string("a[*]", Test::X64_WINDOWS); REQUIRE(install_specs.has_value()); if (!install_specs.has_value()) return; @@ -908,21 +908,21 @@ TEST_CASE ("transitive features test", "[plan]") StatusParagraphs(std::move(status_paragraphs))); REQUIRE(install_plan.size() == 3); - features_check(install_plan.install_actions.at(0), "c", {"0", "core"}, Triplet::X64_WINDOWS); - features_check(install_plan.install_actions.at(1), "b", {"0", "core"}, Triplet::X64_WINDOWS); - features_check(install_plan.install_actions.at(2), "a", {"0", "core"}, Triplet::X64_WINDOWS); + features_check(install_plan.install_actions.at(0), "c", {"0", "core"}, Test::X64_WINDOWS); + features_check(install_plan.install_actions.at(1), "b", {"0", "core"}, Test::X64_WINDOWS); + features_check(install_plan.install_actions.at(2), "a", {"0", "core"}, Test::X64_WINDOWS); } TEST_CASE ("no transitive features test", "[plan]") { std::vector<std::unique_ptr<StatusParagraph>> status_paragraphs; - PackageSpecMap spec_map(Triplet::X64_WINDOWS); + PackageSpecMap spec_map(Test::X64_WINDOWS); auto spec_a_64 = FullPackageSpec{spec_map.emplace("a", "b", {{"0", ""}}), {"core"}}; auto spec_b_64 = FullPackageSpec{spec_map.emplace("b", "c", {{"0", ""}}), {"core"}}; auto spec_c_64 = FullPackageSpec{spec_map.emplace("c", "", {{"0", ""}}), {"core"}}; - auto install_specs = FullPackageSpec::from_string("a[*]", Triplet::X64_WINDOWS); + auto install_specs = FullPackageSpec::from_string("a[*]", Test::X64_WINDOWS); REQUIRE(install_specs.has_value()); if (!install_specs.has_value()) return; PortFileProvider::MapPortFileProvider provider(spec_map.map); @@ -933,21 +933,21 @@ TEST_CASE ("no transitive features test", "[plan]") StatusParagraphs(std::move(status_paragraphs))); REQUIRE(install_plan.size() == 3); - features_check(install_plan.install_actions.at(0), "c", {"core"}, Triplet::X64_WINDOWS); - features_check(install_plan.install_actions.at(1), "b", {"core"}, Triplet::X64_WINDOWS); - features_check(install_plan.install_actions.at(2), "a", {"0", "core"}, Triplet::X64_WINDOWS); + features_check(install_plan.install_actions.at(0), "c", {"core"}, Test::X64_WINDOWS); + features_check(install_plan.install_actions.at(1), "b", {"core"}, Test::X64_WINDOWS); + features_check(install_plan.install_actions.at(2), "a", {"0", "core"}, Test::X64_WINDOWS); } TEST_CASE ("only transitive features test", "[plan]") { std::vector<std::unique_ptr<StatusParagraph>> status_paragraphs; - PackageSpecMap spec_map(Triplet::X64_WINDOWS); + PackageSpecMap spec_map(Test::X64_WINDOWS); auto spec_a_64 = FullPackageSpec{spec_map.emplace("a", "", {{"0", "b[0]"}}), {"core"}}; auto spec_b_64 = FullPackageSpec{spec_map.emplace("b", "", {{"0", "c[0]"}}), {"core"}}; auto spec_c_64 = FullPackageSpec{spec_map.emplace("c", "", {{"0", ""}}), {"core"}}; - auto install_specs = FullPackageSpec::from_string("a[*]", Triplet::X64_WINDOWS); + auto install_specs = FullPackageSpec::from_string("a[*]", Test::X64_WINDOWS); REQUIRE(install_specs.has_value()); if (!install_specs.has_value()) return; PortFileProvider::MapPortFileProvider provider(spec_map.map); @@ -958,9 +958,9 @@ TEST_CASE ("only transitive features test", "[plan]") StatusParagraphs(std::move(status_paragraphs))); REQUIRE(install_plan.size() == 3); - features_check(install_plan.install_actions.at(0), "c", {"0", "core"}, Triplet::X64_WINDOWS); - features_check(install_plan.install_actions.at(1), "b", {"0", "core"}, Triplet::X64_WINDOWS); - features_check(install_plan.install_actions.at(2), "a", {"0", "core"}, Triplet::X64_WINDOWS); + features_check(install_plan.install_actions.at(0), "c", {"0", "core"}, Test::X64_WINDOWS); + features_check(install_plan.install_actions.at(1), "b", {"0", "core"}, Test::X64_WINDOWS); + features_check(install_plan.install_actions.at(2), "a", {"0", "core"}, Test::X64_WINDOWS); } TEST_CASE ("basic remove scheme", "[plan]") @@ -969,7 +969,7 @@ TEST_CASE ("basic remove scheme", "[plan]") pghs.push_back(make_status_pgh("a")); StatusParagraphs status_db(std::move(pghs)); - auto remove_plan = Dependencies::create_remove_plan({{"a", Triplet::X86_WINDOWS}}, status_db); + auto remove_plan = Dependencies::create_remove_plan({{"a", Test::X86_WINDOWS}}, status_db); REQUIRE(remove_plan.size() == 1); REQUIRE(remove_plan.at(0).spec.name() == "a"); @@ -982,7 +982,7 @@ TEST_CASE ("recurse remove scheme", "[plan]") pghs.push_back(make_status_pgh("b", "a")); StatusParagraphs status_db(std::move(pghs)); - auto remove_plan = Dependencies::create_remove_plan({{"a", Triplet::X86_WINDOWS}}, status_db); + auto remove_plan = Dependencies::create_remove_plan({{"a", Test::X86_WINDOWS}}, status_db); REQUIRE(remove_plan.size() == 2); REQUIRE(remove_plan.at(0).spec.name() == "b"); @@ -997,7 +997,7 @@ TEST_CASE ("features depend remove scheme", "[plan]") pghs.push_back(make_status_feature_pgh("b", "0", "a")); StatusParagraphs status_db(std::move(pghs)); - auto remove_plan = Dependencies::create_remove_plan({{"a", Triplet::X86_WINDOWS}}, status_db); + auto remove_plan = Dependencies::create_remove_plan({{"a", Test::X86_WINDOWS}}, status_db); REQUIRE(remove_plan.size() == 2); REQUIRE(remove_plan.at(0).spec.name() == "b"); @@ -1013,7 +1013,7 @@ TEST_CASE ("features depend remove scheme once removed", "[plan]") pghs.push_back(make_status_feature_pgh("opencv", "vtk", "vtk")); StatusParagraphs status_db(std::move(pghs)); - auto remove_plan = Dependencies::create_remove_plan({{"expat", Triplet::X86_WINDOWS}}, status_db); + auto remove_plan = Dependencies::create_remove_plan({{"expat", Test::X86_WINDOWS}}, status_db); REQUIRE(remove_plan.size() == 3); REQUIRE(remove_plan.at(0).spec.name() == "opencv"); diff --git a/toolsrc/src/vcpkg-test/specifier.cpp b/toolsrc/src/vcpkg-test/specifier.cpp index f350ff601..f750f4144 100644 --- a/toolsrc/src/vcpkg-test/specifier.cpp +++ b/toolsrc/src/vcpkg-test/specifier.cpp @@ -5,6 +5,8 @@ #include <vcpkg/packagespec.h> +#include <vcpkg-test/util.h> + using namespace vcpkg; TEST_CASE ("specifier conversion", "[specifier]") @@ -13,8 +15,8 @@ TEST_CASE ("specifier conversion", "[specifier]") { constexpr std::size_t SPEC_SIZE = 6; - PackageSpec a_spec("a", Triplet::X64_WINDOWS); - PackageSpec b_spec("b", Triplet::X64_WINDOWS); + PackageSpec a_spec("a", Test::X64_WINDOWS); + PackageSpec b_spec("b", Test::X64_WINDOWS); auto fspecs = FullPackageSpec{a_spec, {"0", "1"}}.to_feature_specs({}, {}); auto fspecs2 = FullPackageSpec{b_spec, {"2", "3"}}.to_feature_specs({}, {}); @@ -94,19 +96,18 @@ TEST_CASE ("specifier parsing", "[specifier]") SECTION ("expand wildcards") { - auto zlib = vcpkg::FullPackageSpec::from_string("zlib[0,1]", Triplet::X86_UWP).value_or_exit(VCPKG_LINE_INFO); - auto openssl = - vcpkg::FullPackageSpec::from_string("openssl[*]", Triplet::X86_UWP).value_or_exit(VCPKG_LINE_INFO); + auto zlib = vcpkg::FullPackageSpec::from_string("zlib[0,1]", Test::X86_UWP).value_or_exit(VCPKG_LINE_INFO); + auto openssl = vcpkg::FullPackageSpec::from_string("openssl[*]", Test::X86_UWP).value_or_exit(VCPKG_LINE_INFO); auto specs = zlib.to_feature_specs({}, {}); auto specs2 = openssl.to_feature_specs({}, {}); Util::Vectors::append(&specs, specs2); Util::sort(specs); std::vector<FeatureSpec> spectargets{ - {{"openssl", Triplet::X86_UWP}, "core"}, - {{"zlib", Triplet::X86_UWP}, "core"}, - {{"zlib", Triplet::X86_UWP}, "0"}, - {{"zlib", Triplet::X86_UWP}, "1"}, + {{"openssl", Test::X86_UWP}, "core"}, + {{"zlib", Test::X86_UWP}, "core"}, + {{"zlib", Test::X86_UWP}, "0"}, + {{"zlib", Test::X86_UWP}, "1"}, }; Util::sort(spectargets); REQUIRE(specs.size() == spectargets.size()); diff --git a/toolsrc/src/vcpkg-test/statusparagraphs.cpp b/toolsrc/src/vcpkg-test/statusparagraphs.cpp index 382eab1a7..f647484e6 100644 --- a/toolsrc/src/vcpkg-test/statusparagraphs.cpp +++ b/toolsrc/src/vcpkg-test/statusparagraphs.cpp @@ -28,7 +28,7 @@ Status: install ok installed StatusParagraphs status_db( Util::fmap(*pghs.get(), [](Paragraph& rpgh) { return std::make_unique<StatusParagraph>(std::move(rpgh)); })); - auto it = status_db.find_installed({"ffmpeg", Triplet::X64_WINDOWS}); + auto it = status_db.find_installed({"ffmpeg", Test::X64_WINDOWS}); REQUIRE(it != status_db.end()); } @@ -49,7 +49,7 @@ Status: purge ok not-installed StatusParagraphs status_db( Util::fmap(*pghs.get(), [](Paragraph& rpgh) { return std::make_unique<StatusParagraph>(std::move(rpgh)); })); - auto it = status_db.find_installed({"ffmpeg", Triplet::X64_WINDOWS}); + auto it = status_db.find_installed({"ffmpeg", Test::X64_WINDOWS}); REQUIRE(it == status_db.end()); } @@ -78,11 +78,11 @@ Status: purge ok not-installed StatusParagraphs status_db( Util::fmap(*pghs.get(), [](Paragraph& rpgh) { return std::make_unique<StatusParagraph>(std::move(rpgh)); })); - auto it = status_db.find_installed({"ffmpeg", Triplet::X64_WINDOWS}); + auto it = status_db.find_installed({"ffmpeg", Test::X64_WINDOWS}); REQUIRE(it != status_db.end()); // Feature "openssl" is not installed and should not be found - auto it1 = status_db.find_installed({{"ffmpeg", Triplet::X64_WINDOWS}, "openssl"}); + auto it1 = status_db.find_installed({{"ffmpeg", Test::X64_WINDOWS}, "openssl"}); REQUIRE(it1 == status_db.end()); } @@ -111,6 +111,6 @@ Status: install ok installed Util::fmap(*pghs.get(), [](Paragraph& rpgh) { return std::make_unique<StatusParagraph>(std::move(rpgh)); })); // Feature "openssl" is installed and should therefore be found - auto it = status_db.find_installed({{"ffmpeg", Triplet::X64_WINDOWS}, "openssl"}); + auto it = status_db.find_installed({{"ffmpeg", Test::X64_WINDOWS}, "openssl"}); REQUIRE(it != status_db.end()); } diff --git a/toolsrc/src/vcpkg-test/util.cpp b/toolsrc/src/vcpkg-test/util.cpp index 74ade3aeb..2841aefa0 100644 --- a/toolsrc/src/vcpkg-test/util.cpp +++ b/toolsrc/src/vcpkg-test/util.cpp @@ -39,6 +39,12 @@ namespace vcpkg::Test { + const Triplet X86_WINDOWS = Triplet::from_canonical_name("x86-windows"); + const Triplet X64_WINDOWS = Triplet::from_canonical_name("x64-windows"); + const Triplet X86_UWP = Triplet::from_canonical_name("x86-uwp"); + const Triplet ARM_UWP = Triplet::from_canonical_name("arm-uwp"); + const Triplet X64_ANDROID = Triplet::from_canonical_name("x64-android"); + std::unique_ptr<SourceControlFile> make_control_file( const char* name, const char* depends, diff --git a/toolsrc/src/vcpkg/archives.cpp b/toolsrc/src/vcpkg/archives.cpp index 35e6427be..c90706928 100644 --- a/toolsrc/src/vcpkg/archives.cpp +++ b/toolsrc/src/vcpkg/archives.cpp @@ -2,6 +2,7 @@ #include <vcpkg/archives.h> #include <vcpkg/commands.h> +#include <vcpkg/tools.h> namespace vcpkg::Archives { diff --git a/toolsrc/src/vcpkg/binarycaching.cpp b/toolsrc/src/vcpkg/binarycaching.cpp index 743ce919a..2c6f0fe98 100644 --- a/toolsrc/src/vcpkg/binarycaching.cpp +++ b/toolsrc/src/vcpkg/binarycaching.cpp @@ -9,6 +9,7 @@ #include <vcpkg/binarycaching.private.h> #include <vcpkg/build.h> #include <vcpkg/dependencies.h> +#include <vcpkg/tools.h> using namespace vcpkg; diff --git a/toolsrc/src/vcpkg/build.cpp b/toolsrc/src/vcpkg/build.cpp index 67015fba5..92dedd8db 100644 --- a/toolsrc/src/vcpkg/build.cpp +++ b/toolsrc/src/vcpkg/build.cpp @@ -23,6 +23,7 @@ #include <vcpkg/paragraphs.h> #include <vcpkg/postbuildlint.h> #include <vcpkg/statusparagraphs.h> +#include <vcpkg/tools.h> #include <vcpkg/vcpkglib.h> using namespace vcpkg; diff --git a/toolsrc/src/vcpkg/buildenvironment.cpp b/toolsrc/src/vcpkg/buildenvironment.cpp index cab2bf551..09d84d0e8 100644 --- a/toolsrc/src/vcpkg/buildenvironment.cpp +++ b/toolsrc/src/vcpkg/buildenvironment.cpp @@ -1,4 +1,5 @@ #include <vcpkg/buildenvironment.h> +#include <vcpkg/tools.h> namespace vcpkg { diff --git a/toolsrc/src/vcpkg/commands.fetch.cpp b/toolsrc/src/vcpkg/commands.fetch.cpp index ee809bb13..e6e59a30c 100644 --- a/toolsrc/src/vcpkg/commands.fetch.cpp +++ b/toolsrc/src/vcpkg/commands.fetch.cpp @@ -1,3 +1,5 @@ +#include <vcpkg/base/system.print.h> + #include <vcpkg/commands.fetch.h> namespace vcpkg::Commands::Fetch diff --git a/toolsrc/src/vcpkg/commands.hash.cpp b/toolsrc/src/vcpkg/commands.hash.cpp index d18173335..5ac5e8aa6 100644 --- a/toolsrc/src/vcpkg/commands.hash.cpp +++ b/toolsrc/src/vcpkg/commands.hash.cpp @@ -1,4 +1,5 @@ #include <vcpkg/base/hash.h> +#include <vcpkg/base/system.print.h> #include <vcpkg/commands.hash.h> diff --git a/toolsrc/src/vcpkg/commands.integrate.cpp b/toolsrc/src/vcpkg/commands.integrate.cpp index 17f3aa350..1aa7d5864 100644 --- a/toolsrc/src/vcpkg/commands.integrate.cpp +++ b/toolsrc/src/vcpkg/commands.integrate.cpp @@ -7,6 +7,7 @@ #include <vcpkg/commands.integrate.h> #include <vcpkg/metrics.h> +#include <vcpkg/tools.h> #include <vcpkg/userconfig.h> namespace vcpkg::Commands::Integrate diff --git a/toolsrc/src/vcpkg/commands.porthistory.cpp b/toolsrc/src/vcpkg/commands.porthistory.cpp index 6b6217732..6f45e26ed 100644 --- a/toolsrc/src/vcpkg/commands.porthistory.cpp +++ b/toolsrc/src/vcpkg/commands.porthistory.cpp @@ -4,6 +4,7 @@ #include <vcpkg/commands.porthistory.h> #include <vcpkg/help.h> +#include <vcpkg/tools.h> namespace vcpkg::Commands::PortHistory { diff --git a/toolsrc/src/vcpkg/commands.portsdiff.cpp b/toolsrc/src/vcpkg/commands.portsdiff.cpp index 97e903769..ad27599fb 100644 --- a/toolsrc/src/vcpkg/commands.portsdiff.cpp +++ b/toolsrc/src/vcpkg/commands.portsdiff.cpp @@ -6,6 +6,7 @@ #include <vcpkg/commands.portsdiff.h> #include <vcpkg/help.h> #include <vcpkg/paragraphs.h> +#include <vcpkg/tools.h> #include <vcpkg/versiont.h> namespace vcpkg::Commands::PortsDiff diff --git a/toolsrc/src/vcpkg/export.chocolatey.cpp b/toolsrc/src/vcpkg/export.chocolatey.cpp index 096c99d89..abaea6921 100644 --- a/toolsrc/src/vcpkg/export.chocolatey.cpp +++ b/toolsrc/src/vcpkg/export.chocolatey.cpp @@ -5,6 +5,7 @@ #include <vcpkg/export.chocolatey.h> #include <vcpkg/export.h> #include <vcpkg/install.h> +#include <vcpkg/tools.h> namespace vcpkg::Export::Chocolatey { diff --git a/toolsrc/src/vcpkg/export.cpp b/toolsrc/src/vcpkg/export.cpp index 39cb9328f..f8691aa04 100644 --- a/toolsrc/src/vcpkg/export.cpp +++ b/toolsrc/src/vcpkg/export.cpp @@ -13,6 +13,7 @@ #include <vcpkg/input.h> #include <vcpkg/install.h> #include <vcpkg/paragraphs.h> +#include <vcpkg/tools.h> #include <vcpkg/vcpkglib.h> namespace vcpkg::Export diff --git a/toolsrc/src/vcpkg/export.ifw.cpp b/toolsrc/src/vcpkg/export.ifw.cpp index 512e119b0..45b600801 100644 --- a/toolsrc/src/vcpkg/export.ifw.cpp +++ b/toolsrc/src/vcpkg/export.ifw.cpp @@ -5,6 +5,7 @@ #include <vcpkg/export.h> #include <vcpkg/export.ifw.h> #include <vcpkg/install.h> +#include <vcpkg/tools.h> namespace vcpkg::Export::IFW { diff --git a/toolsrc/src/vcpkg/export.prefab.cpp b/toolsrc/src/vcpkg/export.prefab.cpp index 630e20f72..51ac868c7 100644 --- a/toolsrc/src/vcpkg/export.prefab.cpp +++ b/toolsrc/src/vcpkg/export.prefab.cpp @@ -9,6 +9,7 @@ #include <vcpkg/export.h> #include <vcpkg/export.prefab.h> #include <vcpkg/install.h> +#include <vcpkg/tools.h> namespace vcpkg::Export::Prefab { diff --git a/toolsrc/src/vcpkg/triplet.cpp b/toolsrc/src/vcpkg/triplet.cpp index 789943237..c9ae74970 100644 --- a/toolsrc/src/vcpkg/triplet.cpp +++ b/toolsrc/src/vcpkg/triplet.cpp @@ -1,6 +1,7 @@ #include <vcpkg/base/strings.h> #include <vcpkg/triplet.h> +#include <vcpkg/vcpkgcmdarguments.h> namespace vcpkg { @@ -27,25 +28,9 @@ namespace std namespace vcpkg { - static std::unordered_set<TripletInstance> g_triplet_instances; - - const Triplet Triplet::X86_WINDOWS = from_canonical_name("x86-windows"); - const Triplet Triplet::X64_WINDOWS = from_canonical_name("x64-windows"); - const Triplet Triplet::ARM_WINDOWS = from_canonical_name("arm-windows"); - const Triplet Triplet::ARM64_WINDOWS = from_canonical_name("arm64-windows"); - const Triplet Triplet::X86_UWP = from_canonical_name("x86-uwp"); - const Triplet Triplet::X64_UWP = from_canonical_name("x64-uwp"); - const Triplet Triplet::ARM_UWP = from_canonical_name("arm-uwp"); - const Triplet Triplet::ARM64_UWP = from_canonical_name("arm64-uwp"); - - // - const Triplet Triplet::ARM_ANDROID = from_canonical_name("arm-android"); - const Triplet Triplet::ARM64_ANDROID = from_canonical_name("arm64-android"); - const Triplet Triplet::X86_ANDROID = from_canonical_name("x86-android"); - const Triplet Triplet::X64_ANDROID = from_canonical_name("x64-android"); - Triplet Triplet::from_canonical_name(std::string&& triplet_as_string) { + static std::unordered_set<TripletInstance> g_triplet_instances; std::string s(Strings::ascii_to_lowercase(std::move(triplet_as_string))); const auto p = g_triplet_instances.emplace(std::move(s)); return &*p.first; @@ -60,19 +45,19 @@ namespace vcpkg Optional<System::CPUArchitecture> Triplet::guess_architecture() const noexcept { using System::CPUArchitecture; - if (*this == X86_WINDOWS || *this == X86_UWP || *this == X86_ANDROID) + if (Strings::starts_with(this->canonical_name(), "x86-")) { return CPUArchitecture::X86; } - else if (*this == X64_WINDOWS || *this == X64_UWP || *this == X64_ANDROID) + if (Strings::starts_with(this->canonical_name(), "x64-")) { return CPUArchitecture::X64; } - else if (*this == ARM_WINDOWS || *this == ARM_UWP || *this == ARM_ANDROID) + if (Strings::starts_with(this->canonical_name(), "arm-")) { return CPUArchitecture::ARM; } - else if (*this == ARM64_WINDOWS || *this == ARM64_UWP || *this == ARM64_ANDROID) + if (Strings::starts_with(this->canonical_name(), "arm64-")) { return CPUArchitecture::ARM64; } @@ -96,7 +81,7 @@ namespace vcpkg else { #if defined(_WIN32) - return Triplet::X86_WINDOWS; + return Triplet::from_canonical_name("x86-windows"); #elif defined(__APPLE__) return Triplet::from_canonical_name("x64-osx"); #elif defined(__FreeBSD__) diff --git a/toolsrc/src/vcpkg/vcpkgpaths.cpp b/toolsrc/src/vcpkg/vcpkgpaths.cpp index 6572b44f1..4f7ef7141 100644 --- a/toolsrc/src/vcpkg/vcpkgpaths.cpp +++ b/toolsrc/src/vcpkg/vcpkgpaths.cpp @@ -5,11 +5,14 @@ #include <vcpkg/base/system.process.h> #include <vcpkg/base/util.h> +#include <vcpkg/binaryparagraph.h> #include <vcpkg/build.h> #include <vcpkg/commands.h> #include <vcpkg/globalstate.h> #include <vcpkg/metrics.h> #include <vcpkg/packagespec.h> +#include <vcpkg/tools.h> +#include <vcpkg/vcpkgcmdarguments.h> #include <vcpkg/vcpkgpaths.h> #include <vcpkg/visualstudio.h> |
