From a011c760c7a4929ee6e9eaa6231c550964f3a4aa Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 15 Mar 2016 10:44:02 +0200 Subject: Set build.version, build.version.{major,minor,patch,release,string} --- NEWS | 3 +++ build2/context.cxx | 24 +++++++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) 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 +#include #include #include -#include +#include #include 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 -- cgit v1.1