aboutsummaryrefslogtreecommitdiff
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
parentc27b069ab3049e566738bc7a63e9b8fa57657553 (diff)
Align build.version.* variables with standard version/version module
-rw-r--r--build2/context.cxx36
-rw-r--r--build2/utility2
-rw-r--r--build2/utility.cxx2
-rw-r--r--build2/version/init.cxx19
4 files changed, 32 insertions, 27 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
diff --git a/build2/utility b/build2/utility
index 860c841..ca29026 100644
--- a/build2/utility
+++ b/build2/utility
@@ -105,7 +105,7 @@ namespace build2
// Build system driver version and check.
//
- extern standard_version build_version;
+ extern const standard_version build_version;
class location;
diff --git a/build2/utility.cxx b/build2/utility.cxx
index 7fd2a42..11c5024 100644
--- a/build2/utility.cxx
+++ b/build2/utility.cxx
@@ -110,7 +110,7 @@ namespace build2
options ops;
process_path argv0;
- standard_version build_version (BUILD2_VERSION_STR);
+ const standard_version build_version (BUILD2_VERSION_STR);
void
check_build_version (const standard_version_constraint& c, const location& l)
diff --git a/build2/version/init.cxx b/build2/version/init.cxx
index 76c30da..3f8a42a 100644
--- a/build2/version/init.cxx
+++ b/build2/version/init.cxx
@@ -176,24 +176,15 @@ namespace build2
rs.assign (v) = move (val);
};
- // Enough of project version for unique identification (can be used in
- // places like soname, etc).
- //
- string id (v.string_version ());
- if (v.snapshot ()) // Trailing dot already in id.
- {
- id += (v.snapshot_sn == standard_version::latest_sn
- ? "z"
- : (v.snapshot_id.empty ()
- ? to_string (v.snapshot_sn):
- v.snapshot_id));
- }
-
set ("version", v.string ()); // Package version.
set ("version.project", v.string_project ());
set ("version.project_number", v.version);
- set ("version.project_id", move (id));
+
+ // Enough of project version for unique identification (can be used in
+ // places like soname, etc).
+ //
+ set ("version.project_id", v.string_project_id ());
set ("version.epoch", uint64_t (v.epoch));