OLD | NEW |
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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 // or is missing. | 149 // or is missing. |
150 out_ << "build build.ninja"; | 150 out_ << "build build.ninja"; |
151 | 151 |
152 // Other files read by the build. | 152 // Other files read by the build. |
153 EscapeOptions path_escaping; | 153 EscapeOptions path_escaping; |
154 path_escaping.mode = ESCAPE_NINJA_COMMAND; | 154 path_escaping.mode = ESCAPE_NINJA_COMMAND; |
155 std::vector<SourceFile> written_files = g_scheduler->GetWrittenFiles(); | 155 std::vector<SourceFile> written_files = g_scheduler->GetWrittenFiles(); |
156 for (const auto& written_file : written_files) | 156 for (const auto& written_file : written_files) |
157 out_ << " " << | 157 out_ << " " << EscapeString(RebasePath(written_file.value(), |
158 EscapeString(FilePathToUTF8(build_settings_->GetFullPath(written_file)), | 158 build_settings_->build_dir(), build_settings_->root_path_utf8()), |
159 path_escaping, nullptr); | 159 path_escaping, nullptr); |
160 | 160 |
161 out_ << ": gn\n" | 161 out_ << ": gn\n" |
162 << " generator = 1\n" | 162 << " generator = 1\n" |
163 << " depfile = build.ninja.d\n"; | 163 << " depfile = build.ninja.d\n"; |
164 | 164 |
165 // 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 |
166 // 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 |
167 // 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, |
168 // missing files are ignored. | 168 // missing files are ignored. |
169 dep_out_ << "build.ninja:"; | 169 dep_out_ << "build.ninja:"; |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 EscapeOptions ninja_escape; | 325 EscapeOptions ninja_escape; |
326 ninja_escape.mode = ESCAPE_NINJA; | 326 ninja_escape.mode = ESCAPE_NINJA; |
327 | 327 |
328 // Escape for special chars Ninja will handle. | 328 // Escape for special chars Ninja will handle. |
329 std::string escaped = EscapeString(phony_name, ninja_escape, nullptr); | 329 std::string escaped = EscapeString(phony_name, ninja_escape, nullptr); |
330 | 330 |
331 out_ << "build " << escaped << ": phony "; | 331 out_ << "build " << escaped << ": phony "; |
332 path_output_.WriteFile(out_, target_file); | 332 path_output_.WriteFile(out_, target_file); |
333 out_ << std::endl; | 333 out_ << std::endl; |
334 } | 334 } |
OLD | NEW |