Skip to content

Commit

Permalink
Merge pull request #452 from microsoft/master
Browse files Browse the repository at this point in the history
[vcpkg registries] support versions (microsoft#15114)
  • Loading branch information
Jimmy-Hu authored Dec 22, 2020
2 parents c6f86ca + c898283 commit d72c659
Show file tree
Hide file tree
Showing 37 changed files with 1,231 additions and 759 deletions.
4 changes: 2 additions & 2 deletions scripts/azure-pipelines/end-to-end-tests-dir/create.ps1
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
. $PSScriptRoot/../end-to-end-tests-prelude.ps1

# Test vcpkg create
$CurrentTest = "create zlib"
Write-Host $CurrentTest
$Script:CurrentTest = "create zlib"
Write-Host $Script:CurrentTest
./vcpkg --x-builtin-ports-root=$TestingRoot/ports create zlib https://github.com/madler/zlib/archive/v1.2.11.tar.gz zlib-1.2.11.tar.gz
Throw-IfFailed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@ if (-not $IsLinux -and -not $IsMacOS) {
. $PSScriptRoot/../end-to-end-tests-prelude.ps1

# Test msbuild props and targets
$CurrentTest = "zlib:x86-windows-static msbuild scripts\testing\integrate-install\..."
Write-Host $CurrentTest
$Script:CurrentTest = "zlib:x86-windows-static msbuild scripts\testing\integrate-install\..."
Write-Host $Script:CurrentTest
./vcpkg $commonArgs install zlib:x86-windows-static --x-binarysource=clear
Throw-IfFailed
foreach ($project in @("VcpkgTriplet", "VcpkgTriplet2", "VcpkgUseStatic", "VcpkgUseStatic2")) {
$CurrentTest = "msbuild scripts\testing\integrate-install\$project.vcxproj"
$Script:CurrentTest = "msbuild scripts\testing\integrate-install\$project.vcxproj"
./vcpkg $commonArgs env "msbuild scripts\testing\integrate-install\$project.vcxproj /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
}
$CurrentTest = "zlib:x86-windows msbuild scripts\testing\integrate-install\..."
Write-Host $CurrentTest
$Script:CurrentTest = "zlib:x86-windows msbuild scripts\testing\integrate-install\..."
Write-Host $Script:CurrentTest
./vcpkg $commonArgs install zlib:x86-windows --x-binarysource=clear
Throw-IfFailed
foreach ($project in @("Project1", "NoProps")) {
$CurrentTest = "msbuild scripts\testing\integrate-install\$project.vcxproj"
Write-Host $CurrentTest
$Script:CurrentTest = "msbuild scripts\testing\integrate-install\$project.vcxproj"
Write-Host $Script:CurrentTest
./vcpkg $commonArgs env "msbuild scripts\testing\integrate-install\$project.vcxproj /p:VcpkgRoot=$TestingRoot /p:IntDir=$TestingRoot\int\ /p:OutDir=$TestingRoot\out\ "
Throw-IfFailed
Remove-Item -Recurse -Force $TestingRoot\int
Expand Down
13 changes: 13 additions & 0 deletions scripts/azure-pipelines/end-to-end-tests-dir/registries.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
. "$PSScriptRoot/../end-to-end-tests-prelude.ps1"


$commonArgs += @("--x-builtin-port-versions-dir=$PSScriptRoot/../../e2e_ports/port_versions")

Run-Vcpkg install @commonArgs 'vcpkg-internal-e2e-test-port'
Throw-IfNotFailed

Run-Vcpkg install @commonArgs --feature-flags=registries 'vcpkg-internal-e2e-test-port'
Throw-IfFailed

Run-Vcpkg install @commonArgs --feature-flags=registries 'zlib'
Throw-IfFailed
4 changes: 2 additions & 2 deletions scripts/azure-pipelines/end-to-end-tests-dir/spaces.ps1
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
. $PSScriptRoot/../end-to-end-tests-prelude.ps1

##### Test spaces in the path
$CurrentTest = "zlib with spaces in path"
Write-Host $CurrentTest
$Script:CurrentTest = "zlib with spaces in path"
Write-Host $Script:CurrentTest
./vcpkg install zlib "--triplet" $Triplet `
"--no-binarycaching" `
"--x-buildtrees-root=$TestingRoot/build Trees" `
Expand Down
21 changes: 12 additions & 9 deletions scripts/azure-pipelines/end-to-end-tests-prelude.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ $commonArgs = @(
"--x-buildtrees-root=$buildtreesRoot",
"--x-install-root=$installRoot",
"--x-packages-root=$packagesRoot",
"--overlay-ports=scripts/e2e_ports"
"--overlay-ports=scripts/e2e_ports/overlays"
)
$CurrentTest = 'unassigned'
$Script:CurrentTest = 'unassigned'

function Refresh-TestRoot {
Remove-Item -Recurse -Force $TestingRoot -ErrorAction SilentlyContinue
Expand All @@ -28,7 +28,7 @@ function Require-FileExists {
[string]$File
)
if (-Not (Test-Path $File)) {
throw "'$CurrentTest' failed to create file '$File'"
throw "'$Script:CurrentTest' failed to create file '$File'"
}
}

Expand All @@ -38,26 +38,29 @@ function Require-FileNotExists {
[string]$File
)
if (Test-Path $File) {
throw "'$CurrentTest' should not have created file '$File'"
throw "'$Script:CurrentTest' should not have created file '$File'"
}
}

function Throw-IfFailed {
if ($LASTEXITCODE -ne 0) {
throw "'$CurrentTest' had a step with a nonzero exit code"
throw "'$Script:CurrentTest' had a step with a nonzero exit code"
}
}

function Throw-IfNotFailed {
if ($LASTEXITCODE -eq 0) {
throw "'$CurrentTest' had a step with an unexpectedly zero exit code"
throw "'$Script:CurrentTest' had a step with an unexpectedly zero exit code"
}
}

function Run-Vcpkg {
param([string[]]$TestArgs)
$CurrentTest = "./vcpkg $($testArgs -join ' ')"
Write-Host $CurrentTest
Param(
[Parameter(ValueFromRemainingArguments)]
[string[]]$TestArgs
)
$Script:CurrentTest = "./vcpkg $($testArgs -join ' ')"
Write-Host $Script:CurrentTest
./vcpkg @testArgs
}

Expand Down
2 changes: 1 addition & 1 deletion scripts/azure-pipelines/end-to-end-tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ $ErrorActionPreference = "Stop"

$AllTests = Get-ChildItem $PSScriptRoot/end-to-end-tests-dir/*.ps1
if ($Filter -ne $Null) {
$AllTests = $AllTests | ? { $_ -match $Filter }
$AllTests = $AllTests | ? { $_.Name -match $Filter }
}
$n = 1
$m = $AllTests.Count
Expand Down
3 changes: 3 additions & 0 deletions scripts/e2e_ports/port_versions/baseline.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"vcpkg-internal-e2e-test-port": { "version-string": "1.0.0" }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"versions": [
{
"version-string": "1.0.0",
"git-tree": "1dc3e42a3c0cafe2884d379af4399273238b986e"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
set(VCPKG_POLICY_EMPTY_PACKAGE enabled)
4 changes: 4 additions & 0 deletions scripts/e2e_ports/vcpkg-internal-e2e-test-port/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "vcpkg-internal-e2e-test-port",
"version-string": "1.0.0"
}
6 changes: 6 additions & 0 deletions toolsrc/include/vcpkg/base/files.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,12 @@ namespace vcpkg::Files
virtual void current_path(const fs::path& path, std::error_code&) = 0;
void current_path(const fs::path& path, LineInfo li);

// if the path does not exist, then (try_|)take_exclusive_file_lock attempts to create the file
// (but not any path members above the file itself)
// in other words, if `/a/b` is a directory, and you're attempting to lock `/a/b/c`,
// then these lock functions create `/a/b/c` if it doesn't exist;
// however, if `/a/b` doesn't exist, then the functions will fail.

// waits forever for the file lock
virtual fs::SystemHandle take_exclusive_file_lock(const fs::path& path, std::error_code&) = 0;
// waits, at most, 1.5 seconds, for the file lock
Expand Down
2 changes: 1 addition & 1 deletion toolsrc/include/vcpkg/base/jsonreader.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ namespace vcpkg::Json
};
std::vector<Path> m_path;

public:
// checks that an object doesn't contain any fields which both:
// * don't start with a `$`
// * are not in `valid_fields`
// if known_fields.empty(), then it's treated as if all field names are valid
void check_for_unexpected_fields(const Object& obj, View<StringView> valid_fields, StringView type_name);

public:
template<class Type>
void required_object_field(
StringView type, const Object& obj, StringView key, Type& place, IDeserializer<Type>& visitor)
Expand Down
9 changes: 9 additions & 0 deletions toolsrc/include/vcpkg/configuration.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#pragma once

#include <vcpkg/fwd/configuration.h>
#include <vcpkg/fwd/vcpkgcmdarguments.h>

#include <vcpkg/base/files.h>
#include <vcpkg/base/json.h>

#include <vcpkg/registries.h>

Expand All @@ -12,5 +16,10 @@ namespace vcpkg
// `registries` and `default_registry`. The fall back logic is
// taken care of in RegistrySet.
RegistrySet registry_set;

void validate_feature_flags(const FeatureFlagSettings& flags);
};

std::unique_ptr<Json::IDeserializer<Configuration>> make_configuration_deserializer(
const fs::path& config_directory);
}
66 changes: 0 additions & 66 deletions toolsrc/include/vcpkg/configurationdeserializer.h

This file was deleted.

3 changes: 2 additions & 1 deletion toolsrc/include/vcpkg/fwd/registries.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

namespace vcpkg
{
struct RegistryImpl;
struct RegistryEntry;
struct RegistryImplementation;
struct Registry;
struct RegistrySet;
}
13 changes: 6 additions & 7 deletions toolsrc/include/vcpkg/portfileprovider.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <vcpkg/base/expected.h>
#include <vcpkg/base/util.h>

#include <vcpkg/registries.h>
#include <vcpkg/sourceparagraph.h>
#include <vcpkg/versions.h>

Expand Down Expand Up @@ -41,21 +42,19 @@ namespace vcpkg::PortFileProvider

struct IVersionedPortfileProvider
{
virtual const std::vector<vcpkg::Versions::VersionSpec>& get_port_versions(StringView port_name) const = 0;
virtual View<VersionT> get_port_versions(StringView port_name) const = 0;
virtual ~IVersionedPortfileProvider() = default;

virtual ExpectedS<const SourceControlFileLocation&> get_control_file(
const vcpkg::Versions::VersionSpec& version_spec) const = 0;
const Versions::VersionSpec& version_spec) const = 0;
};

struct IBaselineProvider
{
virtual ~IBaselineProvider() = default;

virtual Optional<VersionT> get_baseline_version(StringView port_name) const = 0;
virtual ~IBaselineProvider() = default;
};

std::unique_ptr<IBaselineProvider> make_baseline_provider(const vcpkg::VcpkgPaths& paths);
std::unique_ptr<IBaselineProvider> make_baseline_provider(const vcpkg::VcpkgPaths& paths, StringView baseline);
std::unique_ptr<IVersionedPortfileProvider> make_versioned_portfile_provider(const vcpkg::VcpkgPaths& paths);
std::unique_ptr<IBaselineProvider> make_baseline_provider(const VcpkgPaths&);
std::unique_ptr<IVersionedPortfileProvider> make_versioned_portfile_provider(const VcpkgPaths&);
}
Loading

0 comments on commit d72c659

Please sign in to comment.