From d7b5f03a761714f6ea6c4b1891e8a1f3824d4979 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 20 Aug 2019 09:14:19 +0200 Subject: Add build.version.interface This build system interface version should be embedded into build system modules as load_suffix. --- libbuild2/bash/buildfile | 6 ++++-- libbuild2/context.cxx | 11 +++++++++++ libbuild2/in/buildfile | 6 ++++-- libbuild2/version/buildfile | 6 ++++-- 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/libbuild2/bash/buildfile b/libbuild2/bash/buildfile index ed95998..e30f379 100644 --- a/libbuild2/bash/buildfile +++ b/libbuild2/bash/buildfile @@ -50,8 +50,10 @@ libs{build2-bash}: cxx.export.poptions += -DLIBBUILD2_BASH_SHARED # in place of another pre-release or the final version. See the version module # for details on the version.* variable values. # -# And seeing that this is a build system module, we also embed the same -# version as the build system core version. +# And because this is a build system module, we also embed the same value as +# the interface version (note that we cannot use build.version.interface for +# bundled modules because we could be built with a different version of the +# build system). # ver = ($version.pre_release \ ? "$version.project_id" \ diff --git a/libbuild2/context.cxx b/libbuild2/context.cxx index 815a556..e7f9751 100644 --- a/libbuild2/context.cxx +++ b/libbuild2/context.cxx @@ -432,6 +432,9 @@ namespace build2 gs.assign (variable_pool::instance.insert (var)) = move (val); }; + // Note: here we assume epoch will always be 1 and therefore omit the + // project_ prefix in a few places. + // set ("build.version", v.string_project ()); set ("build.version.number", v.version); @@ -455,6 +458,14 @@ namespace build2 set ("build.version.snapshot_id", v.snapshot_id); // string set ("build.version.snapshot_string", v.string_snapshot ()); + // Build system interface version. In particular, it is embedded into + // build system modules as load_suffix. + // + set ("build.version.interface", + v.pre_release () + ? v.string_project_id () + : to_string (v.major ()) + '.' + to_string (v.minor ())); + // Allow detection (for example, in tests) whether this is a staged // toolchain. // diff --git a/libbuild2/in/buildfile b/libbuild2/in/buildfile index aa5af87..b67ee00 100644 --- a/libbuild2/in/buildfile +++ b/libbuild2/in/buildfile @@ -47,8 +47,10 @@ libs{build2-in}: cxx.export.poptions += -DLIBBUILD2_IN_SHARED # in place of another pre-release or the final version. See the version module # for details on the version.* variable values. # -# And seeing that this is a build system module, we also embed the same -# version as the build system core version. +# And because this is a build system module, we also embed the same value as +# the interface version (note that we cannot use build.version.interface for +# bundled modules because we could be built with a different version of the +# build system). # ver = ($version.pre_release \ ? "$version.project_id" \ diff --git a/libbuild2/version/buildfile b/libbuild2/version/buildfile index 7477815..96f55ad 100644 --- a/libbuild2/version/buildfile +++ b/libbuild2/version/buildfile @@ -51,8 +51,10 @@ libs{build2-version}: cxx.export.poptions += -DLIBBUILD2_VERSION_SHARED # in place of another pre-release or the final version. See the version module # for details on the version.* variable values. # -# And seeing that this is a build system module, we also embed the same -# version as the build system core version. +# And because this is a build system module, we also embed the same value as +# the interface version (note that we cannot use build.version.interface for +# bundled modules because we could be built with a different version of the +# build system). # ver = ($version.pre_release \ ? "$version.project_id" \ -- cgit v1.1