From 0a5af2ca8dbcad9ac0fb71883f6f24650b968273 Mon Sep 17 00:00:00 2001 From: Robert Schumacher Date: Thu, 6 Jan 2022 17:03:53 +0000 Subject: [PATCH] Address CR comments --- include/vcpkg-test/util.h | 2 +- include/vcpkg/packagespec.h | 8 ++++---- src/vcpkg-test/specifier.cpp | 6 +++--- src/vcpkg-test/versionplan.cpp | 4 ++-- src/vcpkg/dependencies.cpp | 9 +++++---- src/vcpkg/input.cpp | 2 +- src/vcpkg/packagespec.cpp | 18 +++++++++++------- 7 files changed, 27 insertions(+), 22 deletions(-) diff --git a/include/vcpkg-test/util.h b/include/vcpkg-test/util.h index 9789d29673..5a4b9c7070 100644 --- a/include/vcpkg-test/util.h +++ b/include/vcpkg-test/util.h @@ -124,7 +124,7 @@ namespace vcpkg::Test { auto opt = parse_qualified_specifier(parser); REQUIRE(opt.has_value()); - ret.push_back(unwrap(opt.get()->to_full_spec(t, ImplicitDefault::yes))); + ret.push_back(unwrap(opt.get()->to_full_spec(t, ImplicitDefault::YES))); } return ret; } diff --git a/include/vcpkg/packagespec.h b/include/vcpkg/packagespec.h index 9ce8ca01a4..941adc8301 100644 --- a/include/vcpkg/packagespec.h +++ b/include/vcpkg/packagespec.h @@ -117,7 +117,7 @@ namespace vcpkg } /// Splats into individual FeatureSpec's - void expand_to(std::vector& out) const; + void expand_fpsecs_to(std::vector& oFut) const; friend bool operator==(const FullPackageSpec& l, const FullPackageSpec& r) { @@ -139,10 +139,10 @@ namespace vcpkg } }; - enum class ImplicitDefault + enum class ImplicitDefault : bool { - no, - yes, + NO, + YES, }; struct Dependency diff --git a/src/vcpkg-test/specifier.cpp b/src/vcpkg-test/specifier.cpp index e3b8838854..7b62b184d8 100644 --- a/src/vcpkg-test/specifier.cpp +++ b/src/vcpkg-test/specifier.cpp @@ -19,8 +19,8 @@ TEST_CASE ("specifier conversion", "[specifier]") PackageSpec b_spec("b", Test::X64_WINDOWS); std::vector fspecs; - FullPackageSpec{a_spec, {"0", "1"}}.expand_to(fspecs); - FullPackageSpec{b_spec, {"2", "3"}}.expand_to(fspecs); + FullPackageSpec{a_spec, {"0", "1"}}.expand_fpsecs_to(fspecs); + FullPackageSpec{b_spec, {"2", "3"}}.expand_fpsecs_to(fspecs); Util::sort(fspecs); REQUIRE(fspecs.size() == SPEC_SIZE); @@ -99,7 +99,7 @@ TEST_CASE ("specifier parsing", "[specifier]") std::vector specs; const auto fspecs = Test::parse_test_fspecs("zlib[core,0,1]:x86-uwp openssl[*]:x86-uwp"); for (auto&& fs : fspecs) - fs.expand_to(specs); + fs.expand_fpsecs_to(specs); Util::sort(specs); std::vector spectargets{ diff --git a/src/vcpkg-test/versionplan.cpp b/src/vcpkg-test/versionplan.cpp index f76c8d38c5..2e165807d3 100644 --- a/src/vcpkg-test/versionplan.cpp +++ b/src/vcpkg-test/versionplan.cpp @@ -40,7 +40,7 @@ TEST_CASE ("filter depends", "[dependencies]") SECTION ("x64-windows") { auto v = - filter_dependencies(deps, Test::X64_WINDOWS, Test::X86_WINDOWS, x64_win_cmake_vars, ImplicitDefault::yes); + filter_dependencies(deps, Test::X64_WINDOWS, Test::X86_WINDOWS, x64_win_cmake_vars, ImplicitDefault::YES); REQUIRE(v.size() == 2); REQUIRE(v.at(0).package_spec.name() == "liba"); REQUIRE(v.at(0).features == defaults); @@ -50,7 +50,7 @@ TEST_CASE ("filter depends", "[dependencies]") SECTION ("arm-uwp") { - auto v2 = filter_dependencies(deps, Test::ARM_UWP, Test::X86_WINDOWS, arm_uwp_cmake_vars, ImplicitDefault::no); + auto v2 = filter_dependencies(deps, Test::ARM_UWP, Test::X86_WINDOWS, arm_uwp_cmake_vars, ImplicitDefault::NO); REQUIRE(v2.size() == 2); REQUIRE(v2.at(0).package_spec.name() == "libb"); REQUIRE(v2.at(0).features == core); diff --git a/src/vcpkg/dependencies.cpp b/src/vcpkg/dependencies.cpp index 940471de8a..0d3d991b83 100644 --- a/src/vcpkg/dependencies.cpp +++ b/src/vcpkg/dependencies.cpp @@ -127,11 +127,11 @@ namespace vcpkg::Dependencies { // Qualified dependency resolution is available auto fullspec_list = filter_dependencies( - *qualified_deps, m_spec.triplet(), host_triplet, *vars, ImplicitDefault::yes); + *qualified_deps, m_spec.triplet(), host_triplet, *vars, ImplicitDefault::YES); for (auto&& fspec : fullspec_list) { - fspec.expand_to(dep_list); + fspec.expand_fpsecs_to(dep_list); } Util::sort_unique_erase(dep_list); @@ -144,7 +144,8 @@ namespace vcpkg::Dependencies { if (dep.platform.is_empty()) { - dep.to_full_spec(m_spec.triplet(), host_triplet, ImplicitDefault::yes).expand_to(dep_list); + dep.to_full_spec(m_spec.triplet(), host_triplet, ImplicitDefault::YES) + .expand_fpsecs_to(dep_list); } else { @@ -689,7 +690,7 @@ namespace vcpkg::Dependencies for (const FullPackageSpec& spec : specs) { pgraph.mark_user_requested(spec.package_spec); - spec.expand_to(feature_specs); + spec.expand_fpsecs_to(feature_specs); } Util::sort_unique_erase(feature_specs); diff --git a/src/vcpkg/input.cpp b/src/vcpkg/input.cpp index ba3707df99..eabc0a9777 100644 --- a/src/vcpkg/input.cpp +++ b/src/vcpkg/input.cpp @@ -48,7 +48,7 @@ namespace vcpkg { const std::string as_lowercase = Strings::ascii_to_lowercase(std::move(full_package_spec_as_string)); auto expected_spec = parse_qualified_specifier(as_lowercase) - .then(&ParsedQualifiedSpecifier::to_full_spec, default_triplet, ImplicitDefault::yes); + .then(&ParsedQualifiedSpecifier::to_full_spec, default_triplet, ImplicitDefault::YES); if (const auto spec = expected_spec.get()) { Input::check_triplet(spec->package_spec.triplet(), paths); diff --git a/src/vcpkg/packagespec.cpp b/src/vcpkg/packagespec.cpp index 60be9a36c2..746d703967 100644 --- a/src/vcpkg/packagespec.cpp +++ b/src/vcpkg/packagespec.cpp @@ -1,4 +1,5 @@ #include +#include #include #include @@ -19,7 +20,7 @@ namespace vcpkg Strings::append(out, port(), '[', feature(), "]:", triplet()); } - void FullPackageSpec::expand_to(std::vector& out) const + void FullPackageSpec::expand_fpsecs_to(std::vector& out) const { for (auto&& feature : features) { @@ -48,8 +49,11 @@ namespace vcpkg return left.name() == right.name() && left.triplet() == right.triplet(); } - static constexpr StringLiteral s_illegal_platform_spec = "platform qualifier is not allowed in this context"; - static constexpr StringLiteral s_illegal_features = "features are not allowed in this context"; + DECLARE_AND_REGISTER_MESSAGE(IllegalPlatformSpec, + (), + "", + "Error: Platform qualifier is not allowed in this context"); + DECLARE_AND_REGISTER_MESSAGE(IllegalFeatures, (), "", "Error: List of features is not allowed in this contect"); static InternalFeatureSet normalize_feature_list(View fs, ImplicitDefault id) { @@ -67,7 +71,7 @@ namespace vcpkg if (!core) { ret.emplace_back("core"); - if (id == ImplicitDefault::yes) + if (id == ImplicitDefault::YES) { ret.emplace_back("default"); } @@ -79,7 +83,7 @@ namespace vcpkg { if (platform) { - return {s_illegal_platform_spec, expected_right_tag}; + return {msg::format(msgIllegalPlatformSpec).data(), expected_right_tag}; } const Triplet t = triplet ? Triplet::from_canonical_name(*triplet.get()) : default_triplet; @@ -91,11 +95,11 @@ namespace vcpkg { if (platform) { - return {s_illegal_platform_spec, expected_right_tag}; + return {msg::format(msgIllegalPlatformSpec).data(), expected_right_tag}; } if (features) { - return {s_illegal_features, expected_right_tag}; + return {msg::format(msgIllegalFeatures).data(), expected_right_tag}; } const Triplet t = triplet ? Triplet::from_canonical_name(*triplet.get()) : default_triplet;