aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS3
-rw-r--r--build2/context.cxx24
2 files changed, 26 insertions, 1 deletions
diff --git a/NEWS b/NEWS
index 38845e0..d361e46 100644
--- a/NEWS
+++ b/NEWS
@@ -57,6 +57,9 @@ Version 0.3.0
build2 was built with but a more precise value can be obtained with the
--config-guess option.
+ * Set build.version, build.version.{major,minor,patch,release,string} build
+ system variables to the build2 version.
+
* Extracted header dependencies (-M*) are now cached in the auxiliary
dependency (.d) files rather than being re-extracted on every run. This
speeds up the up-to-date check significantly.
diff --git a/build2/context.cxx b/build2/context.cxx
index 0fc3bd6..812886c 100644
--- a/build2/context.cxx
+++ b/build2/context.cxx
@@ -6,9 +6,10 @@
#include <butl/triplet>
+#include <build2/rule>
#include <build2/scope>
#include <build2/target>
-#include <build2/rule>
+#include <build2/version>
#include <build2/diagnostics>
using namespace std;
@@ -89,6 +90,27 @@ namespace build2
gs.assign ("build.work", dir_path_type) = work;
gs.assign ("build.home", dir_path_type) = home;
+ // Enter the version.
+ //
+ // @@ VAR types
+ //
+ {
+ gs.assign ("build.version", string_type) = to_string (BUILD2_VERSION);
+ gs.assign ("build.version.string", string_type) = BUILD2_VERSION_STR;
+
+ // AABBCCDD
+ //
+ auto comp = [] (unsigned int d) -> string
+ {
+ return to_string ((BUILD2_VERSION / d)% 100);
+ };
+
+ gs.assign ("build.version.release", string_type) = comp (1);
+ gs.assign ("build.version.patch", string_type) = comp (100);
+ gs.assign ("build.version.minor", string_type) = comp (10000);
+ gs.assign ("build.version.major", string_type) = comp (1000000);
+ }
+
// Enter the host information. Rather than jumping through hoops like
// config.guess, for now we are just going to use the compiler target we
// were built with. While it is not as precise (for example, a binary