summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md3
-rw-r--r--share/man/just-mrrc.5.md17
-rw-r--r--src/other_tools/just_mr/TARGETS1
-rw-r--r--src/other_tools/just_mr/rc.cpp46
4 files changed, 66 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index fce863e3..e9b1fb0b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -27,6 +27,9 @@ A feature release on top of `1.2.0`, backwards compatible.
- When `just-mr` executes the action to generate the desired tree of a
`"git tree"` repository, it can be specified that certain variables
of the environment can be inherited.
+- The just-mr rc file now supports a field `"rc files"` to include
+ other rc files given by location objects; in particular, it is
+ possible to include rc files committed to the workspace.
- Support for fetching archives from FTP and TFTP was added to `just-mr`
if it was built with bundled curl. For package builds, libcurl has
enabled whatever the distro considers suitable.
diff --git a/share/man/just-mrrc.5.md b/share/man/just-mrrc.5.md
index 85c2ce75..021e1126 100644
--- a/share/man/just-mrrc.5.md
+++ b/share/man/just-mrrc.5.md
@@ -131,13 +131,28 @@ The just-mrrc is given by a JSON object.
corresponding subcommand, these strings are prefixed to the **`just`**
argument vector, 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
+ an existing file, this file is read as an additional rc file
+ overlaying the given rc file in the specified order; the value
+ of `"rc files"` in the overlaying files is ignored.
+ In this way, an rc file commited to a repository can be allowed
+ to set a sensible configuration, remote-execution and serve end
+ points, etc. This is particularly useful when simultaneously
+ working on several projects with different settings.
+
+
EXAMPLE
=======
An example just-mrrc file could look like the following:
``` jsonc
-{ "config lookup order":
+{ "rc files":
+ [ {"root": "workspace", "path": "rc.json"}
+ , {"root": "workspace", "path": "etc/rc.json"}
+ ]
+, "config lookup order":
[ {"root": "workspace", "path": "repos.json"}
, {"root": "workspace", "path": "etc/repos.json"}
, {"root": "home", "path": ".just-repos.json"}
diff --git a/src/other_tools/just_mr/TARGETS b/src/other_tools/just_mr/TARGETS
index 2cfef1dd..359b1443 100644
--- a/src/other_tools/just_mr/TARGETS
+++ b/src/other_tools/just_mr/TARGETS
@@ -214,6 +214,7 @@
, ["src/buildtool/logging", "logging"]
, ["src/buildtool/logging", "log_level"]
, "exit_codes"
+ , "rc_merge"
]
, "stage": ["src", "other_tools", "just_mr"]
}
diff --git a/src/other_tools/just_mr/rc.cpp b/src/other_tools/just_mr/rc.cpp
index a7894d53..320efca7 100644
--- a/src/other_tools/just_mr/rc.cpp
+++ b/src/other_tools/just_mr/rc.cpp
@@ -22,6 +22,7 @@
#include "src/buildtool/logging/log_sink_file.hpp"
#include "src/buildtool/logging/logger.hpp"
#include "src/other_tools/just_mr/exit_codes.hpp"
+#include "src/other_tools/just_mr/rc_merge.hpp"
namespace {
@@ -179,6 +180,51 @@ namespace {
gsl::not_null<CommandLineArguments*> const& clargs)
-> std::optional<std::filesystem::path> {
Configuration rc_config = ObtainRCConfig(clargs);
+
+ // Merge in the rc-files to overlay
+ auto extra_rc_files = rc_config["rc files"];
+ if (not extra_rc_files->IsNone()) {
+ if (not extra_rc_files->IsList()) {
+ Logger::Log(
+ LogLevel::Error,
+ "'rc files' has to be a list of location objects, but found {}",
+ extra_rc_files->ToString());
+ std::exit(kExitConfigError);
+ }
+ for (auto const& entry : extra_rc_files->List()) {
+ auto extra_rc_location = ReadLocation(
+ entry, clargs->common.just_mr_paths->workspace_root);
+ if (extra_rc_location) {
+ auto const& extra_rc_path = extra_rc_location->first;
+ if (FileSystemManager::IsFile(extra_rc_path)) {
+ Configuration extra_rc_config{};
+ try {
+ std::ifstream fs(extra_rc_path);
+ auto map =
+ Expression::FromJson(nlohmann::json::parse(fs));
+ if (not map->IsMap()) {
+ Logger::Log(LogLevel::Error,
+ "In extra RC file {}: expected an "
+ "object but found:\n{}",
+ extra_rc_path.string(),
+ map->ToString());
+ std::exit(kExitConfigError);
+ }
+ extra_rc_config = Configuration{map};
+ } catch (std::exception const& e) {
+ Logger::Log(LogLevel::Error,
+ "Parsing extra RC file {} as JSON failed "
+ "with error:\n{}",
+ extra_rc_path.string(),
+ e.what());
+ std::exit(kExitConfigError);
+ }
+ rc_config = MergeMRRC(rc_config, extra_rc_config);
+ }
+ }
+ }
+ }
+
// read local build root; overwritten if user provided it already
if (not clargs->common.just_mr_paths->root) {
auto build_root =