From b6dfd0e94aad546069eee7749a0b78eda45f6a78 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 7 Sep 2022 10:56:46 +0200 Subject: Fix fsdir{} handling corner cases in ad hoc buildscript recipes/rules --- libbuild2/adhoc-rule-buildscript.cxx | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) (limited to 'libbuild2/adhoc-rule-buildscript.cxx') diff --git a/libbuild2/adhoc-rule-buildscript.cxx b/libbuild2/adhoc-rule-buildscript.cxx index 9a38a31..c5eaa60 100644 --- a/libbuild2/adhoc-rule-buildscript.cxx +++ b/libbuild2/adhoc-rule-buildscript.cxx @@ -325,7 +325,11 @@ namespace build2 // We do it always instead of only if one of the targets is path-based in // case the recipe creates temporary files or some such. // - const fsdir* dir (inject_fsdir (a, xt)); + // Note that we disable the prerequisite search for fsdir{} because of the + // prerequisites injected by the pattern. So we have to handle this ad hoc + // below. + // + const fsdir* dir (inject_fsdir (a, xt, false /* prereq */)); // Match prerequisites. // @@ -382,6 +386,9 @@ namespace build2 const target& pt (p.search (xt)); + if (&pt == dir) // Don't add injected fsdir{} twice. + continue; + if (clean && !pt.in (*bs.root_scope ())) continue; @@ -405,7 +412,7 @@ namespace build2 for (const prerequisite_target& pt: pts) { - if (pt.target == dir) + if (pt.target == dir) // Don't match injected fsdir{} twice. continue; match_async (a, *pt.target, ctx.count_busy (), xt[a].task_count); @@ -417,7 +424,7 @@ namespace build2 // for (prerequisite_target& pt: pts) { - if (pt.target == dir) + if (pt.target == dir) // See above. continue; // Handle update=unmatch. @@ -525,6 +532,27 @@ namespace build2 file& t (xt.as ()); const path& tp (t.path ()); + // Re-acquire fsdir{} specified by the user, similar to inject_fsdir() + // (which we have disabled; see above). + // + if (dir == nullptr) + { + for (const target* pt: pts) + { + if (pt != nullptr) + { + if (const fsdir* dt = pt->is_a ()) + { + if (dt->dir == t.dir) + { + dir = dt; + break; + } + } + } + } + } + if (dir != nullptr) fsdir_rule::perform_update_direct (a, t); -- cgit v1.1