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} --- build2/context.cxx | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'build2/context.cxx') 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