From 3c2185bf17b1c1a631366aa11591da3e3beb51eb Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Tue, 7 Mar 2023 14:28:56 +0100 Subject: Just-mr: Add --local-launcher option Also update just-mr section-1 man page --- share/man/just-mr.1.org | 8 ++++++++ src/other_tools/just_mr/cli.hpp | 13 +++++++++++++ src/other_tools/just_mr/main.cpp | 8 ++++++++ src/other_tools/just_mr/utils.hpp | 17 +++++++++-------- 4 files changed, 38 insertions(+), 8 deletions(-) diff --git a/share/man/just-mr.1.org b/share/man/just-mr.1.org index 978ec306..8f8a1e2b 100644 --- a/share/man/just-mr.1.org +++ b/share/man/just-mr.1.org @@ -57,6 +57,11 @@ See *just-mr-repository-config(5)* for more details on the input format. options overwrites any values set in the *just-mrrc(5)* file.\\ Default: file path ~".just-local.json"~ in user's home directory. + *--local-launcher* \\ + JSON array with the list of strings representing the launcher to + prepend actions' commands before being executed locally.\\ + Default: ~["env", "--"]~. + *--distdir* PATH\\ Directory to look for distfiles before fetching. If given, this will be the first place distfiles are looked for. This option can be given multiple times @@ -173,6 +178,9 @@ All logging arguments given to ~just-mr~ are passed to ~just~ as early arguments If log files are provided, an unconditional ~--log-append~ argument is passed as well, which ensures no log messages will get overwritten. +The ~--local-launcher~ argument is passed to ~just~ as early argument for those +/known/ subcommands that accept it (build, install, rebuild). + ** version|describe|analyse|build|install|install-cas|rebuild|gc This subcommand is the explicit way of specifying /known/ just subcommands and diff --git a/src/other_tools/just_mr/cli.hpp b/src/other_tools/just_mr/cli.hpp index 2174c331..c9a36387 100644 --- a/src/other_tools/just_mr/cli.hpp +++ b/src/other_tools/just_mr/cli.hpp @@ -37,6 +37,7 @@ struct MultiRepoCommonArguments { std::optional checkout_locations_file{std::nullopt}; std::vector explicit_distdirs{}; JustMR::PathsPtr just_mr_paths = std::make_shared(); + std::optional> local_launcher{std::nullopt}; std::optional just_path{std::nullopt}; std::optional main{std::nullopt}; std::optional rc_path{std::nullopt}; @@ -99,6 +100,18 @@ static inline void SetupMultiRepoCommonArguments( }, "Specification file for checkout locations.") ->type_name("CHECKOUT_LOCATION"); + app->add_option_function( + "--local-launcher", + [clargs](auto const& launcher_raw) { + clargs->local_launcher = + nlohmann::json::parse(launcher_raw) + .template get>(); + }, + "JSON array with the list of strings representing the launcher to " + "prepend actions' commands before being executed locally.") + ->type_name("JSON") + ->run_callback_for_default() + ->default_val(nlohmann::json{"env", "--"}.dump()); app->add_option_function( "--distdir", [clargs](auto const& distdir_raw) { diff --git a/src/other_tools/just_mr/main.cpp b/src/other_tools/just_mr/main.cpp index 7157034d..b479e1f2 100644 --- a/src/other_tools/just_mr/main.cpp +++ b/src/other_tools/just_mr/main.cpp @@ -1241,6 +1241,7 @@ void DefaultReachableRepositories( bool use_config{false}; bool use_build_root{false}; + bool use_launcher{false}; std::optional mr_config_path{std::nullopt}; if (subcommand and kKnownJustSubcommands.contains(*subcommand)) { @@ -1256,6 +1257,7 @@ void DefaultReachableRepositories( } } use_build_root = kKnownJustSubcommands.at(*subcommand).build_root; + use_launcher = kKnownJustSubcommands.at(*subcommand).launch; } // build just command std::vector cmd = {arguments.common.just_path->string()}; @@ -1270,6 +1272,12 @@ void DefaultReachableRepositories( cmd.emplace_back("--local-build-root"); cmd.emplace_back(*arguments.common.just_mr_paths->root); } + if (use_launcher and arguments.common.local_launcher and + not arguments.common.local_launcher->empty()) { + cmd.emplace_back("--local-launcher"); + cmd.emplace_back( + nlohmann::json(*arguments.common.local_launcher).dump()); + } // forward logging arguments if (not arguments.log.log_files.empty()) { cmd.emplace_back("--log-append"); diff --git a/src/other_tools/just_mr/utils.hpp b/src/other_tools/just_mr/utils.hpp index f5cc7de9..bfd81f16 100644 --- a/src/other_tools/just_mr/utils.hpp +++ b/src/other_tools/just_mr/utils.hpp @@ -48,18 +48,19 @@ std::vector const kTakeOver = {"bindings", struct JustSubCmdFlags { bool config; bool build_root; + bool launch; }; // ordered, so that we have replicability std::map const kKnownJustSubcommands{ - {"version", {false /*config*/, false /*build_root*/}}, - {"describe", {true /*config*/, false /*build_root*/}}, - {"analyse", {true /*config*/, true /*build_root*/}}, - {"build", {true /*config*/, true /*build_root*/}}, - {"install", {true /*config*/, true /*build_root*/}}, - {"rebuild", {true /*config*/, true /*build_root*/}}, - {"install-cas", {false /*config*/, true /*build_root*/}}, - {"gc", {false /*config*/, true /*build_root*/}}}; + {"version", {false /*config*/, false /*build_root*/, false /*launch*/}}, + {"describe", {true /*config*/, false /*build_root*/, false /*launch*/}}, + {"analyse", {true /*config*/, true /*build_root*/, false /*launch*/}}, + {"build", {true /*config*/, true /*build_root*/, true /*launch*/}}, + {"install", {true /*config*/, true /*build_root*/, true /*launch*/}}, + {"rebuild", {true /*config*/, true /*build_root*/, true /*launch*/}}, + {"install-cas", {false /*config*/, true /*build_root*/, false /*launch*/}}, + {"gc", {false /*config*/, true /*build_root*/, false /*launch*/}}}; nlohmann::json const kDefaultConfigLocations = nlohmann::json::array( {{{"root", "workspace"}, {"path", "repos.json"}}, -- cgit v1.2.3