From b2f795e0e05743a234587f3a1c32c9c1d4ec524f Mon Sep 17 00:00:00 2001 From: Klaus Aehlig Date: Fri, 2 Aug 2024 12:00:44 +0200 Subject: Actions with non-trivial cwd: add empty input tree, if required While our local action execution implicitly creates the specified cwd with the first output file or directory, this behaviour is not mandated by the remote-execution protocol. There, an action definition has to ensure that cwd is a directory implied by the input files. Achieve this, by adding an empty input directory at cwd if this can be done without creating tree conflicts. --- src/buildtool/build_engine/target_map/target_map.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/buildtool/build_engine/target_map/target_map.cpp') diff --git a/src/buildtool/build_engine/target_map/target_map.cpp b/src/buildtool/build_engine/target_map/target_map.cpp index 14d897b9..c7002270 100644 --- a/src/buildtool/build_engine/target_map/target_map.cpp +++ b/src/buildtool/build_engine/target_map/target_map.cpp @@ -513,7 +513,8 @@ void withDependencies( return eval(expr->Get("default", empty_list), env); }}, {"ACTION", - [&actions, &rule](auto&& eval, auto const& expr, auto const& env) { + [&actions, &rule, &trees]( + auto&& eval, auto const& expr, auto const& env) { auto const& empty_map_exp = Expression::kEmptyMapExpr; auto inputs_exp = eval(expr->Get("inputs", empty_map_exp), env); if (not inputs_exp->IsMap()) { @@ -605,6 +606,8 @@ void withDependencies( "cwd has to be a non-upwards relative path, but found {}", cwd_exp->ToString())}; } + auto final_inputs = BuildMaps::Target::Utils::add_dir_for( + cwd_exp->String(), inputs_exp, &trees); auto env_exp = eval(expr->Get("env", empty_map_exp), env); if (not env_exp->IsMap()) { throw Evaluator::EvaluationError{ @@ -716,7 +719,7 @@ void withDependencies( timeout_scale_exp->IsNumber() ? timeout_scale_exp->Number() : 1.0, execution_properties, - inputs_exp); + final_inputs); auto action_id = action->Id(); actions.emplace_back(std::move(action)); for (auto const& out : outputs) { -- cgit v1.2.3