From b5d143f529e4ebbeb7a1746312e38da815e2e321 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 8 May 2023 13:21:55 +0200 Subject: Add --load-only option in addition to --match-only This option has the effect of loading all the subdirectory buildfiles that are not explicitly included. --- build2/b.cxx | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'build2/b.cxx') diff --git a/build2/b.cxx b/build2/b.cxx index 163a89e..72c49e9 100644 --- a/build2/b.cxx +++ b/build2/b.cxx @@ -416,10 +416,14 @@ main (int argc, char* argv[]) pctx = nullptr; // Free first to reuse memory. } + optional mo; + if (ops.load_only ()) mo = match_only_level::alias; + else if (ops.match_only ()) mo = match_only_level::all; + pctx.reset (new context (sched, mutexes, fcache, - ops.match_only (), + mo, ops.no_external_modules (), ops.dry_run (), ops.no_diag_buffer (), @@ -479,6 +483,8 @@ main (int argc, char* argv[]) 1100 /* variables */}); } + bool load_only (ops.load_only ()); + const path& buildfile (ops.buildfile_specified () ? ops.buildfile () : empty_path); @@ -1409,6 +1415,9 @@ main (int argc, char* argv[]) break; } + if (load_only && (mid != perform_id || oid != update_id)) + fail << "--load-only requires perform(update) action"; + // Now load the buildfiles and search the targets. // action_targets tgs; @@ -1440,6 +1449,9 @@ main (int argc, char* argv[]) if (tt == nullptr) fail (l) << "unknown target type " << tn.type; + if (load_only && !tt->is_a ()) + fail << "--load-only requires alias target"; + if (mif->search != nullptr) { // If the directory is relative, assume it is relative to work @@ -1470,7 +1482,9 @@ main (int argc, char* argv[]) } } // target - if (dump_load) + // Delay until after match in the --load-only mode (see below). + // + if (dump_load && !load_only) dump (ctx, nullopt /* action */); // Finally, match the rules and perform the operation. @@ -1610,6 +1624,9 @@ main (int argc, char* argv[]) << ", id " << static_cast (post_oid);}); } + if (dump_load && load_only) + dump (ctx, nullopt /* action */); + if (mif->operation_post != nullptr) mif->operation_post (ctx, mparams, oid); -- cgit v1.1