| 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_utf8(), |
| 33 ESCAPE_NINJA) { |
| 32 } | 34 } |
| 33 | 35 |
| 34 NinjaTargetWriter::~NinjaTargetWriter() { | 36 NinjaTargetWriter::~NinjaTargetWriter() { |
| 35 } | 37 } |
| 36 | 38 |
| 37 // static | 39 // static |
| 38 void NinjaTargetWriter::RunAndWriteFile(const Target* target) { | 40 void NinjaTargetWriter::RunAndWriteFile(const Target* target) { |
| 39 const Settings* settings = target->settings(); | 41 const Settings* settings = target->settings(); |
| 40 | 42 |
| 41 ScopedTrace trace(TraceItem::TRACE_FILE_WRITE, | 43 ScopedTrace trace(TraceItem::TRACE_FILE_WRITE, |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 return OutputFile(); // No input/hard deps. | 169 return OutputFile(); // No input/hard deps. |
| 168 | 170 |
| 169 // One potential optimization is if there are few input dependencies (or | 171 // 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 | 172 // 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 | 173 // 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 | 174 // 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 | 175 // source file can really explode the ninja file but this won't be the most |
| 174 // optimal thing in all cases. | 176 // optimal thing in all cases. |
| 175 | 177 |
| 176 OutputFile input_stamp_file( | 178 OutputFile input_stamp_file( |
| 177 RebaseSourceAbsolutePath(GetTargetOutputDir(target_).value(), | 179 RebasePath(GetTargetOutputDir(target_).value(), |
| 178 settings_->build_settings()->build_dir())); | 180 settings_->build_settings()->build_dir(), |
| 181 settings_->build_settings()->root_path_utf8())); |
| 179 input_stamp_file.value().append(target_->label().name()); | 182 input_stamp_file.value().append(target_->label().name()); |
| 180 input_stamp_file.value().append(".inputdeps.stamp"); | 183 input_stamp_file.value().append(".inputdeps.stamp"); |
| 181 | 184 |
| 182 out_ << "build "; | 185 out_ << "build "; |
| 183 path_output_.WriteFile(out_, input_stamp_file); | 186 path_output_.WriteFile(out_, input_stamp_file); |
| 184 out_ << ": " | 187 out_ << ": " |
| 185 << GetNinjaRulePrefixForToolchain(settings_) | 188 << GetNinjaRulePrefixForToolchain(settings_) |
| 186 << Toolchain::ToolTypeToName(Toolchain::TYPE_STAMP); | 189 << Toolchain::ToolTypeToName(Toolchain::TYPE_STAMP); |
| 187 | 190 |
| 188 // Script file (if applicable). | 191 // Script file (if applicable). |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 << GetNinjaRulePrefixForToolchain(settings_) | 259 << GetNinjaRulePrefixForToolchain(settings_) |
| 257 << Toolchain::ToolTypeToName(Toolchain::TYPE_STAMP); | 260 << Toolchain::ToolTypeToName(Toolchain::TYPE_STAMP); |
| 258 path_output_.WriteFiles(out_, files); | 261 path_output_.WriteFiles(out_, files); |
| 259 | 262 |
| 260 if (!order_only_deps.empty()) { | 263 if (!order_only_deps.empty()) { |
| 261 out_ << " ||"; | 264 out_ << " ||"; |
| 262 path_output_.WriteFiles(out_, order_only_deps); | 265 path_output_.WriteFiles(out_, order_only_deps); |
| 263 } | 266 } |
| 264 out_ << std::endl; | 267 out_ << std::endl; |
| 265 } | 268 } |
| OLD | NEW |