summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaksim Denisov <denisov.maksim@huawei.com>2025-02-27 12:41:59 +0100
committerMaksim Denisov <denisov.maksim@huawei.com>2025-02-28 13:44:06 +0100
commit87832d98f34cec0513e5abc14e912eec3100e975 (patch)
treebab9eb518bc356fd8bf47fe4134e877deb003de6
parent43ef3b3c953be338d8820e457f956bb96cd4f44d (diff)
downloadjustbuild-87832d98f34cec0513e5abc14e912eec3100e975.tar.gz
GraphTraverser: Pass artifacts, blobs and trees to BuildAndStage by rvalue
-rw-r--r--src/buildtool/computed_roots/analyse_and_build.cpp10
-rw-r--r--src/buildtool/graph_traverser/graph_traverser.hpp27
-rw-r--r--src/buildtool/main/main.cpp8
-rw-r--r--src/buildtool/serve_api/serve_service/target.cpp42
4 files changed, 47 insertions, 40 deletions
diff --git a/src/buildtool/computed_roots/analyse_and_build.cpp b/src/buildtool/computed_roots/analyse_and_build.cpp
index f8a18cec..05d37f5b 100644
--- a/src/buildtool/computed_roots/analyse_and_build.cpp
+++ b/src/buildtool/computed_roots/analyse_and_build.cpp
@@ -54,7 +54,7 @@
auto const [artifacts, runfiles] =
ReadOutputArtifacts(analysis_result->target);
- auto const [actions, blobs, trees] = analysis_result->result_map.ToResult(
+ auto [actions, blobs, trees] = analysis_result->result_map.ToResult(
analyse_context->statistics, analyse_context->progress, logger);
auto const cache_targets = analysis_result->result_map.CacheTargets();
@@ -69,8 +69,12 @@
extra_artifacts.emplace_back(desc);
}
- auto build_result = traverser.BuildAndStage(
- artifacts, {}, actions, blobs, trees, std::move(extra_artifacts));
+ auto build_result = traverser.BuildAndStage(artifacts,
+ {},
+ std::move(actions),
+ std::move(blobs),
+ std::move(trees),
+ std::move(extra_artifacts));
if (not build_result) {
if (logger != nullptr) {
diff --git a/src/buildtool/graph_traverser/graph_traverser.hpp b/src/buildtool/graph_traverser/graph_traverser.hpp
index 5d240cd6..9dc32b61 100644
--- a/src/buildtool/graph_traverser/graph_traverser.hpp
+++ b/src/buildtool/graph_traverser/graph_traverser.hpp
@@ -114,18 +114,18 @@ class GraphTraverser {
[[nodiscard]] auto BuildAndStage(
std::map<std::string, ArtifactDescription> const& artifact_descriptions,
std::map<std::string, ArtifactDescription> const& runfile_descriptions,
- std::vector<ActionDescription::Ptr> const& action_descriptions,
- std::vector<std::string> const& blobs,
- std::vector<Tree::Ptr> const& trees,
+ std::vector<ActionDescription::Ptr>&& action_descriptions,
+ std::vector<std::string>&& blobs,
+ std::vector<Tree::Ptr>&& trees,
std::vector<ArtifactDescription>&& extra_artifacts = {}) const
-> std::optional<BuildResult> {
DependencyGraph graph; // must outlive artifact_nodes
auto artifacts = BuildArtifacts(&graph,
artifact_descriptions,
runfile_descriptions,
- action_descriptions,
- trees,
- blobs,
+ std::move(action_descriptions),
+ std::move(trees),
+ std::move(blobs),
extra_artifacts);
if (not artifacts) {
return std::nullopt;
@@ -211,7 +211,7 @@ class GraphTraverser {
if (not desc) {
return std::nullopt;
}
- auto const [blobs, tree_descs, actions] = *desc;
+ auto [blobs, tree_descs, actions] = *std::move(desc);
HashFunction::Type const hash_type =
context_.apis->local->GetHashType();
@@ -245,8 +245,11 @@ class GraphTraverser {
artifact_descriptions.emplace(rel_path, std::move(*artifact));
}
- return BuildAndStage(
- artifact_descriptions, {}, action_descriptions, blobs, trees);
+ return BuildAndStage(artifact_descriptions,
+ {},
+ std::move(action_descriptions),
+ std::move(blobs),
+ std::move(trees));
}
private:
@@ -496,9 +499,9 @@ class GraphTraverser {
gsl::not_null<DependencyGraph*> const& graph,
std::map<std::string, ArtifactDescription> const& artifacts,
std::map<std::string, ArtifactDescription> const& runfiles,
- std::vector<ActionDescription::Ptr> const& actions,
- std::vector<Tree::Ptr> const& trees,
- std::vector<std::string> const& blobs,
+ std::vector<ActionDescription::Ptr>&& actions,
+ std::vector<Tree::Ptr>&& trees,
+ std::vector<std::string>&& blobs,
std::vector<ArtifactDescription> const& extra_artifacts = {}) const
-> std::optional<
std::tuple<std::vector<std::filesystem::path>,
diff --git a/src/buildtool/main/main.cpp b/src/buildtool/main/main.cpp
index 5acba963..e4ac6a02 100644
--- a/src/buildtool/main/main.cpp
+++ b/src/buildtool/main/main.cpp
@@ -1178,7 +1178,7 @@ auto main(int argc, char* argv[]) -> int {
}
#ifndef BOOTSTRAP_BUILD_TOOL
ReportTaintedness(*analyse_result);
- auto const& [actions, blobs, trees] =
+ auto [actions, blobs, trees] =
analyse_result->result_map.ToResult(&stats, &progress);
// collect cache targets and artifacts for target-level caching
@@ -1206,9 +1206,9 @@ auto main(int argc, char* argv[]) -> int {
auto build_result =
traverser.BuildAndStage(artifacts,
runfiles,
- actions,
- blobs,
- trees,
+ std::move(actions),
+ std::move(blobs),
+ std::move(trees),
std::move(cache_artifacts));
if (build_result) {
WriteTargetCacheEntries(
diff --git a/src/buildtool/serve_api/serve_service/target.cpp b/src/buildtool/serve_api/serve_service/target.cpp
index 2bd91079..6b46157c 100644
--- a/src/buildtool/serve_api/serve_service/target.cpp
+++ b/src/buildtool/serve_api/serve_service/target.cpp
@@ -531,24 +531,6 @@ auto TargetService::ServeTarget(
logger_->Emit(
LogLevel::Info, "Analysed target {}", analyse_result->id.ToString());
- // get the output artifacts
- auto const [artifacts, runfiles] =
- ReadOutputArtifacts(analyse_result->target);
-
- // get the analyse_result map outputs
- auto const& [actions, blobs, trees] =
- analyse_result->result_map.ToResult(&stats, &progress, &logger);
-
- // collect cache targets and artifacts for target-level caching
- auto const cache_targets = analyse_result->result_map.CacheTargets();
- auto cache_artifacts = CollectNonKnownArtifacts(cache_targets);
-
- // Clean up analyse_result map, now that it is no longer needed
- {
- TaskSystem ts{serve_config_.jobs};
- analyse_result->result_map.Clear(&ts);
- }
-
auto jobs = serve_config_.build_jobs;
if (jobs == 0) {
jobs = serve_config_.jobs;
@@ -584,12 +566,30 @@ auto TargetService::ServeTarget(
ProgressReporter::Reporter(&stats, &progress, &logger),
&logger};
+ // get the output artifacts
+ auto const [artifacts, runfiles] =
+ ReadOutputArtifacts(analyse_result->target);
+
+ // get the analyse_result map outputs
+ auto [actions, blobs, trees] =
+ analyse_result->result_map.ToResult(&stats, &progress, &logger);
+
+ // collect cache targets and artifacts for target-level caching
+ auto const cache_targets = analyse_result->result_map.CacheTargets();
+ auto cache_artifacts = CollectNonKnownArtifacts(cache_targets);
+
+ // Clean up analyse_result map, now that it is no longer needed
+ {
+ TaskSystem ts{serve_config_.jobs};
+ analyse_result->result_map.Clear(&ts);
+ }
+
// perform build
auto build_result = traverser.BuildAndStage(artifacts,
runfiles,
- actions,
- blobs,
- trees,
+ std::move(actions),
+ std::move(blobs),
+ std::move(trees),
std::move(cache_artifacts));
if (not build_result) {