summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKlaus Aehlig <klaus.aehlig@huawei.com>2023-06-21 10:27:52 +0200
committerKlaus Aehlig <klaus.aehlig@huawei.com>2023-06-22 17:58:50 +0200
commitf0746d90ac95ff2cad70617da5fa83dde38b911c (patch)
treec187ece5994aabc3731f6d4d4a2c1ae2858455d9
parent37e5115503299bc75cd0ad439b274d009a5a7045 (diff)
downloadjustbuild-f0746d90ac95ff2cad70617da5fa83dde38b911c.tar.gz
generic target: support execution properties
-rw-r--r--src/buildtool/build_engine/target_map/built_in_rules.cpp39
1 files changed, 38 insertions, 1 deletions
diff --git a/src/buildtool/build_engine/target_map/built_in_rules.cpp b/src/buildtool/build_engine/target_map/built_in_rules.cpp
index aca7cc6d..257006f5 100644
--- a/src/buildtool/build_engine/target_map/built_in_rules.cpp
+++ b/src/buildtool/build_engine/target_map/built_in_rules.cpp
@@ -42,6 +42,7 @@ auto const kGenericRuleFields =
"cmds",
"deps",
"env",
+ "execution properties",
"tainted",
"timeout scaling",
"type",
@@ -1056,6 +1057,42 @@ void GenericRuleWithDeps(
return;
}
+ auto props_exp = desc->ReadOptionalExpression("execution properties",
+ Expression::kEmptyMapExpr);
+ if (not props_exp) {
+ return;
+ }
+ auto props_val = props_exp.Evaluate(
+ param_config, string_fields_fcts, [&logger](auto const& msg) {
+ (*logger)(
+ fmt::format("While evaluating execution properties:\n{}", msg),
+ true);
+ });
+ if (not props_val) {
+ return;
+ }
+ if (props_val->IsNone()) {
+ props_val = Expression::kEmptyMap;
+ }
+ if (not props_val->IsMap()) {
+ (*logger)(fmt::format("execution properties has to evaluate to a map "
+ "(or null for default), but found {}",
+ props_val->ToString()),
+ true);
+ return;
+ }
+ for (auto const& [prop_name, prop_val] : props_val->Map()) {
+ if (not prop_val->IsString()) {
+ (*logger)(
+ fmt::format("execution properties has to evaluate to a map (or "
+ "null for default), but found {} for key {}",
+ nlohmann::json(prop_name).dump(),
+ prop_val->ToString()),
+ true);
+ return;
+ }
+ }
+
// Construct inputs; in case of conflicts, artifacts take precedence
// over runfiles.
auto inputs = ExpressionPtr{Expression::map_t{}};
@@ -1075,7 +1112,7 @@ void GenericRuleWithDeps(
std::nullopt,
false,
scale_val->IsNumber() ? scale_val->Number() : 1.0,
- Expression::kEmptyMap,
+ props_val,
inputs);
auto action_identifier = action->Id();
Expression::map_t::underlying_map_t artifacts;