summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2023-03-07 14:28:56 +0100
committerPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2023-03-07 15:10:00 +0100
commit3c2185bf17b1c1a631366aa11591da3e3beb51eb (patch)
treedbead789637df095b07214ea5b134ddf66fa6412
parent4181505a187a158d36a1845a4a796af5671cc7ab (diff)
downloadjustbuild-3c2185bf17b1c1a631366aa11591da3e3beb51eb.tar.gz
Just-mr: Add --local-launcher option
Also update just-mr section-1 man page
-rw-r--r--share/man/just-mr.1.org8
-rw-r--r--src/other_tools/just_mr/cli.hpp13
-rw-r--r--src/other_tools/just_mr/main.cpp8
-rw-r--r--src/other_tools/just_mr/utils.hpp17
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>\\
+ 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<std::filesystem::path> checkout_locations_file{std::nullopt};
std::vector<std::string> explicit_distdirs{};
JustMR::PathsPtr just_mr_paths = std::make_shared<JustMR::Paths>();
+ std::optional<std::vector<std::string>> local_launcher{std::nullopt};
std::optional<std::filesystem::path> just_path{std::nullopt};
std::optional<std::string> main{std::nullopt};
std::optional<std::filesystem::path> rc_path{std::nullopt};
@@ -100,6 +101,18 @@ static inline void SetupMultiRepoCommonArguments(
"Specification file for checkout locations.")
->type_name("CHECKOUT_LOCATION");
app->add_option_function<std::string>(
+ "--local-launcher",
+ [clargs](auto const& launcher_raw) {
+ clargs->local_launcher =
+ nlohmann::json::parse(launcher_raw)
+ .template get<std::vector<std::string>>();
+ },
+ "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<std::string>(
"--distdir",
[clargs](auto const& distdir_raw) {
clargs->explicit_distdirs.emplace_back(
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<std::filesystem::path> 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<std::string> 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<std::string> const kTakeOver = {"bindings",
struct JustSubCmdFlags {
bool config;
bool build_root;
+ bool launch;
};
// ordered, so that we have replicability
std::map<std::string, JustSubCmdFlags> 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"}},