diff options
author | Klaus Aehlig <klaus.aehlig@huawei.com> | 2023-05-25 14:48:25 +0200 |
---|---|---|
committer | Klaus Aehlig <klaus.aehlig@huawei.com> | 2023-05-31 14:14:25 +0200 |
commit | 6e6516f741771076f9210531a37ffcd30e6ec636 (patch) | |
tree | a8518f677ca8506baa084bb80831ba6c467b1955 /src/buildtool/build_engine/target_map/target_map.cpp | |
parent | eb6c1fab20327379f318b5f81b940a88627cec8e (diff) | |
download | justbuild-6e6516f741771076f9210531a37ffcd30e6ec636.tar.gz |
ACTION constructor: accept "timeout scaling"
Allow rules to set the timeout-scaling factor for their actions to
indicate that some actions are expected to take longer than others,
e.g., because they call a foreign build tool or are a very complex
end-to-end test.
Diffstat (limited to 'src/buildtool/build_engine/target_map/target_map.cpp')
-rw-r--r-- | src/buildtool/build_engine/target_map/target_map.cpp | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/src/buildtool/build_engine/target_map/target_map.cpp b/src/buildtool/build_engine/target_map/target_map.cpp index 13825148..c61e3670 100644 --- a/src/buildtool/build_engine/target_map/target_map.cpp +++ b/src/buildtool/build_engine/target_map/target_map.cpp @@ -551,15 +551,25 @@ void withDependencies( } } bool no_cache = not no_cache_exp->List().empty(); - auto action = - BuildMaps::Target::Utils::createAction(outputs, - output_dirs, - std::move(cmd), - env_exp, - may_fail, - no_cache, - 1.0, - inputs_exp); + auto timeout_scale_exp = + eval(expr->Get("timeout scaling", Expression::kOne), env); + if (not(timeout_scale_exp->IsNumber() or + timeout_scale_exp->IsNone())) { + throw Evaluator::EvaluationError{ + fmt::format("timeout scaling has to be number (or null " + "for default), but found {}", + timeout_scale_exp->ToString())}; + } + auto action = BuildMaps::Target::Utils::createAction( + outputs, + output_dirs, + std::move(cmd), + env_exp, + may_fail, + no_cache, + timeout_scale_exp->IsNumber() ? timeout_scale_exp->Number() + : 1.0, + inputs_exp); auto action_id = action->Id(); actions.emplace_back(std::move(action)); for (auto const& out : outputs) { |