From 6effe0cff0146e6f9806c8cf734b817a8ac6ea57 Mon Sep 17 00:00:00 2001 From: Hyunwoo Nam Date: Mon, 18 Oct 2021 23:00:27 +0900 Subject: [PATCH] log when build fails --- src/build.cc | 6 +----- src/ninja.cc | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/build.cc b/src/build.cc index 17cf950124..651a824538 100644 --- a/src/build.cc +++ b/src/build.cc @@ -796,11 +796,7 @@ void Builder::Cleanup() { } } - if (compiler_log_) { - fprintf(compiler_log_, "#Done(%" PRId64 ")\n", GetTimeMillis()); - fclose(compiler_log_); - compiler_log_ = NULL; - } + compiler_log_ = NULL; } Node* Builder::AddTarget(const string& name, string* err) { diff --git a/src/ninja.cc b/src/ninja.cc index 590c416ec8..3114fc595a 100644 --- a/src/ninja.cc +++ b/src/ninja.cc @@ -1172,19 +1172,27 @@ int NinjaMain::RunBuild(int argc, char** argv) { printf("ninja: build stopped: %s.\n", err.c_str()); #else - if(ShouldBeColorFul(false)){ - printf("\x1b[31m" "FAILED:" "\x1b[0m" " %s.\n", err.c_str()); - } else { - printf("FAILED: %s.\n", err.c_str()); - } + if (ShouldBeColorFul(false)) { + printf("\x1b[31m" "FAILED:" "\x1b[0m" " %s.\n", err.c_str()); + } else { + printf("FAILED: %s.\n", err.c_str()); + } + fprintf(compiler_log_, "FAILED: %s.\n", err.c_str()); #endif + + fprintf(compiler_log_, "#Done(%" PRId64 ")\n", GetTimeMillis()); + fclose(compiler_log_); + if (err.find("interrupted by user") != string::npos) { return 2; } return 1; } + fprintf(compiler_log_, "#Done(%" PRId64 ")\n", GetTimeMillis()); + fclose(compiler_log_); + return 0; }