Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(319)

Side by Side Diff: tools/gn/ninja_target_writer.cc

Issue 1704383002: [GN] Don't rewrite files with the same contents (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/gn/function_write_file.cc ('k') | tools/gn/visual_studio_writer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « tools/gn/function_write_file.cc ('k') | tools/gn/visual_studio_writer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698