From 16faed678540be37ea623fa7f0f2c2e7c442b147 Mon Sep 17 00:00:00 2001 From: Squareys Date: Fri, 16 Feb 2018 14:27:04 +0100 Subject: [vcpkg] Add find/find_installed/is_installed for FeatureSpec Signed-off-by: Squareys --- toolsrc/src/tests.statusparagraphs.cpp | 33 +++++++++++++++++++++++++++++++++ toolsrc/src/vcpkg/statusparagraphs.cpp | 19 +++++++++++++++++++ 2 files changed, 52 insertions(+) (limited to 'toolsrc/src') diff --git a/toolsrc/src/tests.statusparagraphs.cpp b/toolsrc/src/tests.statusparagraphs.cpp index 0d5324a8c..fa0d54fac 100644 --- a/toolsrc/src/tests.statusparagraphs.cpp +++ b/toolsrc/src/tests.statusparagraphs.cpp @@ -77,6 +77,39 @@ Status: purge ok not-installed auto it = status_db.find_installed(unsafe_pspec("ffmpeg", Triplet::X64_WINDOWS)); Assert::IsTrue(it != status_db.end()); + + // Feature "openssl" is not installed and should not be found + auto it1 = status_db.find_installed({unsafe_pspec("ffmpeg", Triplet::X64_WINDOWS), "openssl"}); + Assert::IsTrue(it1 == status_db.end()); + } + + TEST_METHOD(find_for_feature_packages) + { + auto pghs = parse_paragraphs(R"( +Package: ffmpeg +Version: 3.3.3 +Architecture: x64-windows +Multi-Arch: same +Description: +Status: install ok installed + +Package: ffmpeg +Feature: openssl +Depends: openssl +Architecture: x64-windows +Multi-Arch: same +Description: +Status: install ok installed +)"); + Assert::IsTrue(!!pghs); + if (!pghs) return; + + StatusParagraphs status_db(Util::fmap( + *pghs.get(), [](RawParagraph& rpgh) { return std::make_unique(std::move(rpgh)); })); + + // Feature "openssl" is installed and should therefore be found + auto it = status_db.find_installed({unsafe_pspec("ffmpeg", Triplet::X64_WINDOWS), "openssl"}); + Assert::IsTrue(it != status_db.end()); } }; } diff --git a/toolsrc/src/vcpkg/statusparagraphs.cpp b/toolsrc/src/vcpkg/statusparagraphs.cpp index 475f86279..b23d8b884 100644 --- a/toolsrc/src/vcpkg/statusparagraphs.cpp +++ b/toolsrc/src/vcpkg/statusparagraphs.cpp @@ -83,12 +83,31 @@ namespace vcpkg } } + StatusParagraphs::const_iterator StatusParagraphs::find_installed(const FeatureSpec& spec) const + { + auto it = find(spec); + if (it != end() && (*it)->is_installed()) + { + return it; + } + else + { + return end(); + } + } + bool vcpkg::StatusParagraphs::is_installed(const PackageSpec& spec) const { auto it = find(spec); return it != end() && (*it)->is_installed(); } + bool vcpkg::StatusParagraphs::is_installed(const FeatureSpec& spec) const + { + auto it = find(spec); + return it != end() && (*it)->is_installed(); + } + StatusParagraphs::iterator StatusParagraphs::insert(std::unique_ptr pgh) { Checks::check_exit(VCPKG_LINE_INFO, pgh != nullptr, "Inserted null paragraph"); -- cgit v1.2.3 From f1ce125a28c98fd5a87bf509ac965b06c219d8f3 Mon Sep 17 00:00:00 2001 From: Squareys Date: Fri, 16 Feb 2018 14:27:32 +0100 Subject: [vcpkg] Fix build command for packages that depend of features Signed-off-by: Squareys --- toolsrc/src/vcpkg/build.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'toolsrc/src') diff --git a/toolsrc/src/vcpkg/build.cpp b/toolsrc/src/vcpkg/build.cpp index 7de276f4f..cc376c773 100644 --- a/toolsrc/src/vcpkg/build.cpp +++ b/toolsrc/src/vcpkg/build.cpp @@ -267,13 +267,16 @@ namespace vcpkg::Build const Triplet& triplet = config.triplet; { - std::vector missing_specs; + std::vector missing_specs; for (auto&& dep : filter_dependencies(config.scf.core_paragraph->depends, triplet)) { - auto dep_spec = PackageSpec::from_name_and_triplet(dep, triplet).value_or_exit(VCPKG_LINE_INFO); - if (!status_db.is_installed(dep_spec)) + auto dep_specs = FeatureSpec::from_strings_and_triplet({dep}, triplet); + for (auto&& feature : dep_specs) { - missing_specs.push_back(std::move(dep_spec)); + if (!status_db.is_installed(feature)) + { + missing_specs.push_back(std::move(feature)); + } } } // Fail the build if any dependencies were missing @@ -600,7 +603,7 @@ namespace vcpkg::Build : code(code), binary_control_file(std::move(bcf)) { } - ExtendedBuildResult::ExtendedBuildResult(BuildResult code, std::vector&& unmet_deps) + ExtendedBuildResult::ExtendedBuildResult(BuildResult code, std::vector&& unmet_deps) : code(code), unmet_dependencies(std::move(unmet_deps)) { } -- cgit v1.2.3