Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't require a name or version in "project" manifests. #605

Merged
merged 8 commits into from
Jun 30, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions azure-pipelines/e2e_assets/format-manifest/empty.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "name-and-version",
"version": "1.0"
}
3 changes: 3 additions & 0 deletions azure-pipelines/e2e_assets/format-manifest/expected/name.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"name": "hello"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"version": "1.2"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"name":"name-and-version", "version": "1.0"}
1 change: 1 addition & 0 deletions azure-pipelines/e2e_assets/format-manifest/name.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"name":"hello"}
1 change: 1 addition & 0 deletions azure-pipelines/e2e_assets/format-manifest/version.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"version":"1.2"}
26 changes: 26 additions & 0 deletions azure-pipelines/end-to-end-tests-dir/add.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
. "$PSScriptRoot/../end-to-end-tests-prelude.ps1"

$manifestDir = "$TestingRoot/add_port"
$manifestDirArgs = $commonArgs + @("--x-manifest-root=$manifestDir")
$manifestPath = "$manifestDir/vcpkg.json"
$vcpkgJson = @{}

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
Throw-IfFailed

$expected = @"
{
"dependencies": [
"zlib"
]
}
"@

$actual = (Get-Content -Path $manifestPath -Raw).TrimEnd()
if ($expected -ne $actual) {
throw "Add port didn't add zlib dependency correctly.`nExpected: $expected`nActual:$actual"
}
36 changes: 36 additions & 0 deletions azure-pipelines/end-to-end-tests-dir/format-manifest.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
. "$PSScriptRoot/../end-to-end-tests-prelude.ps1"

$formatManifestAssets = (Get-Item "$PSScriptRoot/../e2e_assets/format-manifest").FullName
$testProjects = Get-ChildItem "$formatManifestAssets/*.json" -File
$testProjects | % {
$asItem = Get-Item $_
$full = $asItem.FullName
$name = $asItem.Name
$expectedPath = "$formatManifestAssets/expected/$name"
$tempItemPath = "$TestingRoot/$name"
Write-Trace "test that format-manifest on $full produces $expectedPath"
[string]$expected = Get-Content $expectedPath -Raw
Copy-Item $asItem $tempItemPath
Run-Vcpkg format-manifest $tempItemPath
$actual = Get-Content $tempItemPath -Raw
if ($expected -ne $actual) {
throw "Expected formatting $full to produce $expectedPath but was $tempItemPath"
}
}

Write-Trace "test re-serializing every manifest"
$manifestDir = "$TestingRoot/manifest-dir"
New-Item -Path $manifestDir -ItemType Directory | Out-Null

$ports = Get-ChildItem "$env:VCPKG_ROOT/ports"

$ports | % {
Copy-Item "$_/vcpkg.json" "$manifestDir" | Out-Null
$x = Get-Content "$manifestDir/vcpkg.json" -Raw
Run-Vcpkg -EndToEndTestSilent format-manifest "$manifestDir/vcpkg.json" | Out-Null
Throw-IfFailed "$_/vcpkg.json"
$y = Get-Content "$manifestDir/vcpkg.json" -Raw
if ($x -ne $y) {
throw "Expected formatting manifest $_/vcpkg.json to cause no modifications"
}
}
20 changes: 0 additions & 20 deletions azure-pipelines/end-to-end-tests-dir/manifest-reserialize.ps1

This file was deleted.

3 changes: 0 additions & 3 deletions azure-pipelines/end-to-end-tests-dir/manifests.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
. "$PSScriptRoot/../end-to-end-tests-prelude.ps1"


Write-Trace "test manifest features"
$manifestDir = "$TestingRoot/manifest-dir"

Expand All @@ -15,8 +14,6 @@ function feature {
}

$vcpkgJson = @{
'name' = "manifest-test";
'version' = "1.0.0";
'default-features' = @( 'default-fail' );
'features' = @{
'default-fail' = feature 'vcpkg-fail-if-depended-upon';
Expand Down
9 changes: 6 additions & 3 deletions include/vcpkg/sourceparagraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,13 @@ namespace vcpkg
struct SourceControlFile
{
SourceControlFile clone() const;
static ParseExpected<SourceControlFile> parse_project_manifest_object(StringView origin,
const Json::Object& object,
MessageSink& warnings_sink);

static ParseExpected<SourceControlFile> parse_manifest_object(StringView origin,
const Json::Object& object,
MessageSink& warnings_sink);
static ParseExpected<SourceControlFile> parse_port_manifest_object(StringView origin,
const Json::Object& object,
MessageSink& warnings_sink);

static ParseExpected<SourceControlFile> parse_control_file(StringView origin,
std::vector<Paragraph>&& control_paragraphs);
Expand Down
5 changes: 5 additions & 0 deletions include/vcpkg/versiondeserializers.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ namespace vcpkg
Version version;
};

Optional<SchemedVersion> visit_optional_schemed_deserializer(StringView parent_type,
Json::Reader& r,
const Json::Object& obj,
bool allow_hash_portversion);

SchemedVersion visit_required_schemed_deserializer(StringView parent_type,
Json::Reader& r,
const Json::Object& obj,
Expand Down
1 change: 1 addition & 0 deletions include/vcpkg/versions.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ namespace vcpkg

enum class VersionScheme
{
Missing,
Relaxed,
Semver,
Date,
Expand Down