| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/runtime_deps.h" | 5 #include "tools/gn/runtime_deps.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <sstream> | 9 #include <sstream> |
| 10 | 10 |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 if (!base::ReadFileToString(UTF8ToFilePath(deps_target_list_file), | 234 if (!base::ReadFileToString(UTF8ToFilePath(deps_target_list_file), |
| 235 &list_contents)) { | 235 &list_contents)) { |
| 236 *err = Err(Location(), | 236 *err = Err(Location(), |
| 237 std::string("File for --") + switches::kRuntimeDepsListFile + | 237 std::string("File for --") + switches::kRuntimeDepsListFile + |
| 238 " doesn't exist.", | 238 " doesn't exist.", |
| 239 "The file given was \"" + deps_target_list_file + "\""); | 239 "The file given was \"" + deps_target_list_file + "\""); |
| 240 return false; | 240 return false; |
| 241 } | 241 } |
| 242 load_trace.Done(); | 242 load_trace.Done(); |
| 243 | 243 |
| 244 std::vector<std::string> lines; | |
| 245 base::SplitString(list_contents, '\n', &lines); | |
| 246 | |
| 247 SourceDir root_dir("//"); | 244 SourceDir root_dir("//"); |
| 248 Label default_toolchain_label = builder.loader()->GetDefaultToolchain(); | 245 Label default_toolchain_label = builder.loader()->GetDefaultToolchain(); |
| 249 for (const auto& line : lines) { | 246 for (const auto& line : base::SplitString( |
| 247 list_contents, "\n", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) { |
| 250 if (line.empty()) | 248 if (line.empty()) |
| 251 continue; | 249 continue; |
| 252 Label label = Label::Resolve(root_dir, default_toolchain_label, | 250 Label label = Label::Resolve(root_dir, default_toolchain_label, |
| 253 Value(nullptr, line), err); | 251 Value(nullptr, line), err); |
| 254 if (err->has_error()) | 252 if (err->has_error()) |
| 255 return false; | 253 return false; |
| 256 | 254 |
| 257 const Item* item = builder.GetItem(label); | 255 const Item* item = builder.GetItem(label); |
| 258 const Target* target = item ? item->AsTarget() : nullptr; | 256 const Target* target = item ? item->AsTarget() : nullptr; |
| 259 if (!target) { | 257 if (!target) { |
| 260 *err = Err(Location(), "The label \"" + label.GetUserVisibleName(true) + | 258 *err = Err(Location(), "The label \"" + label.GetUserVisibleName(true) + |
| 261 "\" isn't a target.", | 259 "\" isn't a target.", |
| 262 "When reading the line:\n " + line + "\n" | 260 "When reading the line:\n " + line + "\n" |
| 263 "from the --" + switches::kRuntimeDepsListFile + "=" + | 261 "from the --" + switches::kRuntimeDepsListFile + "=" + |
| 264 deps_target_list_file); | 262 deps_target_list_file); |
| 265 return false; | 263 return false; |
| 266 } | 264 } |
| 267 | 265 |
| 268 // Currently this writes all runtime deps files sequentially. We generally | 266 // Currently this writes all runtime deps files sequentially. We generally |
| 269 // expect few of these. We can run this on the worker pool if it looks | 267 // expect few of these. We can run this on the worker pool if it looks |
| 270 // like it's talking a long time. | 268 // like it's talking a long time. |
| 271 WriteRuntimeDepsFile(target); | 269 WriteRuntimeDepsFile(target); |
| 272 } | 270 } |
| 273 return true; | 271 return true; |
| 274 } | 272 } |
| OLD | NEW |