[vcpkg] Port to vcpkg-tool
MODIFY
.gitignore
.gitignore
/.vscode
+/build*
+*.swp

ADD
azure-pipelines/e2e_ports/overlays/vcpkg-default-features-fail-require-other-feature/portfile.cmake
+set(VCPKG_POLICY_EMPTY_PACKAGE enabled)
+if("default-feature" IN_LIST FEATURES)
+ message(FATAL_ERROR "the default feature was depended upon")
+endif()
+if(NOT "success" IN_LIST FEATURES)
+ message(FATAL_ERROR "the success feature was not depended upon")
+endif()

ADD
azure-pipelines/e2e_ports/overlays/vcpkg-default-features-fail-require-other-feature/vcpkg.json
+{
+ "name": "vcpkg-default-features-fail-require-other-feature",
+ "version": "0",
+ "default-features": [
+ "default-feature"
+ ],
+ "features": {
+ "default-feature": {
+ "description": ""
+ },
+ "success": {
+ "description": ""
+ }
+ }
+}

ADD
azure-pipelines/e2e_ports/overlays/vcpkg-default-features-fail/portfile.cmake
+set(VCPKG_POLICY_EMPTY_PACKAGE enabled)
+if("default-feature" IN_LIST FEATURES)
+ message(FATAL_ERROR "the default feature was depended upon")
+endif()

ADD
azure-pipelines/e2e_ports/overlays/vcpkg-default-features-fail/vcpkg.json
+{
+ "name": "vcpkg-default-features-fail",
+ "version": "0",
+ "default-features": [
+ "default-feature"
+ ],
+ "features": {
+ "default-feature": {
+ "description": ""
+ }
+ }
+}

ADD
azure-pipelines/e2e_ports/overlays/vcpkg-empty-port/portfile.cmake
+set(VCPKG_POLICY_EMPTY_PACKAGE enabled)

ADD
azure-pipelines/e2e_ports/overlays/vcpkg-empty-port/vcpkg.json
+{
+ "name": "vcpkg-empty-port",
+ "version": "0"
+}

ADD
azure-pipelines/e2e_ports/overlays/vcpkg-fail-if-depended-upon/portfile.cmake
+set(VCPKG_POLICY_EMPTY_PACKAGE enabled)
+message(FATAL_ERROR "this port should not be depended upon")

ADD
azure-pipelines/e2e_ports/overlays/vcpkg-fail-if-depended-upon/vcpkg.json
+{
+ "name": "vcpkg-fail-if-depended-upon",
+ "version": "0"
+}

