aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2024-02-12 05:52:10 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2024-02-12 05:52:10 +0200
commitd298d5cb1379d719dd96d5374b388889467269ee (patch)
tree2704939e9b47039203fe0b8ee5b9e4a619463de8
parentba8e7dccf1257fbec9c7a2eac8729fcec684a9ea (diff)
Extend class target, prerequisite_target interfaces
-rw-r--r--libbuild2/target.cxx8
-rw-r--r--libbuild2/target.hxx36
2 files changed, 38 insertions, 6 deletions
diff --git a/libbuild2/target.cxx b/libbuild2/target.cxx
index 2e25dd3..a70830e 100644
--- a/libbuild2/target.cxx
+++ b/libbuild2/target.cxx
@@ -233,14 +233,14 @@ namespace build2
}
value& target::
- append (const variable& var)
+ append (const variable& var, const scope* bs)
{
// Note: see also prerequisite::append() if changing anything here.
// Note that here we want the original value without any overrides
// applied.
//
- auto l (lookup_original (var).first);
+ auto l (lookup_original (var, false, bs).first);
if (l.defined () && l.belongs (*this)) // Existing var in this target.
return vars.modify (l); // Ok since this is original.
@@ -254,9 +254,9 @@ namespace build2
}
value& target::
- append_locked (const variable& var)
+ append_locked (const variable& var, const scope* bs)
{
- auto l (lookup_original (var, false, nullptr, true /* locked */).first);
+ auto l (lookup_original (var, false, bs, true /* locked */).first);
if (l.defined () && l.belongs (*this)) // Existing var in this target.
return vars.modify (l); // Ok since this is original.
diff --git a/libbuild2/target.hxx b/libbuild2/target.hxx
index e3152ac..41bf095 100644
--- a/libbuild2/target.hxx
+++ b/libbuild2/target.hxx
@@ -89,9 +89,15 @@ namespace build2
prerequisite_target (const target_type* t, bool a = false, uintptr_t d = 0)
: target (t), include (a ? include_adhoc : 0), data (d) {}
+ prerequisite_target (const target_type& t, bool a = false, uintptr_t d = 0)
+ : prerequisite_target (&t, a, d) {}
+
prerequisite_target (const target_type* t, include_type a, uintptr_t d = 0)
: prerequisite_target (t, a == include_type::adhoc, d) {}
+ prerequisite_target (const target_type& t, include_type a, uintptr_t d = 0)
+ : prerequisite_target (&t, a, d) {}
+
const target_type* target;
operator const target_type*& () {return target;}
@@ -799,15 +805,41 @@ namespace build2
value&
assign (const variable* var) {return vars.assign (var);} // For cached.
+ // Note: variable must already be entered.
+ //
+ value&
+ assign (const string& name)
+ {
+ return vars.assign (base_scope ().var_pool ().find (name));
+ }
+
// Return a value suitable for appending. See scope for details.
//
value&
- append (const variable&);
+ append (const variable&, const scope* bs = nullptr);
+
+ // Note: variable must already be entered.
+ //
+ value&
+ append (const string& name)
+ {
+ const scope& bs (base_scope ());
+ return append (*bs.var_pool ().find (name), &bs);
+ }
// As above but assume the targets mutex is locked.
//
value&
- append_locked (const variable&);
+ append_locked (const variable&, const scope* bs = nullptr);
+
+ // Note: variable must already be entered.
+ //
+ value&
+ append_locked (const string& name)
+ {
+ const scope& bs (base_scope ());
+ return append_locked (*bs.var_pool ().find (name), &bs);
+ }
// Rule hints.
//