From 1b9d5cd435b800adad6432bca91cac189ad58823 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 1 May 2017 16:24:12 +0200 Subject: Use standard version in bootstrap manifest --- bbot/agent.cxx | 34 ++++++++++++++++++---------------- bbot/bootstrap-manifest.cxx | 22 ++++++++++++---------- bbot/bootstrap-manifest.hxx | 13 +++++++------ bbot/worker.cxx | 15 ++++++++------- 4 files changed, 45 insertions(+), 39 deletions(-) (limited to 'bbot') diff --git a/bbot/agent.cxx b/bbot/agent.cxx index d30799f..bb0ccb7 100644 --- a/bbot/agent.cxx +++ b/bbot/agent.cxx @@ -91,10 +91,10 @@ bootstrap_machine (const dir_path& md, toolchain_manifest {tc_id.empty () ? "bogus" : tc_id}, bootstrap_manifest { bootstrap_manifest::versions_type { - {"bbot", BBOT_VERSION}, - {"libbbot", LIBBBOT_VERSION}, - {"libbpkg", LIBBPKG_VERSION}, - {"libbutl", LIBBUTL_VERSION} + {"bbot", standard_version (BBOT_VERSION_STR)}, + {"libbbot", standard_version (LIBBBOT_VERSION_STR)}, + {"libbpkg", standard_version (LIBBPKG_VERSION_STR)}, + {"libbutl", standard_version (LIBBUTL_VERSION_STR)} } } }; @@ -415,13 +415,14 @@ try // auto compare_bbot = [] (const bootstrap_manifest& m) -> int { - auto cmp = [&m] (const string& n, uint64_t v) -> int + auto cmp = [&m] (const string& n, const char* v) -> int { + standard_version sv (v); auto i = m.versions.find (n); - return - i == m.versions.end () || i->second < v - ? -1 - : i->second > v ? 1 : 0; + + return (i == m.versions.end () || i->second < sv + ? -1 + : i->second > sv ? 1 : 0); }; // Start from the top assuming a new dependency cannot be added @@ -429,10 +430,10 @@ try // int r; return - (r = cmp ("bbot", BBOT_VERSION)) != 0 ? r : - (r = cmp ("libbbot", LIBBBOT_VERSION)) != 0 ? r : - (r = cmp ("libbpkg", LIBBPKG_VERSION)) != 0 ? r : - (r = cmp ("libbutl", LIBBUTL_VERSION)) != 0 ? r : 0; + (r = cmp ("bbot", BBOT_VERSION_STR)) != 0 ? r : + (r = cmp ("libbbot", LIBBBOT_VERSION_STR)) != 0 ? r : + (r = cmp ("libbpkg", LIBBPKG_VERSION_STR)) != 0 ? r : + (r = cmp ("libbutl", LIBBUTL_VERSION_STR)) != 0 ? r : 0; }; optional bmm; @@ -777,9 +778,10 @@ try // if (ops.version ()) { - cout << "bbot-agent " << BBOT_VERSION_STR << endl - << "libbbot " << LIBBBOT_VERSION_STR << endl - << "libbutl " << LIBBUTL_VERSION_STR << endl + cout << "bbot-agent " << BBOT_VERSION_ID << endl + << "libbbot " << LIBBBOT_VERSION_ID << endl + << "libbpkg " << LIBBBOT_VERSION_ID << endl + << "libbutl " << LIBBUTL_VERSION_ID << endl << "Copyright (c) 2014-2017 Code Synthesis Ltd" << endl << "TBC; All rights reserved" << endl; diff --git a/bbot/bootstrap-manifest.cxx b/bbot/bootstrap-manifest.cxx index 0d6e6b5..ebbc7ce 100644 --- a/bbot/bootstrap-manifest.cxx +++ b/bbot/bootstrap-manifest.cxx @@ -75,15 +75,17 @@ namespace bbot // Package version. // - size_t vn; - uint64_t pv (stoull (v, &vn)); - if (vn != v.size ()) - bad_value ("invalid package version"); - - // Make sure the package version is not redefined. - // - if (!versions.emplace (move (pn), pv).second) - bad_name (n + " redefinition"); + try + { + // Make sure the package version is not redefined. + // + if (!versions.emplace (move (pn), standard_version (v)).second) + bad_name (n + " redefinition"); + } + catch (const invalid_argument& e) + { + bad_value (string ("invalid package version: ") + e.what ()); + } } else if (!iu) bad_name ("unknown name '" + n + "' in bootstrap manifest"); @@ -105,7 +107,7 @@ namespace bbot // Serialize *-version values. // for (const auto& v: versions) - s.next (v.first + "-version", to_string (v.second)); + s.next (v.first + "-version", v.second.string_project ()); s.next ("", ""); // End of manifest. } diff --git a/bbot/bootstrap-manifest.hxx b/bbot/bootstrap-manifest.hxx index 9d583ad..69fb358 100644 --- a/bbot/bootstrap-manifest.hxx +++ b/bbot/bootstrap-manifest.hxx @@ -8,6 +8,7 @@ #include #include +#include #include #include @@ -21,14 +22,14 @@ namespace bbot { public: - // Map of packages to their (numeric) versions that were used inside the - // bootstrapped machine. Used to make sure bbot agent/worker use the same - // versions. For example: + // Map of packages to their (standard project) versions that were used + // inside the bootstrapped machine. Used to make sure bbot agent/worker + // use the same versions. For example: // - // libbbot-version: 1010100 # 1.1.1 - // bbot-version: 1010200 # 1.1.2 + // libbbot-version: 1.2.3 + // bbot-version: 1.2.4-a.0.1234.de2f // - using versions_type = std::map; + using versions_type = std::map; versions_type versions; explicit diff --git a/bbot/worker.cxx b/bbot/worker.cxx index f777e30..70440b0 100644 --- a/bbot/worker.cxx +++ b/bbot/worker.cxx @@ -465,10 +465,10 @@ bootstrap () { bootstrap_manifest bm { bootstrap_manifest::versions_type { - {"bbot", BBOT_VERSION}, - {"libbbot", LIBBBOT_VERSION}, - {"libbpkg", LIBBPKG_VERSION}, - {"libbutl", LIBBUTL_VERSION} + {"bbot", standard_version (BBOT_VERSION_STR)}, + {"libbbot", standard_version (LIBBBOT_VERSION_STR)}, + {"libbpkg", standard_version (LIBBPKG_VERSION_STR)}, + {"libbutl", standard_version (LIBBUTL_VERSION_STR)} } }; @@ -526,9 +526,10 @@ try // if (ops.version ()) { - cout << "bbot-worker " << BBOT_VERSION_STR << endl - << "libbbot " << LIBBBOT_VERSION_STR << endl - << "libbutl " << LIBBUTL_VERSION_STR << endl + cout << "bbot-worker " << BBOT_VERSION_ID << endl + << "libbbot " << LIBBBOT_VERSION_ID << endl + << "libbpkg " << LIBBBOT_VERSION_ID << endl + << "libbutl " << LIBBUTL_VERSION_ID << endl << "Copyright (c) 2014-2017 Code Synthesis Ltd" << endl << "TBC; All rights reserved" << endl; -- cgit v1.1