From e20a351013745e8d6c3a0a99bd40c172ed0ae8be Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 14 Mar 2019 17:20:02 +0200 Subject: 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 --- build2/config/operation.cxx | 18 +++++------------- build2/config/utility.cxx | 2 +- build2/config/utility.txx | 2 +- 3 files changed, 7 insertions(+), 15 deletions(-) (limited to 'build2/config') 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 org (root.find_original (var)); - pair ovr (var.override == nullptr + pair 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 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 ovr (root.find_override (var, move (org))); -- cgit v1.1