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 <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 Loading... |
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 Loading... |
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 |
OLD | NEW |