From 542ad9696f50e33fa20e735c14c052720c55bc3a Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 23 Aug 2019 14:35:53 +0200 Subject: dry_run --- build2/cc/compile-rule.cxx | 22 +++++++++++++--------- build2/cc/init.cxx | 8 +++++--- build2/cc/link-rule.cxx | 20 +++++++++++--------- build2/cc/pkgconfig.cxx | 2 +- build2/cc/windows-manifest.cxx | 2 +- build2/cc/windows-rpath.cxx | 4 ++-- 6 files changed, 33 insertions(+), 25 deletions(-) (limited to 'build2/cc') diff --git a/build2/cc/compile-rule.cxx b/build2/cc/compile-rule.cxx index 6902bb6..fa43533 100644 --- a/build2/cc/compile-rule.cxx +++ b/build2/cc/compile-rule.cxx @@ -583,6 +583,8 @@ namespace build2 match_data& md (t.data ()); + context& ctx (t.ctx); + // Note: until refined below, non-BMI-generating translation unit is // assumed non-modular. // @@ -698,7 +700,7 @@ namespace build2 // Start asynchronous matching of prerequisites. Wait with unlocked // phase to allow phase switching. // - wait_guard wg (t.ctx, t.ctx.count_busy (), t[a].task_count, true); + wait_guard wg (ctx, ctx.count_busy (), t[a].task_count, true); size_t start (pts.size ()); // Index of the first to be added. for (prerequisite_member p: group_prerequisite_members (a, t)) @@ -760,7 +762,7 @@ namespace build2 continue; } - match_async (a, *pt, t.ctx.count_busy (), t[a].task_count); + match_async (a, *pt, ctx.count_busy (), t[a].task_count); pts.push_back (prerequisite_target (pt, pi)); } @@ -1148,7 +1150,7 @@ namespace build2 // to keep re-validating the file on every subsequent dry-run as well // on the real run). // - if (u && dd.reading () && !dry_run) + if (u && dd.reading () && !ctx.dry_run) dd.touch = true; dd.close (); @@ -5558,6 +5560,8 @@ namespace build2 match_data md (move (t.data ())); unit_type ut (md.type); + context& ctx (t.ctx); + // While all our prerequisites are already up-to-date, we still have to // execute them to keep the dependency counts straight. Actually, no, we // may also have to update the modules. @@ -5583,9 +5587,9 @@ namespace build2 { if (md.touch) { - touch (tp, false, 2); + touch (ctx, tp, false, 2); t.mtime (system_clock::now ()); - t.ctx.skip_count.fetch_add (1, memory_order_relaxed); + ctx.skip_count.fetch_add (1, memory_order_relaxed); } // Note: else mtime should be cached. @@ -5600,7 +5604,7 @@ namespace build2 ? system_clock::now () : timestamp_unknown); - touch (md.dd, false, verb_never); + touch (ctx, md.dd, false, verb_never); const scope& bs (t.base_scope ()); const scope& rs (*bs.root_scope ()); @@ -5949,7 +5953,7 @@ namespace build2 // translation unit (i.e., one of the imported module's has BMIs // changed). // - if (!dry_run) + if (!ctx.dry_run) { try { @@ -6028,7 +6032,7 @@ namespace build2 if (verb >= 2) print_process (args); - if (!dry_run) + if (!ctx.dry_run) { // Remove the target file if this fails. If we don't do that, we // will end up with a broken build that is up-to-date. @@ -6061,7 +6065,7 @@ namespace build2 timestamp now (system_clock::now ()); - if (!dry_run) + if (!ctx.dry_run) depdb::check_mtime (start, md.dd, tp, now); // Should we go to the filesystem and get the new mtime? We know the diff --git a/build2/cc/init.cxx b/build2/cc/init.cxx index 3ff59a1..c83d5ed 100644 --- a/build2/cc/init.cxx +++ b/build2/cc/init.cxx @@ -26,27 +26,29 @@ namespace build2 static target_state clean_module_sidebuilds (action, const scope& rs, const dir&) { + context& ctx (rs.ctx); + const dir_path& out_root (rs.out_path ()); dir_path d (out_root / rs.root_extra->build_dir / modules_sidebuild_dir); if (exists (d)) { - if (build2::rmdir_r (d)) + if (rmdir_r (ctx, d)) { // Clean up cc/ if it became empty. // d = out_root / rs.root_extra->build_dir / module_dir; if (empty (d)) { - rmdir (d); + rmdir (ctx, d); // And build/ if it also became empty (e.g., in case of a build // with a transient configuration). // d = out_root / rs.root_extra->build_dir; if (empty (d)) - rmdir (d); + rmdir (ctx, d); } return target_state::changed; diff --git a/build2/cc/link-rule.cxx b/build2/cc/link-rule.cxx index 9980fa3..bfc31d7 100644 --- a/build2/cc/link-rule.cxx +++ b/build2/cc/link-rule.cxx @@ -1749,6 +1749,8 @@ namespace build2 const file& t (xt.as ()); const path& tp (t.path ()); + context& ctx (t.ctx); + const scope& bs (t.base_scope ()); const scope& rs (*bs.root_scope ()); @@ -1868,7 +1870,7 @@ namespace build2 if (verb >= 3) print_process (args); - if (!dry_run) + if (!ctx.dry_run) { auto_rmfile rm (of); @@ -1968,7 +1970,7 @@ namespace build2 const string& cs ( cast ( rs[tsys == "win32-msvc" - ? t.ctx.var_pool["bin.ld.checksum"] + ? ctx.var_pool["bin.ld.checksum"] : x_checksum])); if (dd.expect (cs) != nullptr) @@ -2728,7 +2730,7 @@ namespace build2 // auto_rmfile rm; - if (!dry_run) + if (!ctx.dry_run) { rm = auto_rmfile (relt); @@ -2825,7 +2827,7 @@ namespace build2 if (verb >= 2) print_process (args); - if (!dry_run) + if (!ctx.dry_run) run (rl, args); } @@ -2845,12 +2847,12 @@ namespace build2 // For shared libraries we may need to create a bunch of symlinks (or // fallback to hardlinks/copies on Windows). // - auto ln = [] (const path& f, const path& l) + auto ln = [&ctx] (const path& f, const path& l) { if (verb >= 3) text << "ln -sf " << f << ' ' << l; - if (dry_run) + if (ctx.dry_run) return; try @@ -2910,12 +2912,12 @@ namespace build2 // if (tsys == "darwin" && cast (rs["bin.ar.id"]) == "generic") { - if (!dry_run) - touch (tp, false /* create */, verb_never); + if (!ctx.dry_run) + touch (ctx, tp, false /* create */, verb_never); } } - if (!dry_run) + if (!ctx.dry_run) { rm.cancel (); dd.check_mtime (tp); diff --git a/build2/cc/pkgconfig.cxx b/build2/cc/pkgconfig.cxx index 038ecc6..3b4c711 100644 --- a/build2/cc/pkgconfig.cxx +++ b/build2/cc/pkgconfig.cxx @@ -1248,7 +1248,7 @@ namespace build2 if (verb >= 2) text << "cat >" << p; - if (dry_run) + if (ctx.dry_run) return; auto_rmfile arm (p); diff --git a/build2/cc/windows-manifest.cxx b/build2/cc/windows-manifest.cxx index da12f0f..733cae5 100644 --- a/build2/cc/windows-manifest.cxx +++ b/build2/cc/windows-manifest.cxx @@ -119,7 +119,7 @@ namespace build2 if (verb >= 3) text << "cat >" << mf; - if (!dry_run) + if (!t.ctx.dry_run) { auto_rmfile rm (mf); diff --git a/build2/cc/windows-rpath.cxx b/build2/cc/windows-rpath.cxx index d81e3b0..4478f7d 100644 --- a/build2/cc/windows-rpath.cxx +++ b/build2/cc/windows-rpath.cxx @@ -281,7 +281,7 @@ namespace build2 // simpler. // { - rmdir_status s (build2::rmdir_r (ad, empty, 3)); + rmdir_status s (rmdir_r (t.ctx, ad, empty, 3)); if (empty) return; @@ -362,7 +362,7 @@ namespace build2 if (verb >= 3) text << "cat >" << am; - if (dry_run) + if (t.ctx.dry_run) return; auto_rmfile rm (am); -- cgit v1.1