aboutsummaryrefslogtreecommitdiff
path: root/bbot
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2021-09-27 20:58:59 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2021-09-27 23:30:13 +0300
commitf7a85ac1c09588b27854cef732b9e7a5e7bf6764 (patch)
tree9d616726c4dc7c98a48fe47d4cd48b2455eab7c8 /bbot
parentee6639c3aa1e188bae0eb645373b6c594bddf2c6 (diff)
Invent b.create and b.configure step ids and add support for selfhost module
Diffstat (limited to 'bbot')
-rw-r--r--bbot/worker/worker.cxx147
1 files changed, 89 insertions, 58 deletions
diff --git a/bbot/worker/worker.cxx b/bbot/worker/worker.cxx
index 8dd06de..49248b1 100644
--- a/bbot/worker/worker.cxx
+++ b/bbot/worker/worker.cxx
@@ -153,6 +153,13 @@ catch (const system_error& e)
//
enum class step_id
{
+ // Common fallbacks for bpkg_*_create/b_test_installed_create and
+ // bpkg_*_configure_build/b_test_installed_configure, respectively. Note:
+ // not breakpoints.
+ //
+ b_create,
+ b_configure,
+
// Note that bpkg_module_* options are only used if the main package is a
// build system module (using just ~build2 otherwise). They also have no
// fallback (build system modules are just too different to try to handle
@@ -162,8 +169,8 @@ enum class step_id
// steps are not fallbacks, they are always added first).
//
bpkg_create, // Breakpoint and base.
- bpkg_target_create, //: bpkg_create
- bpkg_host_create, //: bpkg_create
+ bpkg_target_create, //: b_create, bpkg_create
+ bpkg_host_create, //: b_create, bpkg_create
bpkg_module_create, //: no fallback
bpkg_link,
@@ -181,9 +188,9 @@ enum class step_id
// its external tests.
//
bpkg_configure_build, // Breakpoint and base.
- bpkg_target_configure_build, //: bpkg_configure_build
- bpkg_host_configure_build, //: bpkg_configure_build
- bpkg_module_configure_build, //: bpkg_configure_build
+ bpkg_target_configure_build, //: b_configure, bpkg_configure_build
+ bpkg_host_configure_build, //: b_configure, bpkg_configure_build
+ bpkg_module_configure_build, //: b_configure, bpkg_configure_build
bpkg_update,
bpkg_test,
@@ -202,8 +209,8 @@ enum class step_id
// Note: skipped for modules.
//
- b_test_installed_create,
- b_test_installed_configure,
+ b_test_installed_create, //: b_create
+ b_test_installed_configure, //: b_configure
b_test_installed_test,
// Note that for a host package this can involve both run-time and build-
@@ -242,6 +249,9 @@ enum class step_id
};
static const strings step_id_str {
+ "b.create",
+ "b.configure",
+
"bpkg.create",
"bpkg.target.create",
"bpkg.host.create",
@@ -888,6 +898,7 @@ build (size_t argc, const char* argv[])
bool mod (v->second[0] != '-' && v->second.find ('=') == string::npos);
if (mod && !v->first.empty () &&
+ v->first != "b.create" &&
v->first != "bpkg.create" &&
v->first != "bpkg.target.create" &&
v->first != "bpkg.host.create" &&
@@ -903,25 +914,17 @@ build (size_t argc, const char* argv[])
}
// Return command arguments for the specified step id, complementing
- // *.create[_for_*] steps with un-prefixed arguments. Arguments with more
- // specific prefixes come last.
+ // *.create[_for_*] steps with un-prefixed arguments. If no arguments are
+ // specified for the step then use the specified fallbacks, potentially
+ // both. Arguments with more specific prefixes come last.
//
auto step_args = [] (const std::multimap<string, string>& args,
step_id step,
- optional<step_id> fallback = nullopt) -> cstrings
+ optional<step_id> fallback1 = nullopt,
+ optional<step_id> fallback2 = nullopt) -> cstrings
{
cstrings r;
- // If no arguments found for the step id, then use the fallback step id,
- // if specified.
- //
- {
- const string& s (step_id_str[static_cast<size_t> (step)]);
-
- if (args.find (s) == args.end () && fallback)
- step = *fallback;
- }
-
// Add arguments for a specified, potentially empty, prefix.
//
auto add_args = [&args, &r] (const string& prefix)
@@ -937,6 +940,7 @@ build (size_t argc, const char* argv[])
//
switch (step)
{
+ case step_id::b_create:
case step_id::bpkg_create:
case step_id::bpkg_target_create:
case step_id::bpkg_host_create:
@@ -953,16 +957,38 @@ build (size_t argc, const char* argv[])
default: break;
}
- const string& s (step_id_str[static_cast<size_t> (step)]);
-
- for (size_t n (0);; ++n)
+ auto add_step_args = [&add_args] (step_id step)
{
- n = s.find ('.', n);
+ const string& s (step_id_str[static_cast<size_t> (step)]);
- add_args (n == string::npos ? s : string (s, 0, n));
+ for (size_t n (0);; ++n)
+ {
+ n = s.find ('.', n);
- if (n == string::npos)
- break;
+ add_args (n == string::npos ? s : string (s, 0, n));
+
+ if (n == string::npos)
+ break;
+ }
+ };
+
+ // If no arguments found for the step id, then use the fallback step
+ // ids, if specified.
+ //
+ if (args.find (step_id_str[static_cast<size_t> (step)]) != args.end ())
+ {
+ add_step_args (step);
+ }
+ else
+ {
+ // Note that if we ever need to specify fallback pairs with common
+ // ancestors, we may want to suppress duplicate ancestor step ids.
+ //
+ if (fallback1)
+ add_step_args (*fallback1);
+
+ if (fallback2)
+ add_step_args (*fallback2);
}
return r;
@@ -1274,9 +1300,10 @@ build (size_t argc, const char* argv[])
//
if (create_target)
{
- step_id b (step_id::bpkg_create); // Breakpoint.
- step_id s (step_id::bpkg_target_create); // Step.
- step_id f (step_id::bpkg_create); // Fallback.
+ step_id b (step_id::bpkg_create); // Breakpoint.
+ step_id s (step_id::bpkg_target_create); // Step.
+ step_id f1 (step_id::b_create); // First fallback.
+ step_id f2 (step_id::bpkg_create); // Second fallback.
r.status |= run_bpkg (
b,
@@ -1285,9 +1312,9 @@ build (size_t argc, const char* argv[])
"-V",
"create",
"-d", target_conf,
- step_args (modules, s, f),
- step_args (env_args, s, f),
- step_args (config_args, s, f));
+ step_args (modules, s, f1, f2),
+ step_args (env_args, s, f1, f2),
+ step_args (config_args, s, f1, f2));
if (!r.status)
break;
@@ -1297,11 +1324,12 @@ build (size_t argc, const char* argv[])
//
if (create_host)
{
- step_id b (step_id::bpkg_create);
- step_id s (step_id::bpkg_host_create);
- step_id f (step_id::bpkg_create);
+ step_id b (step_id::bpkg_create);
+ step_id s (step_id::bpkg_host_create);
+ step_id f1 (step_id::b_create);
+ step_id f2 (step_id::bpkg_create);
- if (selfhost)
+ if (host_pkg && selfhost)
{
// bpkg create --type host <env-modules> <env-config-args> <config-args>
//
@@ -1314,9 +1342,9 @@ build (size_t argc, const char* argv[])
"-d", host_conf,
"--type", "host",
"--name", "host",
- step_args (modules, s, f),
- step_args (env_args, s, f),
- step_args (config_args, s, f));
+ step_args (modules, s, f1, f2),
+ step_args (env_args, s, f1, f2),
+ step_args (config_args, s, f1, f2));
if (!r.status)
break;
@@ -1362,7 +1390,6 @@ build (size_t argc, const char* argv[])
if (create_module)
{
step_id b (step_id::bpkg_create);
- step_id s (step_id::bpkg_module_create);
// b create(<dir>) config.config.load=~build2 [<env-config-args> <config-args>]
//
@@ -1378,8 +1405,10 @@ build (size_t argc, const char* argv[])
cstrings cas;
string mods;
- if (module_pkg)
+ if (module_pkg && selfhost)
{
+ step_id s (step_id::bpkg_module_create);
+
for (const string& m: step_args (modules, s))
{
if (!mods.empty ())
@@ -1595,10 +1624,11 @@ build (size_t argc, const char* argv[])
host_pkg ? step_id::bpkg_host_configure_build :
step_id::bpkg_module_configure_build);
- step_id f (step_id::bpkg_configure_build);
+ step_id f1 (step_id::b_configure);
+ step_id f2 (step_id::bpkg_configure_build);
- cstrings eas (step_args (env_args, s, f));
- cstrings cas (step_args (config_args, s, f));
+ cstrings eas (step_args (env_args, s, f1, f2));
+ cstrings cas (step_args (config_args, s, f1, f2));
// Main package configuration name.
//
@@ -2133,15 +2163,6 @@ build (size_t argc, const char* argv[])
{
// Create the configuration.
//
- string mods; // build2 create meta-operation parameters.
-
- for (const string& m: step_args (modules,
- step_id::b_test_installed_create))
- {
- mods += mods.empty () ? ", " : " ";
- mods += m;
- }
-
// b create(<dir>, <env-modules>) <env-config-args> <config-args>
//
// Amalgamation directory that will contain configuration subdirectory
@@ -2152,6 +2173,15 @@ build (size_t argc, const char* argv[])
{
step_id b (step_id::b_test_installed_create);
step_id s (step_id::b_test_installed_create);
+ step_id f (step_id::b_create);
+
+ string mods; // build2 create meta-operation parameters.
+
+ for (const string& m: step_args (modules, s, f))
+ {
+ mods += mods.empty () ? ", " : " ";
+ mods += m;
+ }
r.status |= run_b (
b,
@@ -2159,8 +2189,8 @@ build (size_t argc, const char* argv[])
bkp_step, bkp_status, last_cmd,
"-V",
"create('" + out_dir.representation () + "'" + mods + ")",
- step_args (env_args, s),
- step_args (config_args, s));
+ step_args (env_args, s, f),
+ step_args (config_args, s, f));
if (!r.status)
break;
@@ -2177,6 +2207,7 @@ build (size_t argc, const char* argv[])
//
step_id b (step_id::b_test_installed_configure);
step_id s (step_id::b_test_installed_configure);
+ step_id f (step_id::b_configure);
dir_path subprj_src_dir (exists (dist_src)
? dist_src / d
@@ -2193,8 +2224,8 @@ build (size_t argc, const char* argv[])
"configure('" +
subprj_src_dir.representation () + "'@'" +
subprj_out_dir.representation () + "')",
- step_args (env_args, s),
- step_args (config_args, s));
+ step_args (env_args, s, f),
+ step_args (config_args, s, f));
if (!r.status)
break;