From b734b2a16678b835742eed0de5fbf07f8a6332ae Mon Sep 17 00:00:00 2001 From: Klaus Aehlig Date: Thu, 15 May 2025 11:57:38 +0200 Subject: just-mr: support invocation-specific artifacts-to-build logging It is already supported to ask just-mr (via the rc file) to log for each invocation the artifacts that were built. Add a similar option for the artifacts that were to be built, i.e., for dumping the intensional description of the output artifacts. That information can be used, e.g., to compute the critical path. --- doc/tutorial/invocation-logging.md | 3 +++ share/man/just-mrrc.5.md | 3 +++ src/other_tools/just_mr/cli.hpp | 1 + src/other_tools/just_mr/launch.cpp | 14 ++++++++++++++ src/other_tools/just_mr/rc.cpp | 6 ++++++ 5 files changed, 27 insertions(+) diff --git a/doc/tutorial/invocation-logging.md b/doc/tutorial/invocation-logging.md index a1f94a1c..292504f2 100644 --- a/doc/tutorial/invocation-logging.md +++ b/doc/tutorial/invocation-logging.md @@ -48,6 +48,8 @@ be specified. directory to be used when generating the `--profile` option in the command line for the `just` invocation. - `"--dump-graph"` does the same for the `--dump-graph` option. + - `"--dump-artifacts-to-build"` does the same for the + `--dump-artifacts-to-build` option. - `"--dump-artifacts"` does the same for the `--dump-artifacts` option; while not directly useful for profiling, browsing the final artifacts (including the test logs) can be useful to @@ -67,6 +69,7 @@ would look as follows. , "metadata": "meta.json" , "--profile": "profile.json" , "--dump-graph": "graph.json" + , "--dump-artifacts-to-build": "to-build.json" , "--dump-artifacts": "artifacts.json" } } diff --git a/share/man/just-mrrc.5.md b/share/man/just-mrrc.5.md index 662717b7..96f11912 100644 --- a/share/man/just-mrrc.5.md +++ b/share/man/just-mrrc.5.md @@ -195,6 +195,9 @@ The just-mrrc is given by a JSON object. - *`"--dump-plain-graph"`* A file name specifying the file in the invocation-log directory for an invocation-specific `--dump-plain-graph` option. + - *`"--dump-artifacts-to-build"`* A file name specifying the + file in the invocation-log directory for the invocation-specific + `--dump-artifacts-to-build` option. - *`"--dump-artifacts"`* A file name specifying in the file in the invocation-log directory for the invocation-specific `--dump-artifacts` option. diff --git a/src/other_tools/just_mr/cli.hpp b/src/other_tools/just_mr/cli.hpp index df952957..defb7be6 100644 --- a/src/other_tools/just_mr/cli.hpp +++ b/src/other_tools/just_mr/cli.hpp @@ -98,6 +98,7 @@ struct InvocationLogArguments { std::optional metadata{std::nullopt}; std::optional graph_file{std::nullopt}; std::optional graph_file_plain{std::nullopt}; + std::optional dump_artifacts_to_build{std::nullopt}; std::optional dump_artifacts{std::nullopt}; std::optional profile{std::nullopt}; }; diff --git a/src/other_tools/just_mr/launch.cpp b/src/other_tools/just_mr/launch.cpp index 7d2bdf25..0a061031 100644 --- a/src/other_tools/just_mr/launch.cpp +++ b/src/other_tools/just_mr/launch.cpp @@ -326,6 +326,20 @@ auto CallJust(std::optional const& config_file, cmd.emplace_back("--dump-plain-graph"); cmd.emplace_back(*log_dir / *invocation_log.graph_file_plain); } + if (invocation_log.dump_artifacts_to_build) { + if (not IsValidFileName(*invocation_log.dump_artifacts_to_build)) { + Logger::Log( + LogLevel::Error, + "Invalid file name for option --dump-artifacts_to_build: " + "{}", + nlohmann::json(*invocation_log.dump_artifacts_to_build) + .dump()); + std::exit(kExitClargsError); + } + cmd.emplace_back("--dump-artifacts-to-build"); + cmd.emplace_back(*log_dir / + *invocation_log.dump_artifacts_to_build); + } if (does_build and invocation_log.dump_artifacts) { if (not IsValidFileName(*invocation_log.dump_artifacts)) { Logger::Log( diff --git a/src/other_tools/just_mr/rc.cpp b/src/other_tools/just_mr/rc.cpp index 7d7f6f5a..41b7e77e 100644 --- a/src/other_tools/just_mr/rc.cpp +++ b/src/other_tools/just_mr/rc.cpp @@ -619,6 +619,12 @@ namespace { if (graph_file_plain->IsString()) { clargs->invocation_log.graph_file = graph_file_plain->String(); } + auto dump_artifacts_to_build = invocation_log->Get( + "--dump-artifacts-to-build", Expression::none_t{}); + if (dump_artifacts_to_build->IsString()) { + clargs->invocation_log.dump_artifacts_to_build = + dump_artifacts_to_build->String(); + } auto dump_artifacts = invocation_log->Get("--dump-artifacts", Expression::none_t{}); if (dump_artifacts->IsString()) { -- cgit v1.2.3