aboutsummaryrefslogtreecommitdiff
path: root/build2/context.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-04-28 09:22:24 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-04-28 09:22:24 +0200
commitcf9d75fdd1bb02c53f21ab84f64042ee0ec56a97 (patch)
tree0e5471b07357f2a130b976c948b62e3f6e164156 /build2/context.cxx
parentc27b069ab3049e566738bc7a63e9b8fa57657553 (diff)
Align build.version.* variables with standard version/version module
Diffstat (limited to 'build2/context.cxx')
-rw-r--r--build2/context.cxx36
1 files changed, 25 insertions, 11 deletions
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<uint64_t> ("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<uint64_t> ("build.version") = uint64_t (BUILD2_VERSION);
- gs.assign<string> ("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<T> (var)) = move (val);
};
- gs.assign<uint64_t> ("build.version.release") = comp (1);
- gs.assign<uint64_t> ("build.version.patch") = comp (100);
- gs.assign<uint64_t> ("build.version.minor") = comp (10000);
- gs.assign<uint64_t> ("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