diff options
-rw-r--r-- | src/buildtool/computed_roots/analyse_and_build.cpp | 10 | ||||
-rw-r--r-- | src/buildtool/graph_traverser/graph_traverser.hpp | 27 | ||||
-rw-r--r-- | src/buildtool/main/main.cpp | 8 | ||||
-rw-r--r-- | src/buildtool/serve_api/serve_service/target.cpp | 42 |
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) { |