diff options
author | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2023-12-06 15:14:19 +0100 |
---|---|---|
committer | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2023-12-12 16:09:10 +0100 |
commit | d240b3b2d53bb476e742959fa25c3d8806e3800f (patch) | |
tree | 06f3a2600e2206add8148366e5b9edaa126c927a /src/buildtool/main/analyse.cpp | |
parent | c960f942e102df26795226320e761a7f3d78b606 (diff) | |
download | justbuild-d240b3b2d53bb476e742959fa25c3d8806e3800f.tar.gz |
just: Report progress of export targets served during analysis
Diffstat (limited to 'src/buildtool/main/analyse.cpp')
-rw-r--r-- | src/buildtool/main/analyse.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/buildtool/main/analyse.cpp b/src/buildtool/main/analyse.cpp index f90ba3ac..8b69daeb 100644 --- a/src/buildtool/main/analyse.cpp +++ b/src/buildtool/main/analyse.cpp @@ -14,6 +14,12 @@ #include "src/buildtool/main/analyse.hpp" +#ifndef BOOTSTRAP_BUILD_TOOL +#include <atomic> +#include <condition_variable> +#include <thread> +#endif // BOOTSTRAP_BUILD_TOOL + #include "src/buildtool/build_engine/base_maps/directory_map.hpp" #include "src/buildtool/build_engine/base_maps/entity_name.hpp" #include "src/buildtool/build_engine/base_maps/expression_map.hpp" @@ -24,6 +30,9 @@ #include "src/buildtool/build_engine/target_map/target_map.hpp" #include "src/buildtool/multithreading/async_map_consumer.hpp" #include "src/buildtool/multithreading/task_system.hpp" +#ifndef BOOTSTRAP_BUILD_TOOL +#include "src/buildtool/serve_api/progress_reporting/progress_reporter.hpp" +#endif // BOOTSTRAP_BUILD_TOOL namespace { @@ -153,6 +162,14 @@ void DetectAndReportPending(std::string const& name, Logger::Log(LogLevel::Info, "Requested target is {}", id.ToString()); AnalysedTargetPtr target{}; +#ifndef BOOTSTRAP_BUILD_TOOL + std::atomic<bool> done{false}; + std::condition_variable cv{}; + auto reporter = ServeServiceProgressReporter::Reporter(); + auto observer = + std::thread([reporter, &done, &cv]() { reporter(&done, &cv); }); +#endif // BOOTSTRAP_BUILD_TOOL + bool failed{false}; { TaskSystem ts{jobs}; @@ -168,6 +185,13 @@ void DetectAndReportPending(std::string const& name, }); } +#ifndef BOOTSTRAP_BUILD_TOOL + // close progress observer + done = true; + cv.notify_all(); + observer.join(); +#endif // BOOTSTRAP_BUILD_TOOL + if (failed) { return std::nullopt; } |