summaryrefslogtreecommitdiff
path: root/src/buildtool/serve_api/serve_service/target.cpp
diff options
context:
space:
mode:
authorPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2024-03-07 15:44:28 +0100
committerPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2024-03-11 15:59:05 +0100
commit5f6ff55e97104e46c1b5c2c94b39ea0fca35ca7c (patch)
tree9a8a70d311f2c55c20f426258455f9fb3037328a /src/buildtool/serve_api/serve_service/target.cpp
parentb885deebf9fc02b9f1e849d91de93fadcfb71a73 (diff)
downloadjustbuild-5f6ff55e97104e46c1b5c2c94b39ea0fca35ca7c.tar.gz
just: Replace singletons for progress tracking and statistics...
...with regular instances that have controlled life-times. This avoids race conditions in tracking and reporting the results of analysis and build, as the serve endpoint can orchestrate multiple builds at the same time asynchronously. As a bonus side-effect this also ensures the correctness of the progress reporting per orchestrated build.
Diffstat (limited to 'src/buildtool/serve_api/serve_service/target.cpp')
-rw-r--r--src/buildtool/serve_api/serve_service/target.cpp22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/buildtool/serve_api/serve_service/target.cpp b/src/buildtool/serve_api/serve_service/target.cpp
index 97b75b53..202335d9 100644
--- a/src/buildtool/serve_api/serve_service/target.cpp
+++ b/src/buildtool/serve_api/serve_service/target.cpp
@@ -401,11 +401,17 @@ auto TargetService::ServeTarget(
auto configured_target = BuildMaps::Target::ConfiguredTarget{
.target = std::move(*entity), .config = std::move(config)};
+ // setup progress reporting; these instances need to be kept alive for
+ // graph traversal, analysis, and build
+ Statistics stats;
+ Progress progress;
+
// analyse the configured target
auto result = AnalyseTarget(configured_target,
&result_map,
&repository_config,
*tc,
+ &stats,
RemoteServeConfig::Jobs(),
std::nullopt /*request_action_input*/);
@@ -420,7 +426,8 @@ auto TargetService::ServeTarget(
auto const [artifacts, runfiles] = ReadOutputArtifacts(result->target);
// get the result map outputs
- auto const& [actions, blobs, trees] = result_map.ToResult();
+ auto const& [actions, blobs, trees] =
+ result_map.ToResult(&stats, &progress);
// collect cache targets and artifacts for target-level caching
auto const cache_targets = result_map.CacheTargets();
@@ -443,11 +450,14 @@ auto TargetService::ServeTarget(
traverser_args.build.timeout = RemoteServeConfig::ActionTimeout();
traverser_args.stage = std::nullopt;
traverser_args.rebuild = std::nullopt;
- GraphTraverser const traverser{std::move(traverser_args),
- &repository_config,
- std::move(platform_properties),
- std::move(dispatch_list),
- ProgressReporter::Reporter()};
+ GraphTraverser const traverser{
+ std::move(traverser_args),
+ &repository_config,
+ std::move(platform_properties),
+ std::move(dispatch_list),
+ &stats,
+ &progress,
+ ProgressReporter::Reporter(&stats, &progress)};
// perform build
auto build_result = traverser.BuildAndStage(