summaryrefslogtreecommitdiff
path: root/src/buildtool/execution_api/local/local_action.cpp
diff options
context:
space:
mode:
authorOliver Reiche <oliver.reiche@huawei.com>2023-11-21 14:20:24 +0100
committerOliver Reiche <oliver.reiche@huawei.com>2023-11-22 16:51:47 +0100
commitbab0d949d51fe4f10c8d492083427d514206cb63 (patch)
tree4c341f495d4c7f9233ef1e21a0b75b5035bce4be /src/buildtool/execution_api/local/local_action.cpp
parentaa330e53132ee01981d21d5d66f39c0d808cf418 (diff)
downloadjustbuild-bab0d949d51fe4f10c8d492083427d514206cb63.tar.gz
LocalAction: Fix staging of empty trees
Diffstat (limited to 'src/buildtool/execution_api/local/local_action.cpp')
-rw-r--r--src/buildtool/execution_api/local/local_action.cpp21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/buildtool/execution_api/local/local_action.cpp b/src/buildtool/execution_api/local/local_action.cpp
index badc62e5..1d964533 100644
--- a/src/buildtool/execution_api/local/local_action.cpp
+++ b/src/buildtool/execution_api/local/local_action.cpp
@@ -176,8 +176,13 @@ auto LocalAction::Run(bazel_re::Digest const& action_id) const noexcept
return std::nullopt;
}
-auto LocalAction::StageFile(std::filesystem::path const& target_path,
- Artifact::ObjectInfo const& info) const -> bool {
+auto LocalAction::StageInput(std::filesystem::path const& target_path,
+ Artifact::ObjectInfo const& info) const noexcept
+ -> bool {
+ if (IsTreeObject(info.type)) {
+ return FileSystemManager::CreateDirectory(target_path);
+ }
+
auto blob_path =
storage_->CAS().BlobPath(info.digest, IsExecutableObject(info.type));
@@ -204,19 +209,19 @@ auto LocalAction::StageFile(std::filesystem::path const& target_path,
FileSystemManager::CreateFileHardlink(*blob_path, target_path);
}
-auto LocalAction::StageInputFiles(
+auto LocalAction::StageInputs(
std::filesystem::path const& exec_path) const noexcept -> bool {
if (FileSystemManager::IsRelativePath(exec_path)) {
return false;
}
- auto infos =
- storage_->CAS().RecursivelyReadTreeLeafs(root_digest_, exec_path);
+ auto infos = storage_->CAS().RecursivelyReadTreeLeafs(
+ root_digest_, exec_path, /*include_trees=*/true);
if (not infos) {
return false;
}
for (std::size_t i{}; i < infos->first.size(); ++i) {
- if (not StageFile(infos->first.at(i), infos->second.at(i))) {
+ if (not StageInput(infos->first.at(i), infos->second.at(i))) {
return false;
}
}
@@ -237,8 +242,8 @@ auto LocalAction::CreateDirectoryStructure(
return false;
}
- // stage input files to execution directory
- if (not StageInputFiles(exec_path)) {
+ // stage inputs (files, leaf trees) to execution directory
+ if (not StageInputs(exec_path)) {
logger_.Emit(LogLevel::Error,
"failed to stage input files to exec_path");
return false;