From cc89c1aaec13487dc633cd69f7022fcb72fc1c10 Mon Sep 17 00:00:00 2001 From: Scott Graham Date: Tue, 10 Sep 2013 15:34:01 -0700 Subject: add -d keeprsp to preserve @rsp files on success on windows --- configure.py | 2 +- src/build.cc | 3 ++- src/debug_flags.cc | 17 +++++++++++++++++ src/debug_flags.h | 29 +++++++++++++++++++++++++++++ src/explain.cc | 15 --------------- src/explain.h | 27 --------------------------- src/graph.cc | 2 +- src/ninja.cc | 6 +++++- 8 files changed, 55 insertions(+), 46 deletions(-) create mode 100644 src/debug_flags.cc create mode 100644 src/debug_flags.h delete mode 100644 src/explain.cc delete mode 100644 src/explain.h diff --git a/configure.py b/configure.py index c838392..9fe3be8 100755 --- a/configure.py +++ b/configure.py @@ -263,12 +263,12 @@ n.comment('Core source files all build into ninja library.') for name in ['build', 'build_log', 'clean', + 'debug_flags', 'depfile_parser', 'deps_log', 'disk_interface', 'edit_distance', 'eval_env', - 'explain', 'graph', 'graphviz', 'lexer', diff --git a/src/build.cc b/src/build.cc index 8a93632..9718f85 100644 --- a/src/build.cc +++ b/src/build.cc @@ -25,6 +25,7 @@ #endif #include "build_log.h" +#include "debug_flags.h" #include "depfile_parser.h" #include "deps_log.h" #include "disk_interface.h" @@ -776,7 +777,7 @@ bool Builder::FinishCommand(CommandRunner::Result* result, string* err) { // Delete any left over response file. string rspfile = edge->GetBinding("rspfile"); - if (!rspfile.empty()) + if (!rspfile.empty() && !g_keep_rsp) disk_interface_->RemoveFile(rspfile); if (scan_.build_log()) { diff --git a/src/debug_flags.cc b/src/debug_flags.cc new file mode 100644 index 0000000..75f1ea5 --- /dev/null +++ b/src/debug_flags.cc @@ -0,0 +1,17 @@ +// Copyright 2012 Google Inc. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +bool g_explaining = false; + +bool g_keep_rsp = false; diff --git a/src/debug_flags.h b/src/debug_flags.h new file mode 100644 index 0000000..ba3ebf3 --- /dev/null +++ b/src/debug_flags.h @@ -0,0 +1,29 @@ +// Copyright 2012 Google Inc. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef NINJA_EXPLAIN_H_ +#define NINJA_EXPLAIN_H_ + +#include + +#define EXPLAIN(fmt, ...) { \ + if (g_explaining) \ + fprintf(stderr, "ninja explain: " fmt "\n", __VA_ARGS__); \ +} + +extern bool g_explaining; + +extern bool g_keep_rsp; + +#endif // NINJA_EXPLAIN_H_ diff --git a/src/explain.cc b/src/explain.cc deleted file mode 100644 index 4e14c25..0000000 --- a/src/explain.cc +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2012 Google Inc. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -bool g_explaining = false; diff --git a/src/explain.h b/src/explain.h deleted file mode 100644 index d4f6a6c..0000000 --- a/src/explain.h +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2012 Google Inc. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef NINJA_EXPLAIN_H_ -#define NINJA_EXPLAIN_H_ - -#include - -#define EXPLAIN(fmt, ...) { \ - if (g_explaining) \ - fprintf(stderr, "ninja explain: " fmt "\n", __VA_ARGS__); \ -} - -extern bool g_explaining; - -#endif // NINJA_EXPLAIN_H_ diff --git a/src/graph.cc b/src/graph.cc index 6191998..9801a7b 100644 --- a/src/graph.cc +++ b/src/graph.cc @@ -18,10 +18,10 @@ #include #include "build_log.h" +#include "debug_flags.h" #include "depfile_parser.h" #include "deps_log.h" #include "disk_interface.h" -#include "explain.h" #include "manifest_parser.h" #include "metrics.h" #include "state.h" diff --git a/src/ninja.cc b/src/ninja.cc index 0586bdc..a313ecb 100644 --- a/src/ninja.cc +++ b/src/ninja.cc @@ -32,8 +32,8 @@ #include "build_log.h" #include "deps_log.h" #include "clean.h" +#include "debug_flags.h" #include "disk_interface.h" -#include "explain.h" #include "graph.h" #include "graphviz.h" #include "manifest_parser.h" @@ -747,6 +747,7 @@ bool DebugEnable(const string& name) { printf("debugging modes:\n" " stats print operation counts/timing info\n" " explain explain what caused a command to execute\n" +" keeprsp don't delete @response files on success\n" "multiple modes can be enabled via -d FOO -d BAR\n"); return false; } else if (name == "stats") { @@ -755,6 +756,9 @@ bool DebugEnable(const string& name) { } else if (name == "explain") { g_explaining = true; return true; + } else if (name == "keeprsp") { + g_keep_rsp = true; + return true; } else { const char* suggestion = SpellcheckString(name.c_str(), "stats", "explain", NULL); -- cgit v0.12