summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKlaus Aehlig <klaus.aehlig@huawei.com>2023-08-10 09:55:57 +0200
committerKlaus Aehlig <klaus.aehlig@huawei.com>2023-08-11 14:32:28 +0200
commit79f400a1dd1da6710312e33844b1ae04bdc21832 (patch)
tree21e9f5ba7c2fbb753ffd68cd20b9aa68c79897d9
parent24124411aecdeebb4182ad857756265df0764363 (diff)
downloadjustbuild-79f400a1dd1da6710312e33844b1ae04bdc21832.tar.gz
just build: allow -P to reach into trees
-rw-r--r--src/buildtool/graph_traverser/TARGETS1
-rw-r--r--src/buildtool/graph_traverser/graph_traverser.hpp45
2 files changed, 46 insertions, 0 deletions
diff --git a/src/buildtool/graph_traverser/TARGETS b/src/buildtool/graph_traverser/TARGETS
index 04b5f746..b9911633 100644
--- a/src/buildtool/graph_traverser/TARGETS
+++ b/src/buildtool/graph_traverser/TARGETS
@@ -11,6 +11,7 @@
, ["src/buildtool/execution_api/local", "local"]
, ["src/buildtool/execution_api/remote", "bazel"]
, ["src/buildtool/execution_api/remote", "config"]
+ , ["src/buildtool/execution_api/utils", "subobject"]
, ["src/buildtool/file_system", "file_system_manager"]
, ["src/buildtool/file_system", "object_type"]
, ["src/buildtool/file_system", "jsonfs"]
diff --git a/src/buildtool/graph_traverser/graph_traverser.hpp b/src/buildtool/graph_traverser/graph_traverser.hpp
index 48f5c281..9f99e6f2 100644
--- a/src/buildtool/graph_traverser/graph_traverser.hpp
+++ b/src/buildtool/graph_traverser/graph_traverser.hpp
@@ -36,6 +36,7 @@
#include "src/buildtool/execution_api/local/local_api.hpp"
#include "src/buildtool/execution_api/remote/bazel/bazel_api.hpp"
#include "src/buildtool/execution_api/remote/config.hpp"
+#include "src/buildtool/execution_api/utils/subobject.hpp"
#include "src/buildtool/execution_engine/dag/dag.hpp"
#include "src/buildtool/execution_engine/executor/executor.hpp"
#include "src/buildtool/execution_engine/traverser/traverser.hpp"
@@ -675,6 +676,50 @@ class GraphTraverser {
return;
}
}
+ // Not directly an artifact, hence check if the path is contained in
+ // some artifact
+ auto target_path = ToNormalPath(std::filesystem::path{
+ *clargs_.build.print_to_stdout})
+ .relative_path();
+ auto remote = GetRemoteApi();
+ for (size_t i = 0; i < paths.size(); i++) {
+ auto const& path = paths[i];
+ auto relpath = target_path.lexically_relative(path);
+ if ((not relpath.empty()) and *relpath.begin() != "..") {
+ Logger::Log(
+ LogLevel::Info,
+ "'{}' not a direct logical path of the specified "
+ "target; will take subobject '{}' of '{}'",
+ *(clargs_.build.print_to_stdout),
+ relpath.string(),
+ path.string());
+ auto info = artifacts[i]->Content().Info();
+ if (info) {
+ auto new_info =
+ RetrieveSubPathId(*info, remote, relpath);
+ if (new_info) {
+ if (not remote_api_->RetrieveToFds(
+ {*new_info},
+ {dup(fileno(stdout))},
+ /*raw_tree=*/false)) {
+ Logger::Log(LogLevel::Error,
+ "Failed to retrieve artifact {} at "
+ "path '{}' of '{}'",
+ new_info->ToString(),
+ relpath.string(),
+ path.string());
+ }
+ }
+ }
+ else {
+ Logger::Log(
+ LogLevel::Error,
+ "Failed to obtain object information for {}",
+ *(clargs_.build.print_to_stdout));
+ }
+ return;
+ }
+ }
Logger::Log(LogLevel::Warning,
"{} not a logical path of the specified target",
*(clargs_.build.print_to_stdout));