aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2020-04-24 10:32:21 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2020-04-27 09:24:07 +0200
commitab93dccd5806de95b9123ec6c2272847ca0ae592 (patch)
tree922a4a586a8273c67adaf56dddaae8e79d3a0c78
parent56499cc66ca248029aa584fe9f5de04eeb24702f (diff)
Add inject() for injecting additional dependencies during match
-rw-r--r--libbuild2/algorithm.hxx7
-rw-r--r--libbuild2/algorithm.ixx7
2 files changed, 14 insertions, 0 deletions
diff --git a/libbuild2/algorithm.hxx b/libbuild2/algorithm.hxx
index d15810c..28b76c4 100644
--- a/libbuild2/algorithm.hxx
+++ b/libbuild2/algorithm.hxx
@@ -423,6 +423,13 @@ namespace build2
const target*
resolve_group (action, const target&);
+ // Inject a target as a "prerequisite target" (note: not a prerequisite) of
+ // another target. Specifically, first match the prerequisite target and
+ // then add it to the back of the dependent target's prerequisite_targets.
+ //
+ void
+ inject (action, target&, const target& prereq);
+
// Inject dependency on the target's directory fsdir{}, unless it is in the
// src tree or is outside of any project (say, for example, an installation
// directory). If the parent argument is true, then inject the parent
diff --git a/libbuild2/algorithm.ixx b/libbuild2/algorithm.ixx
index 9c656fd..c421218 100644
--- a/libbuild2/algorithm.ixx
+++ b/libbuild2/algorithm.ixx
@@ -476,6 +476,13 @@ namespace build2
return t.group;
}
+ inline void
+ inject (action a, target& t, const target& p)
+ {
+ match (a, p);
+ t.prerequisite_targets[a].emplace_back (&p);
+ }
+
LIBBUILD2_SYMEXPORT void
match_prerequisites (action, target&, const match_search&, const scope*);