ADD
azure-pipelines/end-to-end-tests-dir/manifests.ps1
+. "$PSScriptRoot/../end-to-end-tests-prelude.ps1"
+
+
+Write-Trace "test manifest features"
+$manifestDir = "$TestingRoot/manifest-dir"
+
+$manifestDirArgs = $commonArgs + @("--x-manifest-root=$manifestDir")
+$noDefaultFeatureArgs = $manifestDirArgs + @('--x-no-default-features')
+
+function feature {
+ @{
+ 'description' = '';
+ 'dependencies' = $args;
+ }
+}
+
+$vcpkgJson = @{
+ 'name' = "manifest-test";
+ 'version' = "1.0.0";
+ 'default-features' = @( 'default-fail' );
+ 'features' = @{
+ 'default-fail' = feature 'vcpkg-fail-if-depended-upon';
+ 'copied-feature' = feature 'vcpkg-empty-port'
+ 'multiple-dep-1' = feature 'vcpkg-empty-port'
+ 'multiple-dep-2' = feature 'vcpkg-empty-port'
+ 'no-default-features-1' = feature @{
+ 'name' = 'vcpkg-default-features-fail';
+ 'default-features' = $False;
+ };
+ 'no-default-features-2' = feature @{
+ 'name' = 'vcpkg-default-features-fail-require-other-feature';
+ 'default-features' = $False;
+ 'features' = @( 'success' )
+ };
+ }
+}
+
+New-Item -Path $manifestDir -ItemType Directory
+$manifestDir = (Get-Item $manifestDir).FullName
+New-Item -Path "$manifestDir/vcpkg.json" -ItemType File `
+ -Value (ConvertTo-Json -Depth 5 -InputObject $vcpkgJson)
+
+Write-Trace "test manifest features: default-features, features = []"
+Run-Vcpkg install @manifestDirArgs
+Throw-IfNotFailed
+
+Write-Trace "test manifest features: no-default-features, features = []"
+Run-Vcpkg install @manifestDirArgs --x-no-default-features
+Throw-IfFailed
+Write-Trace "test manifest features: default-features, features = [core]"
+Run-Vcpkg install @manifestDirArgs --x-feature=core
+Throw-IfFailed
+# test having both
+Write-Trace "test manifest features: no-default-features, features = [core]"
+Run-Vcpkg install @manifestDirArgs --x-no-default-features --x-feature=core
+Throw-IfFailed
+
+Write-Trace "test manifest features: no-default-features, features = [default-fail]"
+Run-Vcpkg install @manifestDirArgs --x-no-default-features --x-feature=default-fail
+Throw-IfNotFailed
+Write-Trace "test manifest features: default-features, features = [core, default-fail]"
+Run-Vcpkg install @manifestDirArgs --x-feature=core --x-feature=default-fail
+Throw-IfNotFailed
+
+Write-Trace "test manifest features: no-default-features, features = [copied-feature]"
+Run-Vcpkg install @noDefaultFeatureArgs --x-feature=copied-feature
+Throw-IfFailed
+Write-Trace "test manifest features: no-default-features, features = [copied-feature, copied-feature]"
+Run-Vcpkg install @noDefaultFeatureArgs --x-feature=copied-feature --x-feature=copied-feature
+Throw-IfFailed
+
+Write-Trace "test manifest features: no-default-features, features = [multiple-dep-1, multiple-dep-2]"
+Run-Vcpkg install @noDefaultFeatureArgs --x-feature=multiple-dep-1 --x-feature=multiple-dep-2
+Throw-IfFailed
+
+Write-Trace "test manifest features: no-default-features, features = [no-default-features-1]"
+Run-Vcpkg install @noDefaultFeatureArgs --x-feature=no-default-features-1
+Throw-IfFailed
+Write-Trace "test manifest features: no-default-features, features = [no-default-features-2]"
+Run-Vcpkg install @noDefaultFeatureArgs --x-feature=no-default-features-2
+Throw-IfFailed

MODIFY
include/vcpkg/binaryparagraph.h
include/vcpkg/binaryparagraph.h
@@ -22,6 +22,8 @@ namespace vcpkg
Triplet triplet,
const std::vector<FeatureSpec>& deps);
+ void canonicalize();
+
std::string displayname() const;
std::string fullstem() const;

MODIFY
src/vcpkg/binaryparagraph.cpp
src/vcpkg/binaryparagraph.cpp
@@ -64,15 +64,7 @@ namespace vcpkg
}
this->description = Strings::split(parser.optional_field(Fields::DESCRIPTION), '\n');
- for (auto& desc : this->description)
- {
- desc = Strings::trim(std::move(desc));
- }
this->maintainers = Strings::split(parser.optional_field(Fields::MAINTAINER), '\n');
- for (auto& maintainer : this->maintainers)
- {
- maintainer = Strings::trim(std::move(maintainer));
- }
this->abi = parser.optional_field(Fields::ABI);
@@ -102,6 +94,8 @@ namespace vcpkg
// prefer failing above when possible because it gives better information
Checks::check_exit(VCPKG_LINE_INFO, multi_arch == "same", "Multi-Arch must be 'same' but was %s", multi_arch);
+
+ canonicalize();
}
BinaryParagraph::BinaryParagraph(const SourceParagraph& spgh,
@@ -120,7 +114,7 @@ namespace vcpkg
, type(spgh.type)
{
this->dependencies = Util::fmap(deps, [](const FeatureSpec& spec) { return spec.spec().name(); });
- Util::sort_unique_erase(this->dependencies);
+ canonicalize();
}
BinaryParagraph::BinaryParagraph(const SourceParagraph& spgh,
@@ -139,7 +133,34 @@ namespace vcpkg
, type(spgh.type)
{
this->dependencies = Util::fmap(deps, [](const FeatureSpec& spec) { return spec.spec().name(); });
+ canonicalize();
+ }
+
+ void BinaryParagraph::canonicalize()
+ {
+ constexpr auto all_empty = [](const std::vector<std::string>& range) {
+ return std::all_of(range.begin(), range.end(), [](const std::string& el) { return el.empty(); });
+ };
+
Util::sort_unique_erase(this->dependencies);
+
+ for (auto& maintainer : this->maintainers)
+ {
+ maintainer = Strings::trim(std::move(maintainer));
+ }
+ if (all_empty(this->maintainers))
+ {
+ this->maintainers.clear();
+ }
+
+ for (auto& desc : this->description)
+ {
+ desc = Strings::trim(std::move(desc));
+ }
+ if (all_empty(this->description))
+ {
+ this->description.clear();
+ }
}
std::string BinaryParagraph::displayname() const

MODIFY
src/vcpkg/dependencies.cpp
src/vcpkg/dependencies.cpp
@@ -1651,22 +1651,20 @@ namespace vcpkg::Dependencies
auto& node = emplace_package(spec);
auto maybe_overlay = m_o_provider.get_control_file(dep.name);
+ auto over_it = m_overrides.find(dep.name);
if (auto p_overlay = maybe_overlay.get())
{
auto ver = to_version(*p_overlay->source_control_file);
m_roots.push_back(DepSpec{spec, ver, dep.features});
add_constraint(node, ver, toplevel.name());
- continue;
}
-
- auto over_it = m_overrides.find(dep.name);
- if (over_it != m_overrides.end())
+ else if (over_it != m_overrides.end())
{
m_roots.push_back(DepSpec{spec, over_it->second, dep.features});
add_constraint(node, over_it->second, toplevel.name());
- continue;
}
-
+ else
+ {
auto dep_ver = to_version(dep.constraint);
auto base_ver = m_base_provider.get_baseline_version(dep.name);
if (auto p_dep_ver = dep_ver.get())
@@ -1679,8 +1677,8 @@ namespace vcpkg::Dependencies
auto base_scfl = m_ver_provider.get_control_file({dep.name, *p_base_ver});
if (dep_scfl && base_scfl)
{
- auto r =
- compare_versions(dep_scfl.get()->source_control_file->core_paragraph->version_scheme,
+ auto r = compare_versions(
+ dep_scfl.get()->source_control_file->core_paragraph->version_scheme,
*p_dep_ver,
base_scfl.get()->source_control_file->core_paragraph->version_scheme,
*p_base_ver);
@@ -1717,6 +1715,7 @@ namespace vcpkg::Dependencies
dep.name,
" without a baseline entry or override."));
}
+ }
for (auto&& f : dep.features)
{

MODIFY
src/vcpkg/install.cpp
src/vcpkg/install.cpp
@@ -836,15 +836,40 @@ namespace vcpkg::Install
features.insert(features.end(), manifest_feature_it->second.begin(), manifest_feature_it->second.end());
}
auto core_it = Util::find(features, "core");
- if (core_it == features.end())
+ if (core_it == features.end() &&
+ !Util::Sets::contains(options.switches, OPTION_MANIFEST_NO_DEFAULT_FEATURES))
{
- if (!Util::Sets::contains(options.switches, OPTION_MANIFEST_NO_DEFAULT_FEATURES))
- features.push_back("default");
+ const auto& default_features = manifest_scf.core_paragraph->default_features;
+ features.insert(features.end(), default_features.begin(), default_features.end());
}
else
{
// remove "core" because resolve_deps_as_top_level uses default-inversion
- features.erase(core_it);
+ // support multiple core features
+ core_it = std::remove(core_it, features.end(), "core");
+ features.erase(core_it, features.end());
+ }
+ Util::sort_unique_erase(features);
+
+ auto dependencies = manifest_scf.core_paragraph->dependencies;
+ for (const auto& feature : features)
+ {
+ auto it = Util::find_if(
+ manifest_scf.feature_paragraphs,
+ [&feature](const std::unique_ptr<FeatureParagraph>& fpgh) { return fpgh->name == feature; });
+
+ if (it == manifest_scf.feature_paragraphs.end())
+ {
+ System::printf(System::Color::warning,
+ "Warning: feature %s was passed, but that is not a feature that %s supports.",
+ feature,
+ manifest_scf.core_paragraph->name);
+ }
+ else
+ {
+ dependencies.insert(
+ dependencies.end(), it->get()->dependencies.begin(), it->get()->dependencies.end());
+ }
}
if (!manifest_scf.core_paragraph->overrides.empty())
@@ -876,7 +901,7 @@ namespace vcpkg::Install
*baseprovider,
*oprovider,
var_provider,
- manifest_scf.core_paragraph->dependencies,
+ dependencies,
manifest_scf.core_paragraph->overrides,
{manifest_scf.core_paragraph->name, default_triplet})
.value_or_exit(VCPKG_LINE_INFO);

[vcpkg] Port #14944 to vcpkg-tool