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

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

Issue 1252403005: Add output reference to gen written files. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: do not escape paths in build.ninja.d 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') | tools/gn/ninja_build_writer.cc » ('J')
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
126 // Compute output. 118 // Compute output.
127 std::ostringstream contents; 119 std::ostringstream contents;
128 if (args[1].type() == Value::LIST) { 120 if (args[1].type() == Value::LIST) {
129 const std::vector<Value>& list = args[1].list_value(); 121 const std::vector<Value>& list = args[1].list_value();
130 for (const auto& cur : list) 122 for (const auto& cur : list)
131 contents << cur.ToString(false) << std::endl; 123 contents << cur.ToString(false) << std::endl;
132 } else { 124 } else {
133 contents << args[1].ToString(false); 125 contents << args[1].ToString(false);
134 } 126 }
135 const std::string& new_contents = contents.str(); 127 const std::string& new_contents = contents.str();
(...skipping 17 matching lines...) Expand all
153 if (DoWriteFile(file_path, new_contents.c_str(), int_size) 145 if (DoWriteFile(file_path, new_contents.c_str(), int_size)
154 != int_size) { 146 != int_size) {
155 *err = Err(function->function(), "Unable to write file.", 147 *err = Err(function->function(), "Unable to write file.",
156 "I was writing \"" + FilePathToUTF8(file_path) + "\"."); 148 "I was writing \"" + FilePathToUTF8(file_path) + "\".");
157 return Value(); 149 return Value();
158 } 150 }
159 return Value(); 151 return Value();
160 } 152 }
161 153
162 } // namespace functions 154 } // namespace functions
OLDNEW
« no previous file with comments | « no previous file | tools/gn/ninja_build_writer.cc » ('j') | tools/gn/ninja_build_writer.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698