From ab93dccd5806de95b9123ec6c2272847ca0ae592 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 24 Apr 2020 10:32:21 +0200 Subject: Add inject() for injecting additional dependencies during match --- libbuild2/algorithm.hxx | 7 +++++++ libbuild2/algorithm.ixx | 7 +++++++ 2 files changed, 14 insertions(+) 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*); -- cgit v1.1