From cf9d75fdd1bb02c53f21ab84f64042ee0ec56a97 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 28 Apr 2017 09:22:24 +0200 Subject: Align build.version.* variables with standard version/version module --- build2/context.cxx | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) (limited to 'build2/context.cxx') diff --git a/build2/context.cxx b/build2/context.cxx index 97a2995..56db9d4 100644 --- a/build2/context.cxx +++ b/build2/context.cxx @@ -275,23 +275,37 @@ namespace build2 // gs.assign ("build.verbosity") = verb; - // Build system version. + // Build system version (similar to what we do in the version module + // except here we don't include package epoch/revision). // { - gs.assign ("build.version") = uint64_t (BUILD2_VERSION); - gs.assign ("build.version.string") = BUILD2_VERSION_STR; + const standard_version& v (build_version); - // AABBCCDD - // - auto comp = [] (unsigned int d) -> uint64_t + auto set = [&vp, &gs] (const char* var, auto val) { - return (BUILD2_VERSION / d) % 100; + using T = decltype (val); + gs.assign (vp.insert (var)) = move (val); }; - gs.assign ("build.version.release") = comp (1); - gs.assign ("build.version.patch") = comp (100); - gs.assign ("build.version.minor") = comp (10000); - gs.assign ("build.version.major") = comp (1000000); + set ("build.version", v.string_project ()); + + set ("build.version.number", v.version); + set ("build.version.id", v.string_project_id ()); + + set ("build.version.major", uint64_t (v.major ())); + set ("build.version.minor", uint64_t (v.minor ())); + set ("build.version.patch", uint64_t (v.patch ())); + + set ("build.version.alpha", v.alpha ()); // bool + set ("build.version.beta", v.beta ()); // bool + set ("build.version.pre_release", v.alpha () || v.beta ()); + set ("build.version.pre_release_string", v.string_pre_release ()); + set ("build.version.pre_release_number", uint64_t (v.pre_release ())); + + set ("build.version.snapshot", v.snapshot ()); // bool + set ("build.version.snapshot_sn", v.snapshot_sn); // uint64 + set ("build.version.snapshot_id", v.snapshot_id); // string + set ("build.version.snapshot_string", v.string_snapshot ()); } // Enter the host information. Rather than jumping through hoops like -- cgit v1.1