aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Romero <romerosanchezv@gmail.com>2021-01-14 08:57:05 -0800
committerGitHub <noreply@github.com>2021-01-14 08:57:05 -0800
commitfb21b708461641927290976adb2b7eee21b5748e (patch)
tree81c07f50dfcb616139efe531a7e7cf48e2135822
parent3f3d9a615a4f86ce892613885f00ca315cfe1e7e (diff)
downloadvcpkg-fb21b708461641927290976adb2b7eee21b5748e.tar.gz
vcpkg-fb21b708461641927290976adb2b7eee21b5748e.zip
[vcpkg] Change version field in `baseline.json` (#15633)
* [vcpkg] Change version field in `baseline.json` * Change name from `version-tag` to `baseline` * [vcpkg] x-history serializes version scheme * Update e2e tests * Update baseline e2e test
-rw-r--r--scripts/e2e_ports/port_versions/baseline.json2
-rw-r--r--scripts/generateBaseline.py35
-rw-r--r--scripts/testing/version-files/default-baseline-2/vcpkg.json2
-rw-r--r--scripts/testing/version-files/port_versions/baseline.json8
-rw-r--r--scripts/testing/version-files/port_versions_incomplete/baseline.json8
-rw-r--r--toolsrc/include/vcpkg/registries.h4
-rw-r--r--toolsrc/include/vcpkg/sourceparagraph.h5
-rw-r--r--toolsrc/include/vcpkg/versiondeserializers.h1
-rw-r--r--toolsrc/src/vcpkg/commands.add-version.cpp65
-rw-r--r--toolsrc/src/vcpkg/commands.civerifyversions.cpp38
-rw-r--r--toolsrc/src/vcpkg/commands.porthistory.cpp6
-rw-r--r--toolsrc/src/vcpkg/registries.cpp10
-rw-r--r--toolsrc/src/vcpkg/versiondeserializers.cpp62
13 files changed, 149 insertions, 97 deletions
diff --git a/scripts/e2e_ports/port_versions/baseline.json b/scripts/e2e_ports/port_versions/baseline.json
index 953e8752d..98e63d8b5 100644
--- a/scripts/e2e_ports/port_versions/baseline.json
+++ b/scripts/e2e_ports/port_versions/baseline.json
@@ -1,3 +1,3 @@
{
- "vcpkg-internal-e2e-test-port": { "version-string": "1.0.0" }
+ "vcpkg-internal-e2e-test-port": { "baseline": "1.0.0" }
}
diff --git a/scripts/generateBaseline.py b/scripts/generateBaseline.py
index 55bea6ba2..d70ab369b 100644
--- a/scripts/generateBaseline.py
+++ b/scripts/generateBaseline.py
@@ -11,6 +11,24 @@ PORTS_DIRECTORY = os.path.join(SCRIPT_DIRECTORY, '../ports')
VERSIONS_DB_DIRECTORY = os.path.join(SCRIPT_DIRECTORY, '../port_versions')
+def get_version_tag(version):
+ if 'version' in version:
+ return version['version']
+ elif 'version-date' in version:
+ return version['version-date']
+ elif 'version-semver' in version:
+ return version['version-semver']
+ elif 'version-string' in version:
+ return version['version-string']
+ sys.exit(1)
+
+
+def get_version_port_version(version):
+ if 'port-version' in version:
+ return version['port-version']
+ return 0
+
+
def generate_baseline():
start_time = time.time()
@@ -35,18 +53,11 @@ def generate_baseline():
try:
versions_object = json.load(db_file)
if versions_object['versions']:
- last_version = versions_object['versions'][0]
- version_obj = {}
- if 'version' in last_version:
- version_obj['version'] = last_version['version']
- elif 'version-date' in last_version:
- version_obj['version-date'] = last_version['version-date']
- elif 'version-semver' in last_version:
- version_obj['version-semver'] - last_version['version-semver']
- else:
- version_obj['version-string'] = last_version['version-string']
- version_obj['port-version'] = last_version['port-version']
- baseline_entries[port_name] = version_obj
+ last_version = versions_object['versions'][0]
+ baseline_entries[port_name] = {
+ 'baseline': get_version_tag(last_version),
+ 'port-version': get_version_port_version(last_version)
+ }
except json.JSONDecodeError as e:
print(f'Error: Decoding {port_file_path}\n{e}\n')
baseline_object = {}
diff --git a/scripts/testing/version-files/default-baseline-2/vcpkg.json b/scripts/testing/version-files/default-baseline-2/vcpkg.json
index 1e41002ff..af353c09d 100644
--- a/scripts/testing/version-files/default-baseline-2/vcpkg.json
+++ b/scripts/testing/version-files/default-baseline-2/vcpkg.json
@@ -1,7 +1,7 @@
{
"name": "default-baseline-test",
"version-string": "0",
- "$x-default-baseline": "cbd5a68012471f820b7cf28d618199b4a4d89c58",
+ "$x-default-baseline": "16002d9c2318dec4c69e02d9af8c0e11dca0d4c6",
"dependencies": [
"zlib"
]
diff --git a/scripts/testing/version-files/port_versions/baseline.json b/scripts/testing/version-files/port_versions/baseline.json
index bfe49f984..44a4764a1 100644
--- a/scripts/testing/version-files/port_versions/baseline.json
+++ b/scripts/testing/version-files/port_versions/baseline.json
@@ -1,19 +1,19 @@
{
"default": {
"cat": {
- "version-string": "1.0",
+ "baseline": "1.0",
"port-version": 0
},
"dog": {
- "version-string": "2001-01-01",
+ "baseline": "2001-01-01",
"port-version": 0
},
"duck": {
- "version-string": "mallard",
+ "baseline": "mallard",
"port-version": 0
},
"mouse": {
- "version-string": "1.0.0",
+ "baseline": "1.0.0",
"port-version": 0
}
}
diff --git a/scripts/testing/version-files/port_versions_incomplete/baseline.json b/scripts/testing/version-files/port_versions_incomplete/baseline.json
index aadd634fc..7f27e5b65 100644
--- a/scripts/testing/version-files/port_versions_incomplete/baseline.json
+++ b/scripts/testing/version-files/port_versions_incomplete/baseline.json
@@ -1,19 +1,19 @@
{
"default": {
"cat": {
- "version-string": "1.0",
+ "baseline": "1.0",
"port-version": 0
},
"dog": {
- "version-string": "2001-01-01",
+ "baseline": "2001-01-01",
"port-version": 0
},
"duck": {
- "version-string": "mallard",
+ "baseline": "mallard",
"port-version": 0
},
"fish": {
- "version-string": "1.0.0",
+ "baseline": "1.0.0",
"port-version": 0
}
}
diff --git a/toolsrc/include/vcpkg/registries.h b/toolsrc/include/vcpkg/registries.h
index c36c0179d..74782859d 100644
--- a/toolsrc/include/vcpkg/registries.h
+++ b/toolsrc/include/vcpkg/registries.h
@@ -106,8 +106,8 @@ namespace vcpkg
std::unique_ptr<Json::IDeserializer<std::vector<Registry>>> get_registry_array_deserializer(
const fs::path& configuration_directory);
- ExpectedS<std::vector<std::pair<VersionT, std::string>>> get_builtin_versions(const VcpkgPaths& paths,
- StringView port_name);
+ ExpectedS<std::vector<std::pair<SchemedVersion, std::string>>> get_builtin_versions(const VcpkgPaths& paths,
+ StringView port_name);
ExpectedS<std::map<std::string, VersionT, std::less<>>> get_builtin_baseline(const VcpkgPaths& paths);
}
diff --git a/toolsrc/include/vcpkg/sourceparagraph.h b/toolsrc/include/vcpkg/sourceparagraph.h
index 50417b8ad..f2dd0798b 100644
--- a/toolsrc/include/vcpkg/sourceparagraph.h
+++ b/toolsrc/include/vcpkg/sourceparagraph.h
@@ -12,6 +12,7 @@
#include <vcpkg/packagespec.h>
#include <vcpkg/paragraphparser.h>
#include <vcpkg/platform-expression.h>
+#include <vcpkg/versiondeserializers.h>
#include <vcpkg/versions.h>
namespace vcpkg
@@ -107,6 +108,10 @@ namespace vcpkg
const FeatureFlagSettings& flags) const;
VersionT to_versiont() const { return core_paragraph->to_versiont(); }
+ SchemedVersion to_schemed_version() const
+ {
+ return SchemedVersion{core_paragraph->version_scheme, core_paragraph->to_versiont()};
+ }
friend bool operator==(const SourceControlFile& lhs, const SourceControlFile& rhs);
friend bool operator!=(const SourceControlFile& lhs, const SourceControlFile& rhs) { return !(lhs == rhs); }
diff --git a/toolsrc/include/vcpkg/versiondeserializers.h b/toolsrc/include/vcpkg/versiondeserializers.h
index 02696d39b..ae368f6c5 100644
--- a/toolsrc/include/vcpkg/versiondeserializers.h
+++ b/toolsrc/include/vcpkg/versiondeserializers.h
@@ -11,6 +11,7 @@
namespace vcpkg
{
Json::IDeserializer<VersionT>& get_versiont_deserializer_instance();
+ Json::IDeserializer<VersionT>& get_versiontag_deserializer_instance();
std::unique_ptr<Json::IDeserializer<std::string>> make_version_deserializer(StringLiteral type_name);
struct SchemedVersion
diff --git a/toolsrc/src/vcpkg/commands.add-version.cpp b/toolsrc/src/vcpkg/commands.add-version.cpp
index c650fa9dd..9d7a74465 100644
--- a/toolsrc/src/vcpkg/commands.add-version.cpp
+++ b/toolsrc/src/vcpkg/commands.add-version.cpp
@@ -16,21 +16,51 @@ using namespace vcpkg;
namespace
{
- using VersionGitTree = std::pair<VersionT, std::string>;
+ constexpr StringLiteral BASELINE = "baseline";
+ constexpr StringLiteral VERSION_RELAXED = "version";
+ constexpr StringLiteral VERSION_SEMVER = "version-semver";
+ constexpr StringLiteral VERSION_DATE = "version-date";
+ constexpr StringLiteral VERSION_STRING = "version-string";
- void insert_version_to_json_object(Json::Object& obj, const VersionT& version)
+ using VersionGitTree = std::pair<SchemedVersion, std::string>;
+
+ void insert_version_to_json_object(Json::Object& obj, const VersionT& version, StringLiteral version_field)
{
- obj.insert("version-string", Json::Value::string(version.text()));
+ obj.insert(version_field, Json::Value::string(version.text()));
obj.insert("port-version", Json::Value::integer(version.port_version()));
}
+ void insert_schemed_version_to_json_object(Json::Object& obj, const SchemedVersion& version)
+ {
+ if (version.scheme == Versions::Scheme::Relaxed)
+ {
+ return insert_version_to_json_object(obj, version.versiont, VERSION_RELAXED);
+ }
+
+ if (version.scheme == Versions::Scheme::Semver)
+ {
+ return insert_version_to_json_object(obj, version.versiont, VERSION_SEMVER);
+ }
+
+ if (version.scheme == Versions::Scheme::Date)
+ {
+ return insert_version_to_json_object(obj, version.versiont, VERSION_DATE);
+ }
+
+ if (version.scheme == Versions::Scheme::String)
+ {
+ return insert_version_to_json_object(obj, version.versiont, VERSION_STRING);
+ }
+ Checks::unreachable(VCPKG_LINE_INFO);
+ }
+
static Json::Object serialize_baseline(const std::map<std::string, VersionT, std::less<>>& baseline)
{
Json::Object port_entries_obj;
for (auto&& kv_pair : baseline)
{
Json::Object baseline_version_obj;
- insert_version_to_json_object(baseline_version_obj, kv_pair.second);
+ insert_version_to_json_object(baseline_version_obj, kv_pair.second, BASELINE);
port_entries_obj.insert(kv_pair.first, baseline_version_obj);
}
@@ -46,7 +76,7 @@ namespace
{
Json::Object version_obj;
version_obj.insert("git-tree", Json::Value::string(version.second));
- insert_version_to_json_object(version_obj, version.first);
+ insert_schemed_version_to_json_object(version_obj, version.first);
versions_array.push_back(std::move(version_obj));
}
@@ -169,7 +199,7 @@ namespace
static void update_version_db_file(const VcpkgPaths& paths,
const std::string& port_name,
- const VersionT& version,
+ const SchemedVersion& version,
const std::string& git_tree,
const fs::path& version_db_file_path,
bool overwrite_version,
@@ -185,7 +215,7 @@ namespace
{
System::printf(System::Color::success,
"Added version `%s` to `%s` (new file).\n",
- version.to_string(),
+ version.versiont,
fs::u8string(version_db_file_path));
}
return;
@@ -200,13 +230,13 @@ namespace
versions->begin(), versions_end, [&](auto&& entry) -> bool { return entry.second == git_tree; });
if (found_same_sha != versions_end)
{
- if (found_same_sha->first == version)
+ if (found_same_sha->first.versiont == version.versiont)
{
if (print_success)
{
System::printf(System::Color::success,
"Version `%s` is already in `%s`\n",
- version.to_string(),
+ version.versiont,
fs::u8string(version_db_file_path));
}
return;
@@ -216,15 +246,16 @@ namespace
"-- SHA: %s\n"
"-- Did you remember to commit your changes?\n"
"***No files were updated.***\n",
- found_same_sha->first.to_string(),
+ found_same_sha->first.versiont,
fs::u8string(version_db_file_path),
git_tree);
if (keep_going) return;
Checks::exit_fail(VCPKG_LINE_INFO);
}
- auto it = std::find_if(
- versions->begin(), versions_end, [&](auto&& entry) -> bool { return entry.first == version; });
+ auto it = std::find_if(versions->begin(), versions_end, [&](auto&& entry) -> bool {
+ return entry.first.versiont == version.versiont;
+ });
if (it != versions_end)
{
@@ -239,7 +270,7 @@ namespace
"-- Pass `--overwrite-version` to bypass this check.\n"
"***No files were updated.***\n",
port_name,
- version.to_string(),
+ version.versiont,
it->second,
git_tree);
if (keep_going) return;
@@ -259,7 +290,7 @@ namespace
{
System::printf(System::Color::success,
"Added version `%s` to `%s`.\n",
- version.to_string(),
+ version.versiont,
fs::u8string(version_db_file_path));
}
return;
@@ -352,7 +383,7 @@ namespace vcpkg::Commands::AddVersion
}
const auto& scf = maybe_scf.value_or_exit(VCPKG_LINE_INFO);
- const auto& versiont = scf->to_versiont();
+ const auto& schemed_version = scf->to_schemed_version();
auto git_tree_it = git_tree_map.find(port_name);
if (git_tree_it == git_tree_map.end())
@@ -370,8 +401,8 @@ namespace vcpkg::Commands::AddVersion
auto port_versions_path =
paths.builtin_port_versions / Strings::concat(port_name[0], '-') / Strings::concat(port_name, ".json");
update_version_db_file(
- paths, port_name, versiont, git_tree, port_versions_path, overwrite_version, verbose, add_all);
- update_baseline_version(paths, port_name, versiont, baseline_path, verbose);
+ paths, port_name, schemed_version, git_tree, port_versions_path, overwrite_version, verbose, add_all);
+ update_baseline_version(paths, port_name, schemed_version.versiont, baseline_path, verbose);
}
Checks::exit_success(VCPKG_LINE_INFO);
}
diff --git a/toolsrc/src/vcpkg/commands.civerifyversions.cpp b/toolsrc/src/vcpkg/commands.civerifyversions.cpp
index a0de254c5..00c95f792 100644
--- a/toolsrc/src/vcpkg/commands.civerifyversions.cpp
+++ b/toolsrc/src/vcpkg/commands.civerifyversions.cpp
@@ -85,23 +85,23 @@ namespace vcpkg::Commands::CIVerifyVersions
return {
Strings::format("Error: Unable to parse `%s` used in version `%s`.\n%s\n",
treeish,
- version_entry.first.to_string(),
+ version_entry.first.versiont,
maybe_scf.error()->error),
expected_right_tag,
};
}
const auto& scf = maybe_scf.value_or_exit(VCPKG_LINE_INFO);
- auto&& git_tree_version = scf.get()->to_versiont();
- if (version_entry.first != git_tree_version)
+ auto&& git_tree_version = scf.get()->to_schemed_version();
+ if (version_entry.first.versiont != git_tree_version.versiont)
{
return {
Strings::format("Error: Version in git-tree `%s` does not match version in file "
"`%s`.\n\tgit-tree version: %s\n\t file version: %s\n",
version_entry.second,
fs::u8string(versions_file_path),
- git_tree_version.to_string(),
- version_entry.first.to_string()),
+ git_tree_version.versiont,
+ version_entry.first.versiont),
expected_right_tag,
};
}
@@ -115,7 +115,7 @@ namespace vcpkg::Commands::CIVerifyVersions
Strings::format("Error: The git-tree `%s` for version `%s` in `%s` does not contain a "
"CONTROL file or vcpkg.json file.",
version_entry.second,
- version_entry.first,
+ version_entry.first.versiont,
fs::u8string(versions_file_path)),
expected_right_tag,
};
@@ -134,17 +134,18 @@ namespace vcpkg::Commands::CIVerifyVersions
};
}
- const auto found_version = maybe_scf.value_or_exit(VCPKG_LINE_INFO)->to_versiont();
- if (top_entry.first != found_version)
+ const auto found_version = maybe_scf.value_or_exit(VCPKG_LINE_INFO)->to_schemed_version();
+ if (top_entry.first.versiont != found_version.versiont)
{
auto versions_end = versions.end();
- auto it = std::find_if(
- versions.begin(), versions_end, [&](auto&& entry) { return entry.first == found_version; });
+ auto it = std::find_if(versions.begin(), versions_end, [&](auto&& entry) {
+ return entry.first.versiont == found_version.versiont;
+ });
if (it != versions_end)
{
return {
Strings::format("Error: Version `%s` found but is not the top entry in `%s`.",
- found_version,
+ found_version.versiont,
fs::u8string(versions_file_path)),
expected_right_tag,
};
@@ -152,8 +153,9 @@ namespace vcpkg::Commands::CIVerifyVersions
else
{
return {
- Strings::format(
- "Error: Version `%s` not found in `%s`.", found_version, fs::u8string(versions_file_path)),
+ Strings::format("Error: Version `%s` not found in `%s`.",
+ found_version.versiont,
+ fs::u8string(versions_file_path)),
expected_right_tag,
};
}
@@ -165,7 +167,7 @@ namespace vcpkg::Commands::CIVerifyVersions
Strings::format("Error: Git tree-ish object for version `%s` in `%s` does not match local port files.\n"
"\tLocal SHA: %s\n"
"\t File SHA: %s",
- found_version,
+ found_version.versiont,
fs::u8string(versions_file_path),
local_git_tree,
top_entry.second),
@@ -183,7 +185,7 @@ namespace vcpkg::Commands::CIVerifyVersions
}
auto&& baseline_version = maybe_baseline->second;
- if (baseline_version != top_entry.first)
+ if (baseline_version != top_entry.first.versiont)
{
return {
Strings::format("Error: The baseline version for port `%s` doesn't match the latest version.\n"
@@ -191,7 +193,7 @@ namespace vcpkg::Commands::CIVerifyVersions
"\t Latest version: %s (%s)",
port_name,
baseline_version,
- top_entry.first,
+ top_entry.first.versiont,
fs::u8string(versions_file_path)),
expected_right_tag,
};
@@ -203,7 +205,7 @@ namespace vcpkg::Commands::CIVerifyVersions
Strings::format("Error: Git tree-ish object for version `%s` in `%s` does not match local port files.\n"
"\tLocal SHA: %s\n"
"\t File SHA: %s",
- found_version,
+ found_version.versiont,
fs::u8string(versions_file_path),
local_git_tree,
top_entry.second),
@@ -212,7 +214,7 @@ namespace vcpkg::Commands::CIVerifyVersions
}
return {
- Strings::format("OK: %s\t%s -> %s\n", top_entry.second, port_name, top_entry.first),
+ Strings::format("OK: %s\t%s -> %s\n", top_entry.second, port_name, top_entry.first.versiont),
expected_left_tag,
};
}
diff --git a/toolsrc/src/vcpkg/commands.porthistory.cpp b/toolsrc/src/vcpkg/commands.porthistory.cpp
index e6a7cd5df..392bde7d0 100644
--- a/toolsrc/src/vcpkg/commands.porthistory.cpp
+++ b/toolsrc/src/vcpkg/commands.porthistory.cpp
@@ -25,6 +25,7 @@ namespace vcpkg::Commands::PortHistory
std::string version_string;
std::string version;
int port_version;
+ Versions::Scheme scheme;
};
const System::ExitCodeAndOutput run_git_command_inner(const VcpkgPaths& paths,
@@ -66,6 +67,7 @@ namespace vcpkg::Commands::PortHistory
{
auto version = scf->core_paragraph->version;
auto port_version = scf->core_paragraph->port_version;
+ auto scheme = scf->core_paragraph->version_scheme;
return HistoryVersion{
port_name,
git_tree,
@@ -74,6 +76,7 @@ namespace vcpkg::Commands::PortHistory
Strings::concat(version, "#", port_version),
version,
port_version,
+ scheme,
};
}
}
@@ -193,8 +196,7 @@ namespace vcpkg::Commands::PortHistory
Json::Object object;
object.insert("git-tree", Json::Value::string(version.git_tree));
- serialize_schemed_version(
- object, Versions::Scheme::String, version.version, version.port_version, true);
+ serialize_schemed_version(object, version.scheme, version.version, version.port_version, true);
versions_json.push_back(std::move(object));
}
diff --git a/toolsrc/src/vcpkg/registries.cpp b/toolsrc/src/vcpkg/registries.cpp
index 31f3078de..7f84b5075 100644
--- a/toolsrc/src/vcpkg/registries.cpp
+++ b/toolsrc/src/vcpkg/registries.cpp
@@ -484,7 +484,7 @@ namespace
{
const auto& version_value = pr.second;
VersionT version;
- r.visit_in_key(version_value, pr.first, version, get_versiont_deserializer_instance());
+ r.visit_in_key(version_value, pr.first, version, get_versiontag_deserializer_instance());
result.emplace(pr.first.to_string(), std::move(version));
}
@@ -964,15 +964,17 @@ namespace vcpkg
return true;
}
- ExpectedS<std::vector<std::pair<VersionT, std::string>>> get_builtin_versions(const VcpkgPaths& paths,
- StringView port_name)
+ ExpectedS<std::vector<std::pair<SchemedVersion, std::string>>> get_builtin_versions(const VcpkgPaths& paths,
+ StringView port_name)
{
auto maybe_versions =
load_versions_file(paths.get_filesystem(), VersionDbType::Git, paths.builtin_port_versions, port_name);
if (auto pversions = maybe_versions.get())
{
return Util::fmap(
- *pversions, [](auto&& entry) -> auto { return std::make_pair(entry.version, entry.git_tree); });
+ *pversions, [](auto&& entry) -> auto {
+ return std::make_pair(SchemedVersion{entry.scheme, entry.version}, entry.git_tree);
+ });
}
return maybe_versions.error();
diff --git a/toolsrc/src/vcpkg/versiondeserializers.cpp b/toolsrc/src/vcpkg/versiondeserializers.cpp
index 842bdade3..2892aa567 100644
--- a/toolsrc/src/vcpkg/versiondeserializers.cpp
+++ b/toolsrc/src/vcpkg/versiondeserializers.cpp
@@ -7,6 +7,7 @@ using namespace vcpkg::Versions;
namespace
{
+ constexpr StringLiteral BASELINE = "baseline";
constexpr StringLiteral VERSION_RELAXED = "version";
constexpr StringLiteral VERSION_SEMVER = "version-semver";
constexpr StringLiteral VERSION_STRING = "version-string";
@@ -36,6 +37,26 @@ namespace
}
StringLiteral m_type;
};
+
+ struct GenericVersionTDeserializer : Json::IDeserializer<VersionT>
+ {
+ GenericVersionTDeserializer(StringLiteral version_field) : m_version_field(version_field) { }
+ StringView type_name() const override { return " a version object"; }
+
+ Optional<VersionT> visit_object(Json::Reader& r, const Json::Object& obj) override
+ {
+ std::string version;
+ int port_version = 0;
+
+ static VersionDeserializer version_deserializer{"version"};
+
+ r.required_object_field(type_name(), obj, m_version_field, version, version_deserializer);
+ r.optional_object_field(obj, PORT_VERSION, port_version, Json::NaturalNumberDeserializer::instance);
+
+ return VersionT{std::move(version), port_version};
+ }
+ StringLiteral m_version_field;
+ };
}
namespace vcpkg
@@ -167,38 +188,15 @@ namespace vcpkg
}
}
-}
-
-namespace
-{
- struct VersionTDeserializer final : Json::IDeserializer<VersionT>
+ Json::IDeserializer<VersionT>& get_versiont_deserializer_instance()
{
- StringView type_name() const override { return "a version object"; }
- View<StringView> valid_fields() const override
- {
- static const StringView t[] = {VERSION_STRING, PORT_VERSION};
- return t;
- }
-
- Optional<VersionT> visit_object(Json::Reader& r, const Json::Object& obj) override
- {
- std::string version;
- int port_version = 0;
-
- static VersionDeserializer version_deserializer{"version"};
-
- r.required_object_field(type_name(), obj, VERSION_STRING, version, version_deserializer);
- r.optional_object_field(obj, PORT_VERSION, port_version, Json::NaturalNumberDeserializer::instance);
-
- return VersionT{std::move(version), port_version};
- }
- static VersionTDeserializer instance;
- };
-
- VersionTDeserializer VersionTDeserializer::instance;
-}
+ static GenericVersionTDeserializer deserializer(VERSION_STRING);
+ return deserializer;
+ }
-namespace vcpkg
-{
- Json::IDeserializer<VersionT>& get_versiont_deserializer_instance() { return VersionTDeserializer::instance; }
+ Json::IDeserializer<VersionT>& get_versiontag_deserializer_instance()
+ {
+ static GenericVersionTDeserializer deserializer(BASELINE);
+ return deserializer;
+ }
}