mirror of
https://github.com/microsoft/vcpkg.git
synced 2025-01-15 05:08:02 +08:00
[vcpkg] Add parse checking for version fields and enable non-string versions outside 'versions' flag (#15580)
This commit is contained in:
parent
a904f297e5
commit
c239e82510
@ -136,6 +136,25 @@ TEST_CASE ("manifest versioning", "[manifests]")
|
|||||||
"version-semver": "abcd#1"
|
"version-semver": "abcd#1"
|
||||||
})json",
|
})json",
|
||||||
true);
|
true);
|
||||||
|
|
||||||
|
SECTION ("version syntax")
|
||||||
|
{
|
||||||
|
test_parse_manifest(R"json({
|
||||||
|
"name": "zlib",
|
||||||
|
"version-semver": "2020-01-01"
|
||||||
|
})json",
|
||||||
|
true);
|
||||||
|
test_parse_manifest(R"json({
|
||||||
|
"name": "zlib",
|
||||||
|
"version-date": "1.1.1"
|
||||||
|
})json",
|
||||||
|
true);
|
||||||
|
test_parse_manifest(R"json({
|
||||||
|
"name": "zlib",
|
||||||
|
"version": "1.2.3-rc3"
|
||||||
|
})json",
|
||||||
|
true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE ("manifest constraints error hash", "[manifests]")
|
TEST_CASE ("manifest constraints error hash", "[manifests]")
|
||||||
|
@ -1009,14 +1009,6 @@ namespace vcpkg
|
|||||||
{
|
{
|
||||||
if (!flags.versions)
|
if (!flags.versions)
|
||||||
{
|
{
|
||||||
if (core_paragraph->version_scheme != Versions::Scheme::String)
|
|
||||||
{
|
|
||||||
return Strings::concat(fs::u8string(origin),
|
|
||||||
" was rejected because it uses a non-string version scheme and the `",
|
|
||||||
VcpkgCmdArguments::VERSIONS_FEATURE,
|
|
||||||
"` feature flag is disabled.\nThis can be fixed by using \"version-string\".");
|
|
||||||
}
|
|
||||||
|
|
||||||
auto check_deps = [&](View<Dependency> deps) -> Optional<std::string> {
|
auto check_deps = [&](View<Dependency> deps) -> Optional<std::string> {
|
||||||
for (auto&& dep : deps)
|
for (auto&& dep : deps)
|
||||||
{
|
{
|
||||||
|
@ -97,15 +97,40 @@ namespace vcpkg
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (has_exact)
|
if (has_exact)
|
||||||
|
{
|
||||||
version_scheme = Versions::Scheme::String;
|
version_scheme = Versions::Scheme::String;
|
||||||
|
}
|
||||||
else if (has_relax)
|
else if (has_relax)
|
||||||
|
{
|
||||||
version_scheme = Versions::Scheme::Relaxed;
|
version_scheme = Versions::Scheme::Relaxed;
|
||||||
|
auto v = Versions::RelaxedVersion::from_string(version);
|
||||||
|
if (!v.has_value())
|
||||||
|
{
|
||||||
|
r.add_generic_error(parent_type, "'version' text was not a relaxed version:\n", v.error());
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (has_semver)
|
else if (has_semver)
|
||||||
|
{
|
||||||
version_scheme = Versions::Scheme::Semver;
|
version_scheme = Versions::Scheme::Semver;
|
||||||
|
auto v = Versions::SemanticVersion::from_string(version);
|
||||||
|
if (!v.has_value())
|
||||||
|
{
|
||||||
|
r.add_generic_error(parent_type, "'version-semver' text was not a semantic version:\n", v.error());
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (has_date)
|
else if (has_date)
|
||||||
|
{
|
||||||
version_scheme = Versions::Scheme::Date;
|
version_scheme = Versions::Scheme::Date;
|
||||||
|
auto v = Versions::DateVersion::from_string(version);
|
||||||
|
if (!v.has_value())
|
||||||
|
{
|
||||||
|
r.add_generic_error(parent_type, "'version-date' text was not a date version:\n", v.error());
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
Checks::unreachable(VCPKG_LINE_INFO);
|
Checks::unreachable(VCPKG_LINE_INFO);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return SchemedVersion(version_scheme, VersionT{version, port_version});
|
return SchemedVersion(version_scheme, VersionT{version, port_version});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user