aboutsummaryrefslogtreecommitdiff
path: root/libbuild2
diff options
context:
space:
mode:
Diffstat (limited to 'libbuild2')
-rw-r--r--libbuild2/config/utility.hxx3
-rw-r--r--libbuild2/parser.cxx19
2 files changed, 20 insertions, 2 deletions
diff --git a/libbuild2/config/utility.hxx b/libbuild2/config/utility.hxx
index f2bddc2..38a3ae1 100644
--- a/libbuild2/config/utility.hxx
+++ b/libbuild2/config/utility.hxx
@@ -99,7 +99,8 @@ namespace build2
// then, if there is no value, call the version with the default value and
// end up with the same result if we called the default value version
// straight away. This is useful when computing the default value is
- // expensive.
+ // expensive. It is also ok to call both versions multiple times provided
+ // the flags are the same.
//
// @@ Should we pass flags and interpret save_null_omitted to treat null
// as undefined? Sounds logical.
diff --git a/libbuild2/parser.cxx b/libbuild2/parser.cxx
index 532b357..797a484 100644
--- a/libbuild2/parser.cxx
+++ b/libbuild2/parser.cxx
@@ -1885,7 +1885,24 @@ namespace build2
if (l.var != nullptr)
{
- config_report.push_back (make_pair (l, move (*report)));
+ auto r (make_pair (l, move (*report)));
+
+ // If we have a duplicate, update it (it could be useful to have
+ // multiple config directives to "probe" the value before calculating
+ // the default; see lookup_config() for details).
+ //
+ auto i (find_if (config_report.begin (),
+ config_report.end (),
+ [&l] (const pair<lookup, string>& p)
+ {
+ return p.first.var == l.var;
+ }));
+
+ if (i == config_report.end ())
+ config_report.push_back (move (r));
+ else
+ *i = move (r);
+
config_report_new = config_report_new || new_val;
}
}