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

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

Issue 1255113004: Revert of Add output reference to gen written files. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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 | « no previous file | tools/gn/ninja_build_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 <iostream> 5 #include <iostream>
6 #include <sstream> 6 #include <sstream>
7 7
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/strings/string_split.h" 9 #include "base/strings/string_split.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 SourceFile source_file = cur_dir.ResolveRelativeFile(args[0], err, 108 SourceFile source_file = cur_dir.ResolveRelativeFile(args[0], err,
109 scope->settings()->build_settings()->root_path_utf8()); 109 scope->settings()->build_settings()->root_path_utf8());
110 if (err->has_error()) 110 if (err->has_error())
111 return Value(); 111 return Value();
112 if (!EnsureStringIsInOutputDir( 112 if (!EnsureStringIsInOutputDir(
113 scope->settings()->build_settings()->build_dir(), 113 scope->settings()->build_settings()->build_dir(),
114 source_file.value(), args[0].origin(), err)) 114 source_file.value(), args[0].origin(), err))
115 return Value(); 115 return Value();
116 g_scheduler->AddWrittenFile(source_file); // Track that we wrote this file. 116 g_scheduler->AddWrittenFile(source_file); // Track that we wrote this file.
117 117
118 // Track how to recreate this file, since we write it a gen time.
119 // Note this is a hack since the correct output is not a dependency proper,
120 // but an addition of this file to the output of the gn rule that writes it.
121 // This dependency will, however, cause the gen step to be re-run and the
122 // build restarted if the file is missing.
123 g_scheduler->AddGenDependency(
124 scope->settings()->build_settings()->GetFullPath(source_file));
125
118 // Compute output. 126 // Compute output.
119 std::ostringstream contents; 127 std::ostringstream contents;
120 if (args[1].type() == Value::LIST) { 128 if (args[1].type() == Value::LIST) {
121 const std::vector<Value>& list = args[1].list_value(); 129 const std::vector<Value>& list = args[1].list_value();
122 for (const auto& cur : list) 130 for (const auto& cur : list)
123 contents << cur.ToString(false) << std::endl; 131 contents << cur.ToString(false) << std::endl;
124 } else { 132 } else {
125 contents << args[1].ToString(false); 133 contents << args[1].ToString(false);
126 } 134 }
127 const std::string& new_contents = contents.str(); 135 const std::string& new_contents = contents.str();
(...skipping 17 matching lines...) Expand all
145 if (DoWriteFile(file_path, new_contents.c_str(), int_size) 153 if (DoWriteFile(file_path, new_contents.c_str(), int_size)
146 != int_size) { 154 != int_size) {
147 *err = Err(function->function(), "Unable to write file.", 155 *err = Err(function->function(), "Unable to write file.",
148 "I was writing \"" + FilePathToUTF8(file_path) + "\"."); 156 "I was writing \"" + FilePathToUTF8(file_path) + "\".");
149 return Value(); 157 return Value();
150 } 158 }
151 return Value(); 159 return Value();
152 } 160 }
153 161
154 } // namespace functions 162 } // namespace functions
OLDNEW
« no previous file with comments | « no previous file | tools/gn/ninja_build_writer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698