Skip to content

Commit

Permalink
Address CR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ras0219-msft committed Jan 6, 2022
1 parent 5ec16a2 commit 0a5af2c
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 22 deletions.
2 changes: 1 addition & 1 deletion include/vcpkg-test/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
8 changes: 4 additions & 4 deletions include/vcpkg/packagespec.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ namespace vcpkg
}

/// Splats into individual FeatureSpec's
void expand_to(std::vector<FeatureSpec>& out) const;
void expand_fpsecs_to(std::vector<FeatureSpec>& oFut) const;

friend bool operator==(const FullPackageSpec& l, const FullPackageSpec& r)
{
Expand All @@ -139,10 +139,10 @@ namespace vcpkg
}
};

enum class ImplicitDefault
enum class ImplicitDefault : bool
{
no,
yes,
NO,
YES,
};

struct Dependency
Expand Down
6 changes: 3 additions & 3 deletions src/vcpkg-test/specifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ TEST_CASE ("specifier conversion", "[specifier]")
PackageSpec b_spec("b", Test::X64_WINDOWS);

std::vector<FeatureSpec> 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);

Expand Down Expand Up @@ -99,7 +99,7 @@ TEST_CASE ("specifier parsing", "[specifier]")
std::vector<FeatureSpec> 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<FeatureSpec> spectargets{
Expand Down
4 changes: 2 additions & 2 deletions src/vcpkg-test/versionplan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
9 changes: 5 additions & 4 deletions src/vcpkg/dependencies.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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
{
Expand Down Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion src/vcpkg/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
18 changes: 11 additions & 7 deletions src/vcpkg/packagespec.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <vcpkg/base/checks.h>
#include <vcpkg/base/messages.h>
#include <vcpkg/base/parse.h>
#include <vcpkg/base/util.h>

Expand All @@ -19,7 +20,7 @@ namespace vcpkg
Strings::append(out, port(), '[', feature(), "]:", triplet());
}

void FullPackageSpec::expand_to(std::vector<FeatureSpec>& out) const
void FullPackageSpec::expand_fpsecs_to(std::vector<FeatureSpec>& out) const
{
for (auto&& feature : features)
{
Expand Down Expand Up @@ -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<std::string> fs, ImplicitDefault id)
{
Expand All @@ -67,7 +71,7 @@ namespace vcpkg
if (!core)
{
ret.emplace_back("core");
if (id == ImplicitDefault::yes)
if (id == ImplicitDefault::YES)
{
ret.emplace_back("default");
}
Expand All @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 0a5af2c

Please sign in to comment.