[vcpkg] Fix native platform expression (#147)
* fix 'native' platform identifier * add tests * fix bugs in end-to-end tests * fix tests * more test fixes * merge with upstream * format * fix bug
This commit is contained in:
Родитель
3e6bbe684d
Коммит
660db288ec
|
@ -0,0 +1 @@
|
|||
set(VCPKG_POLICY_EMPTY_PACKAGE enabled)
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"name": "vcpkg-native-dependency",
|
||||
"version": "0",
|
||||
"dependencies": [
|
||||
{
|
||||
"name": "vcpkg-empty-port",
|
||||
"platform": "native"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -60,9 +60,9 @@ if(-Not $IsLinux) {
|
|||
Require-FileExists "$TestingRoot/packages.config"
|
||||
$fetchNuGetArgs = $commonArgs + @('fetch', 'nuget')
|
||||
if ($IsLinux -or $IsMacOS) {
|
||||
mono $(./vcpkg @fetchNuGetArgs) restore $TestingRoot/packages.config -OutputDirectory "$NuGetRoot2" -Source "$NuGetRoot"
|
||||
mono $(Run-Vcpkg @fetchNuGetArgs) restore $TestingRoot/packages.config -OutputDirectory "$NuGetRoot2" -Source "$NuGetRoot"
|
||||
} else {
|
||||
& $(./vcpkg @fetchNuGetArgs) restore $TestingRoot/packages.config -OutputDirectory "$NuGetRoot2" -Source "$NuGetRoot"
|
||||
& $(Run-Vcpkg @fetchNuGetArgs) restore $TestingRoot/packages.config -OutputDirectory "$NuGetRoot2" -Source "$NuGetRoot"
|
||||
}
|
||||
Throw-IfFailed
|
||||
Remove-Item -Recurse -Force $NuGetRoot -ErrorAction SilentlyContinue
|
||||
|
|
|
@ -4,14 +4,14 @@
|
|||
$metricsTagName = 'vcpkg.disable-metrics'
|
||||
$metricsAreDisabledMessage = 'Warning: passed --sendmetrics, but metrics are disabled.'
|
||||
|
||||
function Test-Metrics-Enabled() {
|
||||
function Test-MetricsEnabled() {
|
||||
Param(
|
||||
[Parameter(ValueFromRemainingArguments)]
|
||||
[string[]]$TestArgs
|
||||
)
|
||||
|
||||
$actualArgs = @('version', '--sendmetrics')
|
||||
if ($TestArgs.Length -ne 0) {
|
||||
if ($null -ne $TestArgs -and $TestArgs.Length -ne 0) {
|
||||
$actualArgs += $TestArgs
|
||||
}
|
||||
|
||||
|
@ -27,17 +27,17 @@ function Test-Metrics-Enabled() {
|
|||
|
||||
# By default, metrics are enabled.
|
||||
Require-FileNotExists $metricsTagName
|
||||
if (-Not (Test-Metrics-Enabled)) {
|
||||
if (-Not (Test-MetricsEnabled)) {
|
||||
throw "Metrics were not on by default."
|
||||
}
|
||||
|
||||
if (Test-Metrics-Enabled '--disable-metrics') {
|
||||
if (Test-MetricsEnabled '--disable-metrics') {
|
||||
throw "Metrics were not disabled by switch."
|
||||
}
|
||||
|
||||
$env:VCPKG_DISABLE_METRICS = 'ON'
|
||||
try {
|
||||
if (Test-Metrics-Enabled) {
|
||||
if (Test-MetricsEnabled) {
|
||||
throw "Environment variable did not disable metrics."
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ try {
|
|||
throw "Disabled metrics emit message even without --sendmetrics"
|
||||
}
|
||||
|
||||
if (-Not (Test-Metrics-Enabled '--no-disable-metrics')) {
|
||||
if (-Not (Test-MetricsEnabled '--no-disable-metrics')) {
|
||||
throw "Environment variable to disable metrics could not be overridden by switch."
|
||||
}
|
||||
} finally {
|
||||
|
@ -58,7 +58,7 @@ try {
|
|||
# the command line.
|
||||
Set-Content -Path $metricsTagName -Value ""
|
||||
try {
|
||||
if (Test-Metrics-Enabled '--disable-metrics') {
|
||||
if (Test-MetricsEnabled '--disable-metrics') {
|
||||
throw "Metrics were not force-disabled by the disable-metrics tag file."
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,13 +4,13 @@ if (-not $IsLinux -and -not $IsMacOS) {
|
|||
$env:_VCPKG_TEST_TRACKED = "a"
|
||||
$env:_VCPKG_TEST_UNTRACKED = "b"
|
||||
|
||||
$x = ./vcpkg "--overlay-triplets=$PSScriptRoot/../e2e_ports/env-passthrough" env "echo %_VCPKG_TEST_TRACKED% %_VCPKG_TEST_TRACKED2% %_VCPKG_TEST_UNTRACKED% %_VCPKG_TEST_UNTRACKED2%"
|
||||
$x = Run-Vcpkg "--overlay-triplets=$PSScriptRoot/../e2e_ports/env-passthrough" env "echo %_VCPKG_TEST_TRACKED% %_VCPKG_TEST_TRACKED2% %_VCPKG_TEST_UNTRACKED% %_VCPKG_TEST_UNTRACKED2%"
|
||||
if ($x -ne "%_VCPKG_TEST_TRACKED% %_VCPKG_TEST_TRACKED2% %_VCPKG_TEST_UNTRACKED% %_VCPKG_TEST_UNTRACKED2%")
|
||||
{
|
||||
throw "env should have cleaned the environment ($x)"
|
||||
}
|
||||
|
||||
$y = ./vcpkg "--overlay-triplets=$PSScriptRoot/../e2e_ports/env-passthrough" env --triplet passthrough "echo %_VCPKG_TEST_TRACKED% %_VCPKG_TEST_TRACKED2% %_VCPKG_TEST_UNTRACKED% %_VCPKG_TEST_UNTRACKED2%"
|
||||
$y = Run-Vcpkg "--overlay-triplets=$PSScriptRoot/../e2e_ports/env-passthrough" env --triplet passthrough "echo %_VCPKG_TEST_TRACKED% %_VCPKG_TEST_TRACKED2% %_VCPKG_TEST_UNTRACKED% %_VCPKG_TEST_UNTRACKED2%"
|
||||
if ($y -ne "a %_VCPKG_TEST_TRACKED2% b %_VCPKG_TEST_UNTRACKED2%")
|
||||
{
|
||||
throw "env should have kept the environment ($y)"
|
||||
|
|
|
@ -8,12 +8,12 @@ if (-not $IsLinux -and -not $IsMacOS) {
|
|||
# Test msbuild props and targets
|
||||
$Script:CurrentTest = "zlib:x86-windows msbuild $iiroot\..."
|
||||
Write-Host $Script:CurrentTest
|
||||
./vcpkg $commonArgs install zlib:x86-windows
|
||||
Run-Vcpkg @CommonArgs install zlib:x86-windows
|
||||
Throw-IfFailed
|
||||
foreach ($project in @("Project1", "NoProps")) {
|
||||
$Script:CurrentTest = "msbuild $iiroot\$project.vcxproj"
|
||||
Write-Host $Script:CurrentTest
|
||||
./vcpkg $commonArgs env "msbuild $iiroot\$project.vcxproj /p:VCPKG_ROOT=$VcpkgRoot /p:VcpkgRoot=$TestingRoot /p:IntDir=$TestingRoot\int\ /p:OutDir=$TestingRoot\out\ "
|
||||
Run-Vcpkg @commonArgs env "msbuild $iiroot\$project.vcxproj /p:VCPKG_ROOT=$VcpkgRoot /p:VcpkgRoot=$TestingRoot /p:IntDir=$TestingRoot\int\ /p:OutDir=$TestingRoot\out\ "
|
||||
Throw-IfFailed
|
||||
Remove-Item -Recurse -Force $TestingRoot\int
|
||||
Remove-Item -Recurse -Force $TestingRoot\out
|
||||
|
@ -21,11 +21,11 @@ if (-not $IsLinux -and -not $IsMacOS) {
|
|||
|
||||
$Script:CurrentTest = "zlib:x86-windows-static msbuild $iiroot\..."
|
||||
Write-Host $Script:CurrentTest
|
||||
./vcpkg $commonArgs install zlib:x86-windows-static
|
||||
Run-Vcpkg @CommonArgs install zlib:x86-windows-static
|
||||
Throw-IfFailed
|
||||
foreach ($project in @("VcpkgTriplet", "VcpkgTriplet2", "VcpkgUseStatic", "VcpkgUseStatic2")) {
|
||||
$Script:CurrentTest = "msbuild $iiroot\$project.vcxproj"
|
||||
./vcpkg $commonArgs env "msbuild $iiroot\$project.vcxproj /p:VCPKG_ROOT=$VcpkgRoot /p:VcpkgRoot=$TestingRoot /p:IntDir=$TestingRoot\int\ /p:OutDir=$TestingRoot\out\ "
|
||||
Run-Vcpkg @commonArgs env "msbuild $iiroot\$project.vcxproj /p:VCPKG_ROOT=$VcpkgRoot /p:VcpkgRoot=$TestingRoot /p:IntDir=$TestingRoot\int\ /p:OutDir=$TestingRoot\out\ "
|
||||
Throw-IfFailed
|
||||
Remove-Item -Recurse -Force $TestingRoot\int
|
||||
Remove-Item -Recurse -Force $TestingRoot\out
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
. "$PSScriptRoot/../end-to-end-tests-prelude.ps1"
|
||||
|
||||
if ($IsLinux) {
|
||||
$host_triplet = 'x64-linux-e2e'
|
||||
} elseif ($IsMacOS) {
|
||||
$host_triplet = 'x64-osx-e2e'
|
||||
} elseif ($IsWindows) {
|
||||
$host_triplet = 'x64-windows-e2e'
|
||||
} else {
|
||||
Write-Warning "Unknown platform."
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Write-Trace "test native qualified dependencies"
|
||||
|
||||
Run-Vcpkg install @CommonArgs --host-triplet $Triplet vcpkg-native-dependency:$Triplet
|
||||
Throw-IfFailed
|
||||
Require-FileExists "$installRoot/$Triplet/share/vcpkg-empty-port"
|
||||
Refresh-TestRoot
|
||||
|
||||
Run-Vcpkg install @CommonArgs --host-triplet $host_triplet vcpkg-native-dependency:$Triplet
|
||||
Throw-IfFailed
|
||||
Require-FileNotExists "$installRoot/$Triplet/share/vcpkg-empty-port"
|
||||
Refresh-TestRoot
|
|
@ -20,9 +20,9 @@ $env:X_VCPKG_REGISTRIES_CACHE = Join-Path $TestingRoot 'registries'
|
|||
|
||||
function Refresh-TestRoot {
|
||||
Remove-Item -Recurse -Force $TestingRoot -ErrorAction SilentlyContinue
|
||||
mkdir $TestingRoot | Out-Null
|
||||
mkdir $env:X_VCPKG_REGISTRIES_CACHE | Out-Null
|
||||
mkdir $NuGetRoot | Out-Null
|
||||
New-Item -ItemType Directory -Force $TestingRoot | Out-Null
|
||||
New-Item -ItemType Directory -Force $env:X_VCPKG_REGISTRIES_CACHE | Out-Null
|
||||
New-Item -ItemType Directory -Force $NuGetRoot | Out-Null
|
||||
}
|
||||
|
||||
function Write-Stack {
|
||||
|
|
|
@ -55,7 +55,7 @@ if ([string]::IsNullOrEmpty($VcpkgExe))
|
|||
}
|
||||
}
|
||||
|
||||
$AllTests = Get-ChildItem $PSScriptRoot/end-to-end-tests-dir/*.ps1
|
||||
[Array]$AllTests = Get-ChildItem $PSScriptRoot/end-to-end-tests-dir/*.ps1
|
||||
if ($Filter -ne $Null) {
|
||||
$AllTests = $AllTests | ? { $_.Name -match $Filter }
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
namespace vcpkg::Test
|
||||
{
|
||||
struct MockCMakeVarProvider : CMakeVars::CMakeVarProvider
|
||||
struct MockCMakeVarProvider final : CMakeVars::CMakeVarProvider
|
||||
{
|
||||
using SMap = std::unordered_map<std::string, std::string>;
|
||||
void load_generic_triplet_vars(Triplet triplet) const override
|
||||
|
@ -12,7 +12,7 @@ namespace vcpkg::Test
|
|||
generic_triplet_vars.emplace(triplet, SMap{});
|
||||
}
|
||||
|
||||
void load_dep_info_vars(Span<const PackageSpec> specs) const override
|
||||
void load_dep_info_vars(Span<const PackageSpec> specs, Triplet) const override
|
||||
{
|
||||
for (auto&& spec : specs)
|
||||
dep_info_vars.emplace(spec, SMap{});
|
||||
|
|
|
@ -20,14 +20,15 @@ namespace vcpkg::CMakeVars
|
|||
virtual Optional<const std::unordered_map<std::string, std::string>&> get_dep_info_vars(
|
||||
const PackageSpec& spec) const = 0;
|
||||
|
||||
const std::unordered_map<std::string, std::string>& get_or_load_dep_info_vars(const PackageSpec& spec) const;
|
||||
const std::unordered_map<std::string, std::string>& get_or_load_dep_info_vars(const PackageSpec& spec,
|
||||
Triplet host_triplet) const;
|
||||
|
||||
virtual Optional<const std::unordered_map<std::string, std::string>&> get_tag_vars(
|
||||
const PackageSpec& spec) const = 0;
|
||||
|
||||
virtual void load_generic_triplet_vars(Triplet triplet) const = 0;
|
||||
|
||||
virtual void load_dep_info_vars(Span<const PackageSpec> specs) const = 0;
|
||||
virtual void load_dep_info_vars(Span<const PackageSpec> specs, Triplet host_triplet) const = 0;
|
||||
|
||||
virtual void load_tag_vars(Span<const FullPackageSpec> specs,
|
||||
const PortFileProvider::PortFileProvider& port_provider,
|
||||
|
|
|
@ -98,7 +98,7 @@ namespace vcpkg::Build
|
|||
{
|
||||
auto var_provider_storage = CMakeVars::make_triplet_cmake_var_provider(paths);
|
||||
auto& var_provider = *var_provider_storage;
|
||||
var_provider.load_dep_info_vars({{full_spec.package_spec}});
|
||||
var_provider.load_dep_info_vars({{full_spec.package_spec}}, host_triplet);
|
||||
|
||||
StatusParagraphs status_db = database_load_check(paths);
|
||||
|
||||
|
|
|
@ -28,12 +28,12 @@ namespace vcpkg::CMakeVars
|
|||
}
|
||||
|
||||
const std::unordered_map<std::string, std::string>& CMakeVarProvider::get_or_load_dep_info_vars(
|
||||
const PackageSpec& spec) const
|
||||
const PackageSpec& spec, Triplet host_triplet) const
|
||||
{
|
||||
auto maybe_vars = get_dep_info_vars(spec);
|
||||
if (!maybe_vars.has_value())
|
||||
{
|
||||
load_dep_info_vars({&spec, 1});
|
||||
load_dep_info_vars({&spec, 1}, host_triplet);
|
||||
maybe_vars = get_dep_info_vars(spec);
|
||||
}
|
||||
return maybe_vars.value_or_exit(VCPKG_LINE_INFO);
|
||||
|
@ -49,7 +49,7 @@ namespace vcpkg::CMakeVars
|
|||
|
||||
void load_generic_triplet_vars(Triplet triplet) const override;
|
||||
|
||||
void load_dep_info_vars(View<PackageSpec> specs) const override;
|
||||
void load_dep_info_vars(View<PackageSpec> specs, Triplet host_triplet) const override;
|
||||
|
||||
void load_tag_vars(View<FullPackageSpec> specs,
|
||||
const PortFileProvider::PortFileProvider& port_provider,
|
||||
|
@ -309,7 +309,7 @@ endfunction()
|
|||
std::make_move_iterator(vars.front().end()));
|
||||
}
|
||||
|
||||
void TripletCMakeVarProvider::load_dep_info_vars(View<PackageSpec> specs) const
|
||||
void TripletCMakeVarProvider::load_dep_info_vars(View<PackageSpec> specs, Triplet host_triplet) const
|
||||
{
|
||||
if (specs.size() == 0) return;
|
||||
std::vector<std::vector<std::pair<std::string, std::string>>> vars(specs.size());
|
||||
|
@ -324,11 +324,13 @@ endfunction()
|
|||
auto var_list_itr = vars.begin();
|
||||
for (const PackageSpec& spec : specs)
|
||||
{
|
||||
dep_resolution_vars.emplace(std::piecewise_construct,
|
||||
std::forward_as_tuple(spec),
|
||||
std::forward_as_tuple(std::make_move_iterator(var_list_itr->begin()),
|
||||
std::make_move_iterator(var_list_itr->end())));
|
||||
PlatformExpression::Context ctxt{std::make_move_iterator(var_list_itr->begin()),
|
||||
std::make_move_iterator(var_list_itr->end())};
|
||||
++var_list_itr;
|
||||
|
||||
ctxt.emplace("Z_VCPKG_IS_NATIVE", host_triplet == spec.triplet() ? "1" : "0");
|
||||
|
||||
dep_resolution_vars.emplace(spec, std::move(ctxt));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -333,7 +333,7 @@ namespace vcpkg::Commands::CI
|
|||
}
|
||||
}
|
||||
|
||||
var_provider.load_dep_info_vars(packages_with_qualified_deps);
|
||||
var_provider.load_dep_info_vars(packages_with_qualified_deps, serialize_options.host_triplet);
|
||||
auto action_plan =
|
||||
Dependencies::create_feature_install_plan(provider, var_provider, specs, {}, serialize_options);
|
||||
|
||||
|
|
|
@ -691,7 +691,7 @@ namespace vcpkg::Dependencies
|
|||
auto ctx = [&]() -> const PlatformExpression::Context& {
|
||||
if (!ctx_storage)
|
||||
{
|
||||
var_provider.load_dep_info_vars({&spec, 1});
|
||||
var_provider.load_dep_info_vars({&spec, 1}, host_triplet);
|
||||
ctx_storage = var_provider.get_dep_info_vars(spec);
|
||||
}
|
||||
return ctx_storage.value_or_exit(VCPKG_LINE_INFO);
|
||||
|
@ -943,7 +943,7 @@ namespace vcpkg::Dependencies
|
|||
auto qualified_package_specs =
|
||||
Util::fmap(qualified_dependencies, [](const FeatureSpec& fspec) { return fspec.spec(); });
|
||||
Util::sort_unique_erase(qualified_package_specs);
|
||||
m_var_provider.load_dep_info_vars(qualified_package_specs);
|
||||
m_var_provider.load_dep_info_vars(qualified_package_specs, m_graph->m_host_triplet);
|
||||
|
||||
// Put all the FeatureSpecs for which we had qualified dependencies back on the dependencies stack.
|
||||
// We need to recheck if evaluating the triplet revealed any new dependencies.
|
||||
|
@ -1533,7 +1533,7 @@ namespace vcpkg::Dependencies
|
|||
auto maybe_vars = m_var_provider.get_dep_info_vars(ref.first);
|
||||
if (!maybe_vars)
|
||||
{
|
||||
m_var_provider.load_dep_info_vars({&ref.first, 1});
|
||||
m_var_provider.load_dep_info_vars({&ref.first, 1}, m_host_triplet);
|
||||
maybe_vars = m_var_provider.get_dep_info_vars(ref.first);
|
||||
}
|
||||
|
||||
|
@ -1763,7 +1763,7 @@ namespace vcpkg::Dependencies
|
|||
|
||||
specs.push_back(toplevel);
|
||||
Util::sort_unique_erase(specs);
|
||||
m_var_provider.load_dep_info_vars(specs);
|
||||
m_var_provider.load_dep_info_vars(specs, m_host_triplet);
|
||||
const auto& vars = m_var_provider.get_dep_info_vars(toplevel).value_or_exit(VCPKG_LINE_INFO);
|
||||
std::vector<const Dependency*> active_deps;
|
||||
|
||||
|
@ -1951,7 +1951,7 @@ namespace vcpkg::Dependencies
|
|||
const auto& supports_expr = p_vnode->scfl->source_control_file->core_paragraph->supports_expression;
|
||||
if (!supports_expr.is_empty())
|
||||
{
|
||||
if (!supports_expr.evaluate(m_var_provider.get_or_load_dep_info_vars(spec)))
|
||||
if (!supports_expr.evaluate(m_var_provider.get_or_load_dep_info_vars(spec, m_host_triplet)))
|
||||
{
|
||||
const auto msg = Strings::concat(
|
||||
spec, "@", new_ver, " is only supported on '", to_string(supports_expr), "'\n");
|
||||
|
@ -1976,7 +1976,7 @@ namespace vcpkg::Dependencies
|
|||
const auto& supports_expr = feature.get()->supports_expression;
|
||||
if (!supports_expr.is_empty())
|
||||
{
|
||||
if (!supports_expr.evaluate(m_var_provider.get_or_load_dep_info_vars(spec)))
|
||||
if (!supports_expr.evaluate(m_var_provider.get_or_load_dep_info_vars(spec, m_host_triplet)))
|
||||
{
|
||||
const auto msg = Strings::concat(spec,
|
||||
"@",
|
||||
|
|
Загрузка…
Ссылка в новой задаче