aboutsummaryrefslogtreecommitdiff
path: root/libbuild2
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2024-02-13 13:00:09 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2024-02-13 13:00:09 +0200
commit3d39584285e4b39e7290bea9b2e4006cd1cf8a10 (patch)
treeb9c1099f1ae4b93e85263821a3d28a29f39cbad0 /libbuild2
parent8a23835baa00f0079dbcd259c04ffeb87a764568 (diff)
Add ability to omit matching in inject_fsdir()
Diffstat (limited to 'libbuild2')
-rw-r--r--libbuild2/adhoc-rule-buildscript.cxx2
-rw-r--r--libbuild2/algorithm.cxx6
-rw-r--r--libbuild2/algorithm.hxx13
-rw-r--r--libbuild2/rule.cxx2
4 files changed, 16 insertions, 7 deletions
diff --git a/libbuild2/adhoc-rule-buildscript.cxx b/libbuild2/adhoc-rule-buildscript.cxx
index 302e399..3e868a6 100644
--- a/libbuild2/adhoc-rule-buildscript.cxx
+++ b/libbuild2/adhoc-rule-buildscript.cxx
@@ -424,7 +424,7 @@ namespace build2
// prerequisites injected by the pattern. So we have to handle this ad hoc
// below.
//
- const fsdir* dir (inject_fsdir (a, t, false /* prereq */));
+ const fsdir* dir (inject_fsdir (a, t, true /*match*/, false /*prereq*/));
// Match prerequisites.
//
diff --git a/libbuild2/algorithm.cxx b/libbuild2/algorithm.cxx
index 2abf391..87217f7 100644
--- a/libbuild2/algorithm.cxx
+++ b/libbuild2/algorithm.cxx
@@ -1903,16 +1903,18 @@ namespace build2
}
const fsdir*
- inject_fsdir (action a, target& t, bool prereq, bool parent)
+ inject_fsdir (action a, target& t, bool match, bool prereq, bool parent)
{
const fsdir* r (inject_fsdir_impl (t, prereq, parent));
if (r != nullptr)
{
+ if (match)
+ match_sync (a, *r);
+
// Make it ad hoc so that it doesn't end up in prerequisite_targets
// after execution.
//
- match_sync (a, *r);
t.prerequisite_targets[a].emplace_back (r, include_type::adhoc);
}
diff --git a/libbuild2/algorithm.hxx b/libbuild2/algorithm.hxx
index dd5d367..64660a9 100644
--- a/libbuild2/algorithm.hxx
+++ b/libbuild2/algorithm.hxx
@@ -650,8 +650,12 @@ namespace build2
// src tree or is outside of any project (say, for example, an installation
// directory). If the parent argument is true, then inject the parent
// directory of a target that is itself a directory (name is empty). Match
- // and return the injected target or NULL. Normally this function is called
- // from the rule's apply() function.
+ // unless match is false and return the injected target or NULL. Normally
+ // this function is called from the rule's apply() function.
+ //
+ // The match=false semantics is useful when you wish to first collect all
+ // the prerequisites targets and then match them all as a separate step, for
+ // example, with match_members().
//
// As an extension, unless prereq is false, this function will also search
// for an existing fsdir{} prerequisite for the directory and if one exists,
@@ -659,7 +663,10 @@ namespace build2
// example, to place output into an otherwise non-existent directory.
//
LIBBUILD2_SYMEXPORT const fsdir*
- inject_fsdir (action, target&, bool prereq = true, bool parent = true);
+ inject_fsdir (action, target&,
+ bool match = true,
+ bool prereq = true,
+ bool parent = true);
// As above, but match the injected fsdir{} target directly (that is,
// without incrementing the dependency counts).
diff --git a/libbuild2/rule.cxx b/libbuild2/rule.cxx
index 9f90919..dc1c96c 100644
--- a/libbuild2/rule.cxx
+++ b/libbuild2/rule.cxx
@@ -234,7 +234,7 @@ namespace build2
// Inject dependency on our directory (note: not parent) so that it is
// automatically created on update and removed on clean.
//
- inject_fsdir (a, t, true, false);
+ inject_fsdir (a, t, true, true, false);
// Handle the alias match-only level.
//