vcpkg add port: Handle feature core. (#1163)
This commit is contained in:
Родитель
fe0ad6ccfb
Коммит
f07df71f42
|
@ -9,18 +9,68 @@ New-Item -Path $manifestDir -ItemType Directory
|
|||
New-Item -Path $manifestPath -ItemType File `
|
||||
-Value (ConvertTo-Json -Depth 5 -InputObject $vcpkgJson)
|
||||
|
||||
Run-Vcpkg add port zlib @manifestDirArgs
|
||||
Run-Vcpkg add port "sqlite3[core]" "sqlite3[core]" @manifestDirArgs
|
||||
Throw-IfFailed
|
||||
|
||||
$expected = @"
|
||||
{
|
||||
"dependencies": [
|
||||
"zlib"
|
||||
{
|
||||
"name": "sqlite3",
|
||||
"default-features": false
|
||||
}
|
||||
]
|
||||
}
|
||||
"@
|
||||
|
||||
$actual = (Get-Content -Path $manifestPath -Raw).TrimEnd()
|
||||
if ($expected -ne $actual) {
|
||||
throw "Add port didn't add zlib dependency correctly.`nExpected: $expected`nActual:$actual"
|
||||
throw "Add port didn't add sqlite3[core] dependency correctly.`nExpected: $expected`nActual:$actual"
|
||||
}
|
||||
|
||||
# Add default features
|
||||
Run-Vcpkg add port "sqlite3" "sqlite3[core]" @manifestDirArgs
|
||||
Throw-IfFailed
|
||||
|
||||
$expected = @"
|
||||
{
|
||||
"dependencies": [
|
||||
"sqlite3"
|
||||
]
|
||||
}
|
||||
"@
|
||||
|
||||
$actual = (Get-Content -Path $manifestPath -Raw).TrimEnd()
|
||||
if ($expected -ne $actual) {
|
||||
throw "Add port didn't add sqlite3 dependency correctly.`nExpected: $expected`nActual:$actual"
|
||||
}
|
||||
|
||||
# Adding sqlite3[core] does not change something because default features are already enabled
|
||||
Run-Vcpkg add port "sqlite3[core]" @manifestDirArgs
|
||||
Throw-IfFailed
|
||||
$actual = (Get-Content -Path $manifestPath -Raw).TrimEnd()
|
||||
if ($expected -ne $actual) {
|
||||
throw "Add port didn't add sqlite3[core] dependency correctly.`nExpected: $expected`nActual:$actual"
|
||||
}
|
||||
|
||||
# Add zlib as a feature in comparison to the previous test
|
||||
Run-Vcpkg add port "sqlite3[core,zlib]" @manifestDirArgs
|
||||
Throw-IfFailed
|
||||
$expected = @"
|
||||
{
|
||||
"dependencies": [
|
||||
{
|
||||
"name": "sqlite3",
|
||||
"features": [
|
||||
"zlib"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
"@
|
||||
$actual = (Get-Content -Path $manifestPath -Raw).TrimEnd()
|
||||
if ($expected -ne $actual) {
|
||||
throw "Add port didn't add sqlite3[zlib] dependency correctly.`nExpected: $expected`nActual:$actual"
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -111,16 +111,30 @@ namespace vcpkg
|
|||
return dep.name == spec.name && !dep.host &&
|
||||
structurally_equal(spec.platform.value_or(PlatformExpression::Expr()), dep.platform);
|
||||
});
|
||||
const auto features = Util::fmap(spec.features.value_or({}), [](const std::string& feature) {
|
||||
auto feature_names = spec.features.value_or({});
|
||||
bool is_core = false;
|
||||
Util::erase_if(feature_names, [&](const auto& feature_name) {
|
||||
if (feature_name == "core")
|
||||
{
|
||||
is_core = true;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
const auto features = Util::fmap(feature_names, [](const std::string& feature) {
|
||||
Checks::check_exit(VCPKG_LINE_INFO, !feature.empty() && feature != "core" && feature != "default");
|
||||
return DependencyRequestedFeature{feature};
|
||||
});
|
||||
if (dep == manifest_scf.core_paragraph->dependencies.end())
|
||||
{
|
||||
manifest_scf.core_paragraph->dependencies.push_back(
|
||||
auto& new_dep = manifest_scf.core_paragraph->dependencies.emplace_back(
|
||||
Dependency{spec.name, features, spec.platform.value_or({})});
|
||||
if (is_core)
|
||||
{
|
||||
new_dep.default_features = false;
|
||||
}
|
||||
}
|
||||
else if (spec.features)
|
||||
else
|
||||
{
|
||||
for (const auto& feature : features)
|
||||
{
|
||||
|
@ -129,6 +143,10 @@ namespace vcpkg
|
|||
dep->features.push_back(feature);
|
||||
}
|
||||
}
|
||||
if (!is_core)
|
||||
{
|
||||
dep->default_features = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче