Chromium Code Reviews| 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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 145 out_ << " description = Regenerating ninja files\n"; | 145 out_ << " description = Regenerating ninja files\n"; |
| 146 out_ << " restat = 1\n\n"; | 146 out_ << " restat = 1\n\n"; |
| 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 | |
| 155 std::vector<SourceFile> written_files = g_scheduler->GetWrittenFiles(); | 156 std::vector<SourceFile> written_files = g_scheduler->GetWrittenFiles(); |
| 156 for (const auto& written_file : written_files) | 157 for (const auto& written_file : written_files) { |
| 157 out_ << " " << | 158 Err err; |
| 158 EscapeString(FilePathToUTF8(build_settings_->GetFullPath(written_file)), | 159 base::FilePath::StringType fileref = ComputeStringInOutputDir( |
|
brettw
2015/07/31 23:36:55
I think RebasePath in filesystem_utils.h will hand
| |
| 159 path_escaping, nullptr); | 160 build_settings_->build_dir(), written_file, &err); |
| 161 out_ << " "; | |
| 162 if (!err.has_error()) | |
| 163 EscapeStringToStream(out_, FilePathToUTF8(fileref), path_escaping); | |
| 164 else | |
| 165 EscapeStringToStream(out_, | |
| 166 written_file.Resolve(build_settings_->root_path()), path_escaping); | |
|
Peter Mayo
2015/07/31 19:08:07
Oops, forgot to change to UTF8.
| |
| 167 } | |
| 160 | 168 |
| 161 out_ << ": gn\n" | 169 out_ << ": gn\n" |
| 162 << " generator = 1\n" | 170 << " generator = 1\n" |
| 163 << " depfile = build.ninja.d\n"; | 171 << " depfile = build.ninja.d\n"; |
| 164 | 172 |
| 165 // Input build files. These go in the ".d" file. If we write them as | 173 // 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 | 174 // 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, | 175 // exist and will error if they don't. When files are listed in a depfile, |
| 168 // missing files are ignored. | 176 // missing files are ignored. |
| 169 dep_out_ << "build.ninja:"; | 177 dep_out_ << "build.ninja:"; |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 325 EscapeOptions ninja_escape; | 333 EscapeOptions ninja_escape; |
| 326 ninja_escape.mode = ESCAPE_NINJA; | 334 ninja_escape.mode = ESCAPE_NINJA; |
| 327 | 335 |
| 328 // Escape for special chars Ninja will handle. | 336 // Escape for special chars Ninja will handle. |
| 329 std::string escaped = EscapeString(phony_name, ninja_escape, nullptr); | 337 std::string escaped = EscapeString(phony_name, ninja_escape, nullptr); |
| 330 | 338 |
| 331 out_ << "build " << escaped << ": phony "; | 339 out_ << "build " << escaped << ": phony "; |
| 332 path_output_.WriteFile(out_, target_file); | 340 path_output_.WriteFile(out_, target_file); |
| 333 out_ << std::endl; | 341 out_ << std::endl; |
| 334 } | 342 } |
| OLD | NEW |