From 82e9227262a41bfa740952659b3b91d2d99e984e Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 3 Dec 2021 09:47:05 +0200 Subject: Add depdb-dyndep --drop-cycles option --- libbuild2/adhoc-rule-buildscript.cxx | 56 +++++++++++++++--------------------- 1 file changed, 23 insertions(+), 33 deletions(-) (limited to 'libbuild2/adhoc-rule-buildscript.cxx') diff --git a/libbuild2/adhoc-rule-buildscript.cxx b/libbuild2/adhoc-rule-buildscript.cxx index 0648c3d..ea4ab60 100644 --- a/libbuild2/adhoc-rule-buildscript.cxx +++ b/libbuild2/adhoc-rule-buildscript.cxx @@ -582,28 +582,6 @@ namespace build2 fp, true /* cache */, true /* normalized */, map_ext, *byp.default_type).first) { - // Skip if this is one of the static prerequisites. - // - for (size_t i (0); i != pts_n; ++i) - { - const prerequisite_target& p (pts[i]); - - if (const target* pt = - (p.target != nullptr ? p.target : - p.data != 0 ? reinterpret_cast (p.data) : - nullptr)) - { - if (pt == ft) - { - // Note that we have to increment the skip count since we - // skip before performing this test. - // - skip_count++; - return false; - } - } - } - if (optional u = dyndep::inject_existing_file ( trace, what, a, t, @@ -826,9 +804,11 @@ namespace build2 // // Note that fp is expected to be absolute. // + size_t skip (md.skip_count); + auto add = [&trace, what, a, &bs, &t, &pts, pts_n = md.pts_n, - &byp, &map_ext, &dd] (path fp) + &byp, &map_ext, &dd, &skip] (path fp) { normalize_external (fp, what); @@ -849,11 +829,30 @@ namespace build2 p.data != 0 ? reinterpret_cast (p.data) : nullptr)) { - if (pt == ft) + if (ft == pt) + return; + } + } + + // Skip if this is one of the targets. + // + if (byp.drop_cycles) + { + for (const target* m (&t); m != nullptr; m = m->adhoc_member) + { + if (ft == m) return; } } + // Skip until where we left off. + // + if (skip != 0) + { + --skip; + return; + } + // Verify it has noop recipe. // dyndep::verify_existing_file (trace, what, a, t, *ft); @@ -881,7 +880,6 @@ namespace build2 } location il (file, 1); - size_t skip (md.skip_count); // The way we parse things is format-specific. // @@ -924,14 +922,6 @@ namespace build2 if (r.first == make_type::target) continue; - // Skip until where we left off. - // - if (skip != 0) - { - skip--; - continue; - } - path f (move (r.second)); if (f.relative ()) -- cgit v1.1