summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md6
-rw-r--r--share/man/just.1.org3
-rw-r--r--src/buildtool/common/cli.hpp12
-rw-r--r--src/buildtool/main/main.cpp13
4 files changed, 21 insertions, 13 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a3725cac..a638e41f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -12,6 +12,12 @@ A feature release on top of `1.0.0`, backwards compatible.
and mutual TLS
- `just-mr` is now available as C++ binary and supports fetching in parallel
+### Important changes
+
+- The option `-D` now accumulates instead of ignoring all but the
+ latest occurence. This is an incompatible change of the command
+ line, but not affecting the backwards compatibility of the build.
+
### Other changes
- `just analyse` now supports a new option `--dump-export-targets`
diff --git a/share/man/just.1.org b/share/man/just.1.org
index a08eecbc..47f9ccb2 100644
--- a/share/man/just.1.org
+++ b/share/man/just.1.org
@@ -292,7 +292,8 @@ the original remote build execution protocol.
Defines, via an in-line JSON object a configuration to overlay
(in the sense of ~map_union~) to the configuration
obtained by the *--config* option. If *-D* is given several times,
- only the latest *-D* option is taken.\\
+ the *-D* options overlay in the order they are given on the command
+ line.\\
Supported by: analyse|build|describe|install|rebuild.
*--request-action-input* ACTION\\
diff --git a/src/buildtool/common/cli.hpp b/src/buildtool/common/cli.hpp
index 865ef500..da67d8e7 100644
--- a/src/buildtool/common/cli.hpp
+++ b/src/buildtool/common/cli.hpp
@@ -51,7 +51,7 @@ struct LogArguments {
/// \brief Arguments required for analysing targets.
struct AnalysisArguments {
std::optional<std::size_t> expression_log_limit{};
- std::string defines{};
+ std::vector<std::string> defines{};
std::filesystem::path config_file{};
std::optional<nlohmann::json> target{};
std::optional<std::string> request_action_input{};
@@ -218,12 +218,14 @@ static inline auto SetupAnalysisArguments(
"in error messages (Default {})",
Evaluator::kDefaultExpressionLogLimit))
->type_name("NUM");
- app->add_option(
+ app->add_option_function<std::string>(
"-D,--defines",
- clargs->defines,
+ [clargs](auto const& d) { clargs->defines.emplace_back(d); },
"Define an overlay configuration via an in-line JSON object."
- "Latest wins.")
- ->type_name("JSON");
+ " Multiple options overlay.")
+ ->type_name("JSON")
+ ->trigger_on_parse(); // run callback on all instances while parsing,
+ // not after all parsing is done
app->add_option(
"-c,--config", clargs->config_file, "Path to configuration file.")
->type_name("PATH");
diff --git a/src/buildtool/main/main.cpp b/src/buildtool/main/main.cpp
index 98812abd..869ed146 100644
--- a/src/buildtool/main/main.cpp
+++ b/src/buildtool/main/main.cpp
@@ -487,21 +487,20 @@ void SetupHashFunction() {
}
}
- if (not clargs.defines.empty()) {
+ for (auto const& s : clargs.defines) {
try {
- auto map =
- Expression::FromJson(nlohmann::json::parse(clargs.defines));
+ auto map = Expression::FromJson(nlohmann::json::parse(s));
if (not map->IsMap()) {
Logger::Log(LogLevel::Error,
- "Defines {} does not contain a map.",
- clargs.defines);
+ "Defines entry {} does not contain a map.",
+ nlohmann::json(s).dump());
std::exit(kExitFailure);
}
config = config.Update(map);
} catch (std::exception const& e) {
Logger::Log(LogLevel::Error,
- "Parsing defines {} failed with error:\n{}",
- clargs.defines,
+ "Parsing defines entry {} failed with error:\n{}",
+ nlohmann::json(s).dump(),
e.what());
std::exit(kExitFailure);
}