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

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

Issue 1252403005: Add output reference to gen written files. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: do not escape paths in build.ninja.d Created 5 years, 4 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 cmdline.AppendSwitchASCII(i->first, escaped_value); 69 cmdline.AppendSwitchASCII(i->first, escaped_value);
70 } 70 }
71 } 71 }
72 72
73 #if defined(OS_WIN) 73 #if defined(OS_WIN)
74 return base::WideToUTF8(cmdline.GetCommandLineString()); 74 return base::WideToUTF8(cmdline.GetCommandLineString());
75 #else 75 #else
76 return cmdline.GetCommandLineString(); 76 return cmdline.GetCommandLineString();
77 #endif 77 #endif
78 } 78 }
79
80 } // namespace 79 } // namespace
81 80
82 NinjaBuildWriter::NinjaBuildWriter( 81 NinjaBuildWriter::NinjaBuildWriter(
83 const BuildSettings* build_settings, 82 const BuildSettings* build_settings,
84 const std::vector<const Settings*>& all_settings, 83 const std::vector<const Settings*>& all_settings,
85 const Toolchain* default_toolchain, 84 const Toolchain* default_toolchain,
86 const std::vector<const Target*>& default_toolchain_targets, 85 const std::vector<const Target*>& default_toolchain_targets,
87 std::ostream& out, 86 std::ostream& out,
88 std::ostream& dep_out) 87 std::ostream& dep_out)
89 : build_settings_(build_settings), 88 : build_settings_(build_settings),
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 } 135 }
137 136
138 NinjaBuildWriter gen(build_settings, all_settings, default_toolchain, 137 NinjaBuildWriter gen(build_settings, all_settings, default_toolchain,
139 default_toolchain_targets, file, depfile); 138 default_toolchain_targets, file, depfile);
140 return gen.Run(err); 139 return gen.Run(err);
141 } 140 }
142 141
143 void NinjaBuildWriter::WriteNinjaRules() { 142 void NinjaBuildWriter::WriteNinjaRules() {
144 out_ << "rule gn\n"; 143 out_ << "rule gn\n";
145 out_ << " command = " << GetSelfInvocationCommand(build_settings_) << "\n"; 144 out_ << " command = " << GetSelfInvocationCommand(build_settings_) << "\n";
146 out_ << " description = Regenerating ninja files\n\n"; 145 out_ << " description = Regenerating ninja files\n";
146 out_ << " restat = 1\n\n";
Peter Mayo 2015/09/23 18:53:34 This is important for this change.
147 147
148 // This rule will regenerate the ninja files when any input file has changed. 148 // This rule will regenerate the ninja files when any input file has changed,
149 out_ << "build build.ninja: gn\n" 149 // or is missing.
150 out_ << "build build.ninja";
151
152 // Other files read by the build.
153 EscapeOptions path_escaping;
154 path_escaping.mode = ESCAPE_NINJA_COMMAND;
155 std::vector<SourceFile> written_files = g_scheduler->GetWrittenFiles();
156 for (const auto& written_file : written_files)
157 out_ << " " <<
Peter Mayo 2015/07/30 23:25:32 Is this the right wrapping? dropping the << onto
Dirk Pranke 2015/07/30 23:37:08 no clue :).
brettw 2015/07/31 00:57:01 Seems "not wrong"
158 EscapeString(FilePathToUTF8(build_settings_->GetFullPath(written_file)),
159 path_escaping, nullptr);
160
161 out_ << ": gn\n"
150 << " generator = 1\n" 162 << " generator = 1\n"
151 << " depfile = build.ninja.d\n"; 163 << " depfile = build.ninja.d\n";
152 164
153 // Input build files. These go in the ".d" file. If we write them as 165 // 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 166 // 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, 167 // exist and will error if they don't. When files are listed in a depfile,
156 // missing files are ignored. 168 // missing files are ignored.
157 dep_out_ << "build.ninja:"; 169 dep_out_ << "build.ninja:";
158 std::vector<base::FilePath> input_files; 170 std::vector<base::FilePath> input_files;
159 g_scheduler->input_file_manager()->GetAllPhysicalInputFileNames(&input_files); 171 g_scheduler->input_file_manager()->GetAllPhysicalInputFileNames(&input_files);
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 EscapeOptions ninja_escape; 325 EscapeOptions ninja_escape;
314 ninja_escape.mode = ESCAPE_NINJA; 326 ninja_escape.mode = ESCAPE_NINJA;
315 327
316 // Escape for special chars Ninja will handle. 328 // Escape for special chars Ninja will handle.
317 std::string escaped = EscapeString(phony_name, ninja_escape, nullptr); 329 std::string escaped = EscapeString(phony_name, ninja_escape, nullptr);
318 330
319 out_ << "build " << escaped << ": phony "; 331 out_ << "build " << escaped << ": phony ";
320 path_output_.WriteFile(out_, target_file); 332 path_output_.WriteFile(out_, target_file);
321 out_ << std::endl; 333 out_ << std::endl;
322 } 334 }
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