Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Unified Diff: tools/gn/ninja_build_writer.cc

Issue 82923005: Add "ninja show" and "ninja refresh" targets to GN build. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/ninja_build_writer.cc
diff --git a/tools/gn/ninja_build_writer.cc b/tools/gn/ninja_build_writer.cc
index b7cfdd797cdb620617fc8dd5a8ed9d393a7d44f0..a7752453ec27d9bb8bdbd72acf19bf4520cb14d1 100644
--- a/tools/gn/ninja_build_writer.cc
+++ b/tools/gn/ninja_build_writer.cc
@@ -136,9 +136,26 @@ void NinjaBuildWriter::WriteNinjaRules() {
out_ << " command = " << GetSelfInvocationCommand(build_settings_) << "\n";
out_ << " description = Regenerating ninja files\n\n";
+ // This rule will regenerate the ninja files when any input file has changed.
out_ << "build build.ninja: gn\n"
<< " depfile = build.ninja.d\n";
+ // Provide a way to force regenerating ninja files if the user is suspicious
+ // something is out-of-date. This will be "ninja refresh".
+ out_ << "\nbuild refresh: gn\n";
+
+ // Provide a way to see what flags are associated with this build:
+ // This will be "ninja show".
+ const CommandLine& our_cmdline = *CommandLine::ForCurrentProcess();
+ std::string args = our_cmdline.GetSwitchValueASCII("args");
+ out_ << "rule echo\n";
+ out_ << " command = echo $text\n";
+ out_ << " description = ECHO $desc\n";
+ out_ << "build show: echo\n";
+ out_ << " desc = build arguments:\n";
+ out_ << " text = " << (args.empty() ? std::string("<default args>") : args)
+ << "\n";
+
// Input build files. These go in the ".d" file. If we write them as
// dependencies in the .ninja file itself, ninja will expect the files to
// exist and will error if they don't. When files are listed in a depfile,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698