aboutsummaryrefslogtreecommitdiff
path: root/build2/b.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2023-05-08 13:21:55 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2023-05-09 15:37:47 +0200
commitb5d143f529e4ebbeb7a1746312e38da815e2e321 (patch)
tree2275a4619794874f7e8efea1735d46a1912313dc /build2/b.cxx
parent00df206af5c80aba31bf7d180bdf03d617071e94 (diff)
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.
Diffstat (limited to 'build2/b.cxx')
-rw-r--r--build2/b.cxx21
1 files changed, 19 insertions, 2 deletions
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<match_only_level> 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<alias> ())
+ 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<uint16_t> (post_oid);});
}
+ if (dump_load && load_only)
+ dump (ctx, nullopt /* action */);
+
if (mif->operation_post != nullptr)
mif->operation_post (ctx, mparams, oid);