aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2023-04-20 15:27:07 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2023-04-20 15:29:56 +0300
commit73ad5d9e292da525cebbf5da35a81750bf89218a (patch)
tree72c8c426cc83cc75288fe2dc6dfcdf377964f68a
parent38943a2ecd79d2af18491a6c994c983aa5a35b97 (diff)
Log configuration UUIDs after bpkg.configure.build step id
-rw-r--r--bbot/worker/worker.cxx122
1 files changed, 111 insertions, 11 deletions
diff --git a/bbot/worker/worker.cxx b/bbot/worker/worker.cxx
index 0c159f6..aee7d3c 100644
--- a/bbot/worker/worker.cxx
+++ b/bbot/worker/worker.cxx
@@ -379,6 +379,12 @@ log_line (string&& l, string& log, tracer* trace = nullptr)
log += '\n';
}
+#ifndef _WIN32
+const char* comment_begin ("#");
+#else
+const char* comment_begin ("rem");
+#endif
+
// Run the worker script command. Name is used for logging and diagnostics
// only. Match lines read from the command's stderr against the regular
// expressions and return the warning result status (instead of success) in
@@ -398,11 +404,17 @@ log_line (string&& l, string& log, tracer* trace = nullptr)
// For the special end step no command is executed. In this case only the user
// is potentially prompted and the step is traced/logged.
//
+// If specified, the pre-run callback is called after the step id is logged
+// but before the command is logged/executed.
+//
+using pre_run_function = void ();
+
template <typename... A>
static result_status
run_cmd (step_id step,
tracer& t,
string& log,
+ const function<pre_run_function>& pre_run,
optional<string>* out_str, const path& out_file,
const regexes& warn_detect,
const string& name,
@@ -448,7 +460,7 @@ run_cmd (step_id step,
}
};
- auto prompt_step = [step, &t, &log, &bkp_step, &prompt] ()
+ auto prompt_step = [step, &t, &log, &bkp_step, &prompt, &pre_run] ()
{
const string& sid (to_string (step));
@@ -466,15 +478,15 @@ run_cmd (step_id step,
//
l3 ([&]{t << "step id: " << sid << ' ' << ts;});
-#ifndef _WIN32
- log += "# step id: ";
-#else
- log += "rem step id: ";
-#endif
+ log += comment_begin;
+ log += " step id: ";
log += sid;
log += ' ';
log += ts;
log += '\n';
+
+ if (pre_run)
+ pre_run ();
};
try
@@ -619,12 +631,43 @@ run_cmd (step_id step,
}
}
+template <typename... A>
+static result_status
+run_cmd (step_id step,
+ tracer& t,
+ string& log,
+ optional<string>* out_str, const path& out_file,
+ const regexes& warn_detect,
+ const string& name,
+ const optional<step_id>& bkp_step,
+ const optional<result_status>& bkp_status,
+ string& last_cmd,
+ const process_env& pe,
+ A&&... a)
+{
+ return run_cmd (step,
+ t,
+ log,
+ nullptr /* pre_run */,
+ out_str, out_file,
+ warn_detect,
+ name,
+ bkp_step,
+ bkp_status,
+ last_cmd,
+ pe,
+ forward<A> (a)...);
+}
+
template <typename V, typename... A>
static result_status
run_bpkg (step_id step,
const V& envvars,
tracer& t,
- string& log, optional<string>& out, const regexes& warn_detect,
+ string& log,
+ const function<pre_run_function>& pre_run,
+ optional<string>& out,
+ const regexes& warn_detect,
const optional<step_id>& bkp_step,
const optional<result_status>& bkp_status,
string& last_cmd,
@@ -633,7 +676,10 @@ run_bpkg (step_id step,
{
return run_cmd (step,
t,
- log, &out, path () /* out_file */, warn_detect,
+ log,
+ pre_run,
+ &out, path () /* out_file */,
+ warn_detect,
"bpkg " + cmd,
bkp_step, bkp_status, last_cmd,
process_env ("bpkg", envvars),
@@ -667,7 +713,10 @@ template <typename... A>
static result_status
run_bpkg (step_id step,
tracer& t,
- string& log, optional<string>& out, const regexes& warn_detect,
+ string& log,
+ const function<pre_run_function>& pre_run,
+ optional<string>& out,
+ const regexes& warn_detect,
const optional<step_id>& bkp_step,
const optional<result_status>& bkp_status,
string& last_cmd,
@@ -679,7 +728,10 @@ run_bpkg (step_id step,
return run_bpkg (step,
envvars,
t,
- log, out, warn_detect,
+ log,
+ pre_run,
+ out,
+ warn_detect,
bkp_step, bkp_status, last_cmd,
verbosity, cmd, forward<A> (a)...);
}
@@ -2098,6 +2150,14 @@ build (size_t argc, const char* argv[])
// then when running the bpkg-pkg-build command we need to specify the
// configuration for each package explicitly via --config-uuid.
//
+ // While it's tempting to use the --config-name option instead of
+ // --config-uuid, that wouldn't work well for multiple current
+ // configurations. For --config-name the configuration search is carried
+ // out among configurations explicitly linked to the main configuration
+ // only. That's in contrast to --config-uuid, when the whole
+ // configuration cluster is searched (see bpkg-pkg-build implementation
+ // for details).
+ //
// Let's not generate random UUIDs but use some predefined values which
// we can easily recognize in the build logs.
//
@@ -3043,9 +3103,49 @@ build (size_t argc, const char* argv[])
optional<string> dependency_checksum;
+ // Only log configuration UUIDs if they are specified on the command
+ // line.
+ //
+ function<pre_run_function> log_uuids (
+ [&r, &trace,
+ target_uuid, host_uuid, module_uuid, install_uuid,
+ target_pkg] ()
+ {
+ if (!target_pkg)
+ {
+ auto log = [&r, &trace] (const char* uuid, const char* name)
+ {
+ string s (uuid);
+ s += " - ";
+ s += name;
+
+ l3 ([&]{trace << s;});
+
+ r.log += comment_begin;
+ r.log += ' ';
+ r.log += s;
+ r.log += '\n';
+ };
+
+ r.log += comment_begin;
+ r.log += '\n';
+
+ log (target_uuid, "target");
+ log (host_uuid, "host");
+ log (module_uuid, "module");
+ log (install_uuid, "install");
+
+ r.log += comment_begin;
+ r.log += '\n';
+ }
+ });
+
r.status |= run_bpkg (
b,
- trace, r.log, dependency_checksum, wre,
+ trace, r.log,
+ log_uuids,
+ dependency_checksum,
+ wre,
bkp_step, bkp_status, last_cmd,
"-v",
"build",