From 3b0df49b8828921edfb7b764b0628fb164dab852 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 9 Nov 2017 13:33:06 +0200 Subject: Initial support for prerequisite-specific variables, use for bin.whole --- build2/prerequisite.cxx | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'build2/prerequisite.cxx') diff --git a/build2/prerequisite.cxx b/build2/prerequisite.cxx index 7facbaa..6233ec4 100644 --- a/build2/prerequisite.cxx +++ b/build2/prerequisite.cxx @@ -65,7 +65,8 @@ namespace build2 name (t.name), ext (to_ext (t.ext ())), scope (t.base_scope ()), - target (&t) + target (&t), + vars (false /* global */) { } @@ -75,4 +76,22 @@ namespace build2 const auto& p (t.prerequisites ()); return !(p.empty () || this < &p.front () || this > &p.back ()); } + + value& prerequisite:: + append (const variable& var, const target_type& t) + { + if (value* r = vars.find_to_modify (var)) + return *r; + + value& r (assign (var)); // NULL. + + // Note: pretty similar logic to target::append(). + // + lookup l (t.find_original (var).first); + + if (l.defined ()) + r = *l; // Copy value (and type) from the target/outer scope. + + return r; + } } -- cgit v1.1