summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOliver Reiche <oliver.reiche@huawei.com>2025-05-06 10:50:09 +0200
committerOliver Reiche <oliver.reiche@huawei.com>2025-06-24 12:56:57 +0200
commit778656381c8c05d88453140612b4053dbc2ce787 (patch)
tree0aef34d872a5fdf3cc565398da3d2be0dcf808f4
parent5e9234326754cc83140ecaae798c31fe3ec5c165 (diff)
downloadjustbuild-778656381c8c05d88453140612b4053dbc2ce787.tar.gz
Executor: Verify types of output artifacts
... as Justbuild has a strict separation between output files and output directories, but the RBE protocol does not necessarily maintain such a separation and therefore does not perform such a verification.
-rw-r--r--src/buildtool/execution_engine/executor/executor.hpp21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/buildtool/execution_engine/executor/executor.hpp b/src/buildtool/execution_engine/executor/executor.hpp
index 5f5c2e92..85d01732 100644
--- a/src/buildtool/execution_engine/executor/executor.hpp
+++ b/src/buildtool/execution_engine/executor/executor.hpp
@@ -643,7 +643,8 @@ class ExecutorImpl {
return api.UploadTree(artifacts);
}
/// \brief Check that all outputs expected from the action description
- /// are present in the artifacts map
+ /// are present in the artifacts map and of the expected type
+ template <bool kIsTree = false>
[[nodiscard]] static auto CheckOutputsExist(
IExecutionResponse::ArtifactInfos const& artifacts,
std::vector<Action::LocalPath> const& outputs,
@@ -652,8 +653,18 @@ class ExecutorImpl {
outputs.begin(),
outputs.end(),
[&artifacts, &base](Action::LocalPath const& output) {
- return artifacts.contains(
- RebasePathStringRelativeTo(base, output));
+ auto it =
+ artifacts.find(RebasePathStringRelativeTo(base, output));
+ if (it != artifacts.end()) {
+ auto const& type = it->second.type;
+ if constexpr (kIsTree) {
+ return IsTreeObject(type) or IsSymlinkObject(type);
+ }
+ else {
+ return IsFileObject(type) or IsSymlinkObject(type);
+ }
+ }
+ return false;
});
}
@@ -715,9 +726,9 @@ class ExecutorImpl {
std::sort(output_dirs.begin(), output_dirs.end());
if (artifacts.value()->empty() or
- not CheckOutputsExist(
+ not CheckOutputsExist</*kIsTree=*/false>(
*artifacts.value(), output_files, action->Content().Cwd()) or
- not CheckOutputsExist(
+ not CheckOutputsExist</*kIsTree=*/true>(
*artifacts.value(), output_dirs, action->Content().Cwd())) {
logger.Emit(LogLevel::Error, [&]() {
std::ostringstream message{};