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_target_writer.h" | 5 #include "tools/gn/ninja_target_writer.h" |
6 | 6 |
7 #include <fstream> | 7 #include <fstream> |
8 #include <sstream> | 8 #include <sstream> |
9 | 9 |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "tools/gn/string_utils.h" | 21 #include "tools/gn/string_utils.h" |
22 #include "tools/gn/substitution_writer.h" | 22 #include "tools/gn/substitution_writer.h" |
23 #include "tools/gn/target.h" | 23 #include "tools/gn/target.h" |
24 #include "tools/gn/trace.h" | 24 #include "tools/gn/trace.h" |
25 | 25 |
26 NinjaTargetWriter::NinjaTargetWriter(const Target* target, | 26 NinjaTargetWriter::NinjaTargetWriter(const Target* target, |
27 std::ostream& out) | 27 std::ostream& out) |
28 : settings_(target->settings()), | 28 : settings_(target->settings()), |
29 target_(target), | 29 target_(target), |
30 out_(out), | 30 out_(out), |
31 path_output_(settings_->build_settings()->build_dir(), ESCAPE_NINJA) { | 31 path_output_(settings_->build_settings()->build_dir(), |
| 32 settings_->build_settings()->root_path(), ESCAPE_NINJA) { |
32 } | 33 } |
33 | 34 |
34 NinjaTargetWriter::~NinjaTargetWriter() { | 35 NinjaTargetWriter::~NinjaTargetWriter() { |
35 } | 36 } |
36 | 37 |
37 // static | 38 // static |
38 void NinjaTargetWriter::RunAndWriteFile(const Target* target) { | 39 void NinjaTargetWriter::RunAndWriteFile(const Target* target) { |
39 const Settings* settings = target->settings(); | 40 const Settings* settings = target->settings(); |
40 | 41 |
41 ScopedTrace trace(TraceItem::TRACE_FILE_WRITE, | 42 ScopedTrace trace(TraceItem::TRACE_FILE_WRITE, |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 | 169 |
169 // One potential optimization is if there are few input dependencies (or | 170 // One potential optimization is if there are few input dependencies (or |
170 // potentially few sources that depend on these) it's better to just write | 171 // potentially few sources that depend on these) it's better to just write |
171 // all hard deps on each sources line than have this intermediate stamp. We | 172 // all hard deps on each sources line than have this intermediate stamp. We |
172 // do the stamp file because duplicating all the order-only deps for each | 173 // do the stamp file because duplicating all the order-only deps for each |
173 // source file can really explode the ninja file but this won't be the most | 174 // source file can really explode the ninja file but this won't be the most |
174 // optimal thing in all cases. | 175 // optimal thing in all cases. |
175 | 176 |
176 OutputFile input_stamp_file( | 177 OutputFile input_stamp_file( |
177 RebaseSourceAbsolutePath(GetTargetOutputDir(target_).value(), | 178 RebaseSourceAbsolutePath(GetTargetOutputDir(target_).value(), |
178 settings_->build_settings()->build_dir())); | 179 settings_->build_settings()->build_dir(), |
| 180 settings_->build_settings()->root_path())); |
179 input_stamp_file.value().append(target_->label().name()); | 181 input_stamp_file.value().append(target_->label().name()); |
180 input_stamp_file.value().append(".inputdeps.stamp"); | 182 input_stamp_file.value().append(".inputdeps.stamp"); |
181 | 183 |
182 out_ << "build "; | 184 out_ << "build "; |
183 path_output_.WriteFile(out_, input_stamp_file); | 185 path_output_.WriteFile(out_, input_stamp_file); |
184 out_ << ": " | 186 out_ << ": " |
185 << GetNinjaRulePrefixForToolchain(settings_) | 187 << GetNinjaRulePrefixForToolchain(settings_) |
186 << Toolchain::ToolTypeToName(Toolchain::TYPE_STAMP); | 188 << Toolchain::ToolTypeToName(Toolchain::TYPE_STAMP); |
187 | 189 |
188 // Script file (if applicable). | 190 // Script file (if applicable). |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 << GetNinjaRulePrefixForToolchain(settings_) | 258 << GetNinjaRulePrefixForToolchain(settings_) |
257 << Toolchain::ToolTypeToName(Toolchain::TYPE_STAMP); | 259 << Toolchain::ToolTypeToName(Toolchain::TYPE_STAMP); |
258 path_output_.WriteFiles(out_, files); | 260 path_output_.WriteFiles(out_, files); |
259 | 261 |
260 if (!order_only_deps.empty()) { | 262 if (!order_only_deps.empty()) { |
261 out_ << " ||"; | 263 out_ << " ||"; |
262 path_output_.WriteFiles(out_, order_only_deps); | 264 path_output_.WriteFiles(out_, order_only_deps); |
263 } | 265 } |
264 out_ << std::endl; | 266 out_ << std::endl; |
265 } | 267 } |
OLD | NEW |