aboutsummaryrefslogtreecommitdiff
path: root/build2/config
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2019-03-14 17:20:02 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2019-03-14 17:20:02 +0200
commite20a351013745e8d6c3a0a99bd40c172ed0ae8be (patch)
treeb0e6d24dbc097c2001e6bb4b0c0357bcb83bdc72 /build2/config
parentd1b3ad7b302d037c8154bab9c4810d499c0bf1e4 (diff)
Add support for multiple variable overrides
Now we can do: $ b config.cxx.coptions=-O3 config.cxx.coptions=-O0 Or even: $ b config.cxx.coptions=-O3 config.cxx.coptions+=-g
Diffstat (limited to 'build2/config')
-rw-r--r--build2/config/operation.cxx18
-rw-r--r--build2/config/utility.cxx2
-rw-r--r--build2/config/utility.txx2
3 files changed, 7 insertions, 15 deletions
diff --git a/build2/config/operation.cxx b/build2/config/operation.cxx
index 724b92d..7d6fc74 100644
--- a/build2/config/operation.cxx
+++ b/build2/config/operation.cxx
@@ -131,7 +131,7 @@ namespace build2
const variable& var (sv.var);
pair<lookup, size_t> org (root.find_original (var));
- pair<lookup, size_t> ovr (var.override == nullptr
+ pair<lookup, size_t> ovr (var.overrides == nullptr
? org
: root.find_override (var, org));
const lookup& l (ovr.first);
@@ -859,19 +859,11 @@ namespace build2
{
const variable& var (p.first->first);
- // Annoyingly, this is one of the __override/__prefix/__suffix
- // values. So we strip the last component.
+ // Annoyingly, this can be (always is?) one of the overrides
+ // (__override, __prefix, etc).
//
- size_t n (var.name.size ());
-
- if (var.name.compare (n - 11, 11, ".__override") == 0)
- n -= 11;
- else if (var.name.compare (n - 9, 9, ".__prefix") == 0)
- n -= 9;
- else if (var.name.compare (n - 9, 9, ".__suffix") == 0)
- n -= 9;
-
- m.save_variable (*vp.find (string (var.name, 0, n)));
+ size_t n (var.override ());
+ m.save_variable (n != 0 ? *vp.find (string (var.name, 0, n)) : var);
}
// Now project-specific. For now we just save all of them and let
diff --git a/build2/config/utility.cxx b/build2/config/utility.cxx
index cc89d2f..e15c689 100644
--- a/build2/config/utility.cxx
+++ b/build2/config/utility.cxx
@@ -33,7 +33,7 @@ namespace build2
if (l.defined () && l->extra)
n = true;
- if (var.override != nullptr)
+ if (var.overrides != nullptr)
{
pair<lookup, size_t> ovr (r.find_override (var, move (org)));
diff --git a/build2/config/utility.txx b/build2/config/utility.txx
index 4f3429f..b8e0acc 100644
--- a/build2/config/utility.txx
+++ b/build2/config/utility.txx
@@ -47,7 +47,7 @@ namespace build2
else if (l->extra)
n = (save_flags & save_commented) == 0; // Absence means default.
- if (var.override != nullptr)
+ if (var.overrides != nullptr)
{
pair<lookup, size_t> ovr (root.find_override (var, move (org)));