summaryrefslogtreecommitdiffstats
path: root/src/ninja.cc
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2016-11-14 23:59:41 (GMT)
committerColin Cross <ccross@android.com>2020-12-18 20:38:29 (GMT)
commit589f5b2497929a50a1c74786478cc6fea7a2e1c6 (patch)
tree0b4e837578a50a597e7fec47734abb82a917d54e /src/ninja.cc
parent045890cee352be512beea96da0d142f219472fbb (diff)
downloadNinja-589f5b2497929a50a1c74786478cc6fea7a2e1c6.zip
Ninja-589f5b2497929a50a1c74786478cc6fea7a2e1c6.tar.gz
Ninja-589f5b2497929a50a1c74786478cc6fea7a2e1c6.tar.bz2
Turn BuildStatus into an interface
Make BuildStatus an abstract interface, and move the current implementation to StatusPrinter, to make way for a serialized Status output.
Diffstat (limited to 'src/ninja.cc')
-rw-r--r--src/ninja.cc20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/ninja.cc b/src/ninja.cc
index 57690be..d92e95b 100644
--- a/src/ninja.cc
+++ b/src/ninja.cc
@@ -43,6 +43,7 @@
#include "manifest_parser.h"
#include "metrics.h"
#include "state.h"
+#include "status.h"
#include "util.h"
#include "version.h"
@@ -145,11 +146,11 @@ struct NinjaMain : public BuildLogUser {
/// Rebuild the manifest, if necessary.
/// Fills in \a err on error.
/// @return true if the manifest was rebuilt.
- bool RebuildManifest(const char* input_file, string* err);
+ bool RebuildManifest(const char* input_file, string* err, Status* status);
/// Build the targets listed on the command line.
/// @return an exit code.
- int RunBuild(int argc, char** argv);
+ int RunBuild(int argc, char** argv, Status* status);
/// Dump the output requested by '-d stats'.
void DumpMetrics();
@@ -243,7 +244,8 @@ int GuessParallelism() {
/// Rebuild the build manifest, if necessary.
/// Returns true if the manifest was rebuilt.
-bool NinjaMain::RebuildManifest(const char* input_file, string* err) {
+bool NinjaMain::RebuildManifest(const char* input_file, string* err,
+ Status *status) {
string path = input_file;
uint64_t slash_bits; // Unused because this path is only used for lookup.
if (!CanonicalizePath(&path, &slash_bits, err))
@@ -253,7 +255,7 @@ bool NinjaMain::RebuildManifest(const char* input_file, string* err) {
return false;
Builder builder(&state_, config_, &build_log_, &deps_log_, &disk_interface_,
- start_time_millis_);
+ status, start_time_millis_);
if (!builder.AddTarget(node, err))
return false;
@@ -1193,7 +1195,7 @@ bool NinjaMain::EnsureBuildDirExists() {
return true;
}
-int NinjaMain::RunBuild(int argc, char** argv) {
+int NinjaMain::RunBuild(int argc, char** argv, Status* status) {
string err;
vector<Node*> targets;
if (!CollectTargetsFromArgs(argc, argv, &targets, &err)) {
@@ -1204,7 +1206,7 @@ int NinjaMain::RunBuild(int argc, char** argv) {
disk_interface_.AllowStatCache(g_experimental_statcache);
Builder builder(&state_, config_, &build_log_, &deps_log_, &disk_interface_,
- start_time_millis_);
+ status, start_time_millis_);
for (size_t i = 0; i < targets.size(); ++i) {
if (!builder.AddTarget(targets[i], &err)) {
if (!err.empty()) {
@@ -1364,6 +1366,8 @@ NORETURN void real_main(int argc, char** argv) {
if (exit_code >= 0)
exit(exit_code);
+ Status* status = new StatusPrinter(config);
+
if (options.working_dir) {
// The formatting of this string, complete with funny quotes, is
// so Emacs can properly identify that the cwd has changed for
@@ -1416,7 +1420,7 @@ NORETURN void real_main(int argc, char** argv) {
exit((ninja.*options.tool->func)(&options, argc, argv));
// Attempt to rebuild the manifest before building anything else
- if (ninja.RebuildManifest(options.input_file, &err)) {
+ if (ninja.RebuildManifest(options.input_file, &err, status)) {
// In dry_run mode the regeneration will succeed without changing the
// manifest forever. Better to return immediately.
if (config.dry_run)
@@ -1428,7 +1432,7 @@ NORETURN void real_main(int argc, char** argv) {
exit(1);
}
- int result = ninja.RunBuild(argc, argv);
+ int result = ninja.RunBuild(argc, argv, status);
if (g_metrics)
ninja.DumpMetrics();
exit(result);