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

Side by Side Diff: tools/gn/ninja_build_writer.cc

Issue 1220223002: Add output reference to gen written files. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove dependency hack at the same time Created 5 years, 5 months 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 unified diff | Download patch
« no previous file with comments | « tools/gn/function_write_file.cc ('k') | tools/gn/scheduler.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "tools/gn/ninja_build_writer.h" 5 #include "tools/gn/ninja_build_writer.h"
6 6
7 #include <fstream> 7 #include <fstream>
8 #include <map> 8 #include <map>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 } 136 }
137 137
138 NinjaBuildWriter gen(build_settings, all_settings, default_toolchain, 138 NinjaBuildWriter gen(build_settings, all_settings, default_toolchain,
139 default_toolchain_targets, file, depfile); 139 default_toolchain_targets, file, depfile);
140 return gen.Run(err); 140 return gen.Run(err);
141 } 141 }
142 142
143 void NinjaBuildWriter::WriteNinjaRules() { 143 void NinjaBuildWriter::WriteNinjaRules() {
144 out_ << "rule gn\n"; 144 out_ << "rule gn\n";
145 out_ << " command = " << GetSelfInvocationCommand(build_settings_) << "\n"; 145 out_ << " command = " << GetSelfInvocationCommand(build_settings_) << "\n";
146 out_ << " description = Regenerating ninja files\n\n"; 146 out_ << " description = Regenerating ninja files\n";
147 out_ << " restat = 1\n\n";
147 148
148 // This rule will regenerate the ninja files when any input file has changed. 149 // This rule will regenerate the ninja files when any input file has changed,
149 out_ << "build build.ninja: gn\n" 150 // or is missing.
151 out_ << "build build.ninja";
152
153 // Other files read by the build.
154 std::vector<SourceFile> written_files = g_scheduler->GetWrittenFiles();
155 for (const auto& written_file : written_files)
156 out_ << " " << FilePathToUTF8(build_settings_->GetFullPath(written_file));
157
158 out_ << ": gn\n"
150 << " generator = 1\n" 159 << " generator = 1\n"
151 << " depfile = build.ninja.d\n"; 160 << " depfile = build.ninja.d\n";
152 161
153 // Input build files. These go in the ".d" file. If we write them as 162 // Input build files. These go in the ".d" file. If we write them as
154 // dependencies in the .ninja file itself, ninja will expect the files to 163 // dependencies in the .ninja file itself, ninja will expect the files to
155 // exist and will error if they don't. When files are listed in a depfile, 164 // exist and will error if they don't. When files are listed in a depfile,
156 // missing files are ignored. 165 // missing files are ignored.
157 dep_out_ << "build.ninja:"; 166 dep_out_ << "build.ninja:";
158 std::vector<base::FilePath> input_files; 167 std::vector<base::FilePath> input_files;
159 g_scheduler->input_file_manager()->GetAllPhysicalInputFileNames(&input_files); 168 g_scheduler->input_file_manager()->GetAllPhysicalInputFileNames(&input_files);
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 EscapeOptions ninja_escape; 322 EscapeOptions ninja_escape;
314 ninja_escape.mode = ESCAPE_NINJA; 323 ninja_escape.mode = ESCAPE_NINJA;
315 324
316 // Escape for special chars Ninja will handle. 325 // Escape for special chars Ninja will handle.
317 std::string escaped = EscapeString(phony_name, ninja_escape, nullptr); 326 std::string escaped = EscapeString(phony_name, ninja_escape, nullptr);
318 327
319 out_ << "build " << escaped << ": phony "; 328 out_ << "build " << escaped << ": phony ";
320 path_output_.WriteFile(out_, target_file); 329 path_output_.WriteFile(out_, target_file);
321 out_ << std::endl; 330 out_ << std::endl;
322 } 331 }
OLDNEW
« no previous file with comments | « tools/gn/function_write_file.cc ('k') | tools/gn/scheduler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698