aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2024-02-15 09:11:53 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2024-02-15 09:11:53 +0200
commit70d63c266ffd313c03f6cf68e7080bbcd3c8c064 (patch)
treefa102b7885549600b7f66ecb31519af86858ce85
parent40f84c09974c03405a63c9eba32df7209de4bec0 (diff)
Add fsdir{} duplicate suppression in more places
-rw-r--r--libbuild2/adhoc-rule-regex-pattern.cxx14
-rw-r--r--libbuild2/cc/compile-rule.cxx3
-rw-r--r--libbuild2/cc/link-rule.cxx8
-rw-r--r--libbuild2/rule.hxx3
4 files changed, 24 insertions, 4 deletions
diff --git a/libbuild2/adhoc-rule-regex-pattern.cxx b/libbuild2/adhoc-rule-regex-pattern.cxx
index 9101000..2d60520 100644
--- a/libbuild2/adhoc-rule-regex-pattern.cxx
+++ b/libbuild2/adhoc-rule-regex-pattern.cxx
@@ -452,6 +452,18 @@ namespace build2
auto& pts (t.prerequisite_targets[a]);
+ // Avoid duplicating fsdir{} that may have already been injected by
+ // inject_fsdir() (in which case it is expected to be first).
+ //
+ const target* dir (nullptr);
+ if (!pts.empty ())
+ {
+ const prerequisite_target& pt (pts.front ());
+
+ if (pt.target != nullptr && pt.adhoc () && pt.target->is_a<fsdir> ())
+ dir = pt.target;
+ }
+
for (const element& e: prereqs_)
{
// While it would be nice to avoid copying here, the semantics of
@@ -488,7 +500,7 @@ namespace build2
const target& pt (search (t, move (n), *s, &e.type));
- if (clean && !pt.in (*bs.root_scope ()))
+ if (&pt == dir || (clean && !pt.in (*bs.root_scope ())))
continue;
// @@ TODO: it could be handy to mark a prerequisite (e.g., a tool)
diff --git a/libbuild2/cc/compile-rule.cxx b/libbuild2/cc/compile-rule.cxx
index 5c811a1..d490c8e 100644
--- a/libbuild2/cc/compile-rule.cxx
+++ b/libbuild2/cc/compile-rule.cxx
@@ -1085,7 +1085,8 @@ namespace build2
{
pt = &p.search (t);
- if (a.operation () == clean_id && !pt->dir.sub (rs.out_path ()))
+ if (pt == dir ||
+ (a.operation () == clean_id && !pt->dir.sub (rs.out_path ())))
continue;
}
diff --git a/libbuild2/cc/link-rule.cxx b/libbuild2/cc/link-rule.cxx
index 76e4a25..d705eb5 100644
--- a/libbuild2/cc/link-rule.cxx
+++ b/libbuild2/cc/link-rule.cxx
@@ -912,7 +912,7 @@ namespace build2
// for binless libraries since there could be other output (e.g., .pc
// files).
//
- inject_fsdir (a, t);
+ const fsdir* dir (inject_fsdir (a, t));
// Process prerequisites, pass 1: search and match prerequisite
// libraries, search obj/bmi{} targets, and search targets we do rule
@@ -1201,6 +1201,12 @@ namespace build2
}
pt = &p.search (t);
+
+ if (pt == dir)
+ {
+ pt = nullptr;
+ continue;
+ }
}
if (skip (*pt))
diff --git a/libbuild2/rule.hxx b/libbuild2/rule.hxx
index e4afcd4..eceb6ad 100644
--- a/libbuild2/rule.hxx
+++ b/libbuild2/rule.hxx
@@ -369,7 +369,8 @@ namespace build2
// The implementation should append pattern prerequisites to
// t.prerequisite_targets[a] but not match. It should set bit 2 in
// prerequisite_target::include to indicate update=match and bit 3
- // to indicate update=unmatch.
+ // to indicate update=unmatch. It should also avoid adding duplicate
+ // fsdir{} similar to the search_prerequisite*() functions.
//
virtual void
apply_prerequisites (action, target&,