summaryrefslogtreecommitdiff
path: root/src/buildtool/execution_api/local/local_action.cpp
diff options
context:
space:
mode:
authorKlaus Aehlig <klaus.aehlig@huawei.com>2024-08-01 10:26:13 +0200
committerKlaus Aehlig <klaus.aehlig@huawei.com>2024-08-01 19:00:47 +0200
commit03f948f4b10e916052a2234448b6658b80ee9143 (patch)
tree8eb0e2c26a31fd83fa0691b0d8fde55a15942a9d /src/buildtool/execution_api/local/local_action.cpp
parented71beee3e3a2bbfcba24281ad9e28a0f6df4054 (diff)
downloadjustbuild-03f948f4b10e916052a2234448b6658b80ee9143.tar.gz
Execution API: support cwd
... following the remote-execution standard that all output paths (but none of the input paths) are relative to the working directory. Therefore, the executor has to do the path translation. For our implementation of the API interface - the local API now handles cwd correctly, - the remote API forwards cwd correctly, and - the git API continues to report actions as not implemented.
Diffstat (limited to 'src/buildtool/execution_api/local/local_action.cpp')
-rw-r--r--src/buildtool/execution_api/local/local_action.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/buildtool/execution_api/local/local_action.cpp b/src/buildtool/execution_api/local/local_action.cpp
index aac6bb39..8cc1d242 100644
--- a/src/buildtool/execution_api/local/local_action.cpp
+++ b/src/buildtool/execution_api/local/local_action.cpp
@@ -82,6 +82,7 @@ class BuildCleanupAnchor {
auto LocalAction::Execute(Logger const* logger) noexcept
-> IExecutionResponse::Ptr {
+
auto do_cache = CacheEnabled(cache_flag_);
auto action = CreateActionDigest(root_digest_, not do_cache);
if (not action) {
@@ -174,7 +175,7 @@ auto LocalAction::Run(bazel_re::Digest const& action_id) const noexcept
SystemCommand system{"LocalExecution"};
auto const exit_code =
- system.Execute(cmdline, env_vars_, build_root, *exec_path);
+ system.Execute(cmdline, env_vars_, build_root / cwd_, *exec_path);
if (exit_code.has_value()) {
Output result{};
result.action.set_exit_code(*exit_code);
@@ -187,7 +188,7 @@ auto LocalAction::Run(bazel_re::Digest const& action_id) const noexcept
result.action.set_allocated_stderr_digest(digest_ptr);
}
- if (CollectAndStoreOutputs(&result.action, build_root)) {
+ if (CollectAndStoreOutputs(&result.action, build_root / cwd_)) {
if (cache_flag_ == CacheFlag::CacheOutput) {
if (not local_context_.storage->ActionCache().StoreResult(
action_id, result.action)) {
@@ -343,14 +344,15 @@ auto LocalAction::CreateDirectoryStructure(
};
return std::all_of(output_files_.begin(),
output_files_.end(),
- [&exec_path, &create_dir](auto const& local_path) {
- auto dir = (exec_path / local_path).parent_path();
+ [this, &exec_path, &create_dir](auto const& local_path) {
+ auto dir =
+ (exec_path / cwd_ / local_path).parent_path();
return create_dir(dir);
}) and
std::all_of(output_dirs_.begin(),
output_dirs_.end(),
- [&exec_path, &create_dir](auto const& local_path) {
- return create_dir(exec_path / local_path);
+ [this, &exec_path, &create_dir](auto const& local_path) {
+ return create_dir(exec_path / cwd_ / local_path);
});
}