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 <sstream> | 7 #include <sstream> |
8 | 8 |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 } else if (target->output_type() == Target::GROUP) { | 67 } else if (target->output_type() == Target::GROUP) { |
68 NinjaGroupTargetWriter writer(target, file); | 68 NinjaGroupTargetWriter writer(target, file); |
69 writer.Run(); | 69 writer.Run(); |
70 } else if (target->IsBinary()) { | 70 } else if (target->IsBinary()) { |
71 NinjaBinaryTargetWriter writer(target, file); | 71 NinjaBinaryTargetWriter writer(target, file); |
72 writer.Run(); | 72 writer.Run(); |
73 } else { | 73 } else { |
74 CHECK(0) << "Output type of target not handled."; | 74 CHECK(0) << "Output type of target not handled."; |
75 } | 75 } |
76 | 76 |
77 std::string contents = file.str(); | 77 WriteFileIfChanged(ninja_file, file.str(), nullptr); |
78 base::WriteFile(ninja_file, contents.c_str(), | |
79 static_cast<int>(contents.size())); | |
80 } | 78 } |
81 | 79 |
82 void NinjaTargetWriter::WriteEscapedSubstitution(SubstitutionType type) { | 80 void NinjaTargetWriter::WriteEscapedSubstitution(SubstitutionType type) { |
83 EscapeOptions opts; | 81 EscapeOptions opts; |
84 opts.mode = ESCAPE_NINJA; | 82 opts.mode = ESCAPE_NINJA; |
85 | 83 |
86 out_ << kSubstitutionNinjaNames[type] << " = "; | 84 out_ << kSubstitutionNinjaNames[type] << " = "; |
87 EscapeStringToStream(out_, | 85 EscapeStringToStream(out_, |
88 SubstitutionWriter::GetTargetSubstitution(target_, type), | 86 SubstitutionWriter::GetTargetSubstitution(target_, type), |
89 opts); | 87 opts); |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 << GetNinjaRulePrefixForToolchain(settings_) | 272 << GetNinjaRulePrefixForToolchain(settings_) |
275 << Toolchain::ToolTypeToName(Toolchain::TYPE_STAMP); | 273 << Toolchain::ToolTypeToName(Toolchain::TYPE_STAMP); |
276 path_output_.WriteFiles(out_, files); | 274 path_output_.WriteFiles(out_, files); |
277 | 275 |
278 if (!order_only_deps.empty()) { | 276 if (!order_only_deps.empty()) { |
279 out_ << " ||"; | 277 out_ << " ||"; |
280 path_output_.WriteFiles(out_, order_only_deps); | 278 path_output_.WriteFiles(out_, order_only_deps); |
281 } | 279 } |
282 out_ << std::endl; | 280 out_ << std::endl; |
283 } | 281 } |
OLD | NEW |