summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKlaus Aehlig <klaus.aehlig@huawei.com>2024-01-30 16:07:49 +0100
committerKlaus Aehlig <klaus.aehlig@huawei.com>2024-01-31 10:20:01 +0100
commit8a4a900f93a704f18d5489b682508840a8cda179 (patch)
tree08dbac7941e596c8ab5a3eae2808fc8c4bee8d25
parente2168c51eb9d29542b32aaf7bca24595d0745749 (diff)
downloadjustbuild-8a4a900f93a704f18d5489b682508840a8cda179.tar.gz
just-mrrc: support remote-execution properties
While just-mr does not use remote-execution properties, it is still useful to have those as a separate entry in the rc file. With rc-file delegation, this gives committed rc files an easy way to specify the image to be used without having to set all the remaining arguments for the various just subcommands in "just args".
-rw-r--r--share/man/just-mrrc.5.md8
-rw-r--r--src/other_tools/just_mr/cli.hpp5
-rw-r--r--src/other_tools/just_mr/launch.cpp11
-rw-r--r--src/other_tools/just_mr/launch.hpp1
-rw-r--r--src/other_tools/just_mr/main.cpp1
-rw-r--r--src/other_tools/just_mr/rc.cpp24
-rw-r--r--src/other_tools/just_mr/utils.hpp27
7 files changed, 67 insertions, 10 deletions
diff --git a/share/man/just-mrrc.5.md b/share/man/just-mrrc.5.md
index 021e1126..22820078 100644
--- a/share/man/just-mrrc.5.md
+++ b/share/man/just-mrrc.5.md
@@ -118,6 +118,11 @@ The just-mrrc is given by a JSON object.
Each subkey value can be overwritten by its corresponding command-line
argument.
+ - The value for the key *`"remote-execution properties"`*, if
+ provided, has to be a list of strings. Each entry is forwarded
+ as `--remote-execution-property` to the invocation of the build
+ tool, if **`just-mr`** is used as a launcher.
+
- The value for the key *`"just files"`* is a JSON object. The keys correspond
to options that some **`just`** subcommands accept and require a file as
argument. For each key, the value is a list of location objects. When
@@ -129,7 +134,8 @@ The just-mrrc is given by a JSON object.
- The value for the key *`"just args"`* is a JSON object. Its keys are
**`just`** subcommands and its value is a JSON list of strings. For the
corresponding subcommand, these strings are prefixed to the **`just`**
- argument vector, if **`just-mr`** is used as a launcher.
+ argument vector (after all other options provided through the rc file),
+ if **`just-mr`** is used as a launcher.
- The value for the key *`"rc files"`*, if given, is a list of
location objects. For those location objects that refer to
diff --git a/src/other_tools/just_mr/cli.hpp b/src/other_tools/just_mr/cli.hpp
index bcd5302a..1a77bc62 100644
--- a/src/other_tools/just_mr/cli.hpp
+++ b/src/other_tools/just_mr/cli.hpp
@@ -92,6 +92,10 @@ struct MultiRepoRemoteAuthArguments {
std::optional<std::filesystem::path> tls_client_key{std::nullopt};
};
+struct ForwardOnlyArguments {
+ std::vector<std::string> remote_execution_properties{};
+};
+
enum class SubCommand {
kUnknown,
kMRVersion,
@@ -112,6 +116,7 @@ struct CommandLineArguments {
MultiRepoUpdateArguments update;
MultiRepoJustSubCmdsArguments just_cmd;
MultiRepoRemoteAuthArguments auth;
+ ForwardOnlyArguments launch_fwd;
};
static inline void SetupMultiRepoCommonArguments(
diff --git a/src/other_tools/just_mr/launch.cpp b/src/other_tools/just_mr/launch.cpp
index f8f14659..7a7975e7 100644
--- a/src/other_tools/just_mr/launch.cpp
+++ b/src/other_tools/just_mr/launch.cpp
@@ -35,6 +35,7 @@ auto CallJust(std::optional<std::filesystem::path> const& config_file,
MultiRepoJustSubCmdsArguments const& just_cmd_args,
MultiRepoLogArguments const& log_args,
MultiRepoRemoteAuthArguments const& auth_args,
+ ForwardOnlyArguments const& launch_fwd,
bool forward_build_root,
std::string multi_repo_tool_name) -> int {
// check if subcmd_name can be taken from additional args
@@ -50,6 +51,7 @@ auto CallJust(std::optional<std::filesystem::path> const& config_file,
bool use_launcher{false};
bool supports_defines{false};
bool supports_remote{false};
+ bool supports_remote_properties{false};
bool supports_serve{false};
bool supports_dispatch{false};
bool supports_cacert{false};
@@ -89,6 +91,8 @@ auto CallJust(std::optional<std::filesystem::path> const& config_file,
use_launcher = kKnownJustSubcommands.at(*subcommand).launch;
supports_defines = kKnownJustSubcommands.at(*subcommand).defines;
supports_remote = kKnownJustSubcommands.at(*subcommand).remote;
+ supports_remote_properties =
+ kKnownJustSubcommands.at(*subcommand).remote_props;
supports_serve = kKnownJustSubcommands.at(*subcommand).serve;
supports_dispatch = kKnownJustSubcommands.at(*subcommand).dispatch;
supports_cacert = kKnownJustSubcommands.at(*subcommand).cacert;
@@ -190,6 +194,13 @@ auto CallJust(std::optional<std::filesystem::path> const& config_file,
cmd.emplace_back(auth_args.tls_client_key->string());
}
}
+ // forward-only arguments, still to come before the just-arguments
+ if (supports_remote_properties) {
+ for (auto const& prop : launch_fwd.remote_execution_properties) {
+ cmd.emplace_back("--remote-execution-property");
+ cmd.emplace_back(prop);
+ }
+ }
// add args read from just-mrrc
if (subcommand and just_cmd_args.just_args.contains(*subcommand)) {
for (auto const& subcmd_arg : just_cmd_args.just_args.at(*subcommand)) {
diff --git a/src/other_tools/just_mr/launch.hpp b/src/other_tools/just_mr/launch.hpp
index 11559ffe..0560f42e 100644
--- a/src/other_tools/just_mr/launch.hpp
+++ b/src/other_tools/just_mr/launch.hpp
@@ -28,6 +28,7 @@
MultiRepoJustSubCmdsArguments const& just_cmd_args,
MultiRepoLogArguments const& log_args,
MultiRepoRemoteAuthArguments const& auth_args,
+ ForwardOnlyArguments const& launch_fwd,
bool forward_build_root,
std::string multi_repo_tool_name) -> int;
diff --git a/src/other_tools/just_mr/main.cpp b/src/other_tools/just_mr/main.cpp
index e42f5eca..2d1c7328 100644
--- a/src/other_tools/just_mr/main.cpp
+++ b/src/other_tools/just_mr/main.cpp
@@ -333,6 +333,7 @@ auto main(int argc, char* argv[]) -> int {
arguments.just_cmd,
arguments.log,
arguments.auth,
+ arguments.launch_fwd,
forward_build_root,
my_name);
}
diff --git a/src/other_tools/just_mr/rc.cpp b/src/other_tools/just_mr/rc.cpp
index 209e4be6..8985c958 100644
--- a/src/other_tools/just_mr/rc.cpp
+++ b/src/other_tools/just_mr/rc.cpp
@@ -359,6 +359,30 @@ namespace {
clargs->just_cmd.just_args[cmd_name] = std::move(args);
}
}
+ // read remote-execution properties, used for extending the launch
+ // command-line (not settable on just-mr's command line).
+ auto re_props = rc_config["remote-execution properties"];
+ if (re_props.IsNotNull()) {
+ if (not re_props->IsList()) {
+ Logger::Log(LogLevel::Error,
+ "Configuration-file provided remote-execution "
+ "properties have to be a list of strings, but found {}",
+ re_props->ToString());
+ std::exit(kExitConfigError);
+ }
+ for (auto const& entry : re_props->List()) {
+ if (not entry->IsString()) {
+ Logger::Log(
+ LogLevel::Error,
+ "Configuration-file provided remote-execution properties "
+ "have to be a list of strings, but found entry {}",
+ entry->ToString());
+ std::exit(kExitConfigError);
+ }
+ clargs->launch_fwd.remote_execution_properties.emplace_back(
+ entry->String());
+ }
+ }
// read default for local launcher
if (not clargs->common.local_launcher) {
auto launcher = rc_config["local launcher"];
diff --git a/src/other_tools/just_mr/utils.hpp b/src/other_tools/just_mr/utils.hpp
index fa7c82b7..36a03ddf 100644
--- a/src/other_tools/just_mr/utils.hpp
+++ b/src/other_tools/just_mr/utils.hpp
@@ -45,15 +45,16 @@ std::vector<std::string> const kTakeOver = {"bindings",
"expression_file_name"};
struct JustSubCmdFlags {
- bool config; // requires setup
- bool build_root; // supports the local build root arg
- bool launch; // supports the local launcher arg
- bool defines; // supports defines arg
- bool remote; // supports remote exec args
- bool serve; // supports a serve endpoint
- bool dispatch; // supports dispatching of the remote-execution endpoint
- bool cacert; // supports CA cert arg
- bool client_auth; // supports client auth args
+ bool config; // requires setup
+ bool build_root; // supports the local build root arg
+ bool launch; // supports the local launcher arg
+ bool defines; // supports defines arg
+ bool remote; // supports remote exec args
+ bool remote_props; // supports remote-execution properties
+ bool serve; // supports a serve endpoint
+ bool dispatch; // supports dispatching of the remote-execution endpoint
+ bool cacert; // supports CA cert arg
+ bool client_auth; // supports client auth args
};
// ordered, so that we have replicability
@@ -64,6 +65,7 @@ std::map<std::string, JustSubCmdFlags> const kKnownJustSubcommands{
.launch = false,
.defines = false,
.remote = false,
+ .remote_props = false,
.serve = false,
.dispatch = false,
.cacert = false,
@@ -74,6 +76,7 @@ std::map<std::string, JustSubCmdFlags> const kKnownJustSubcommands{
.launch = false,
.defines = true,
.remote = false,
+ .remote_props = false,
.serve = false,
.dispatch = false,
.cacert = false,
@@ -84,6 +87,7 @@ std::map<std::string, JustSubCmdFlags> const kKnownJustSubcommands{
.launch = false,
.defines = true,
.remote = true,
+ .remote_props = true,
.serve = true,
.dispatch = true,
.cacert = false,
@@ -94,6 +98,7 @@ std::map<std::string, JustSubCmdFlags> const kKnownJustSubcommands{
.launch = true,
.defines = true,
.remote = true,
+ .remote_props = true,
.serve = true,
.dispatch = true,
.cacert = true,
@@ -104,6 +109,7 @@ std::map<std::string, JustSubCmdFlags> const kKnownJustSubcommands{
.launch = true,
.defines = true,
.remote = true,
+ .remote_props = true,
.serve = true,
.dispatch = true,
.cacert = true,
@@ -114,6 +120,7 @@ std::map<std::string, JustSubCmdFlags> const kKnownJustSubcommands{
.launch = true,
.defines = true,
.remote = true,
+ .remote_props = true,
.serve = true,
.dispatch = true,
.cacert = true,
@@ -124,6 +131,7 @@ std::map<std::string, JustSubCmdFlags> const kKnownJustSubcommands{
.launch = false,
.defines = false,
.remote = true,
+ .remote_props = false,
.serve = false,
.dispatch = false,
.cacert = true,
@@ -134,6 +142,7 @@ std::map<std::string, JustSubCmdFlags> const kKnownJustSubcommands{
.launch = false,
.defines = false,
.remote = false,
+ .remote_props = false,
.serve = false,
.dispatch = false,
.cacert = false,