| 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 "tools/gn/input_file_manager.h" | 5 #include "tools/gn/input_file_manager.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "tools/gn/filesystem_utils.h" | 9 #include "tools/gn/filesystem_utils.h" |
| 10 #include "tools/gn/parser.h" | 10 #include "tools/gn/parser.h" |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 g_scheduler->FailWithError(err); | 187 g_scheduler->FailWithError(err); |
| 188 } | 188 } |
| 189 | 189 |
| 190 bool InputFileManager::LoadFile(const LocationRange& origin, | 190 bool InputFileManager::LoadFile(const LocationRange& origin, |
| 191 const BuildSettings* build_settings, | 191 const BuildSettings* build_settings, |
| 192 const SourceFile& name, | 192 const SourceFile& name, |
| 193 InputFile* file, | 193 InputFile* file, |
| 194 Err* err) { | 194 Err* err) { |
| 195 // Do all of this stuff outside the lock. We should not give out file | 195 // Do all of this stuff outside the lock. We should not give out file |
| 196 // pointers until the read is complete. | 196 // pointers until the read is complete. |
| 197 if (g_scheduler->verbose_logging()) | 197 if (g_scheduler->verbose_logging()) { |
| 198 g_scheduler->Log("Loading", name.value()); | 198 std::string logmsg = name.value(); |
| 199 if (origin.begin().file()) |
| 200 logmsg += " (referenced from " + origin.begin().Describe(false) + ")"; |
| 201 g_scheduler->Log("Loading", logmsg); |
| 202 } |
| 199 | 203 |
| 200 // Read. | 204 // Read. |
| 201 base::FilePath primary_path = build_settings->GetFullPath(name); | 205 base::FilePath primary_path = build_settings->GetFullPath(name); |
| 202 if (!file->Load(primary_path)) { | 206 if (!file->Load(primary_path)) { |
| 203 if (!build_settings->secondary_source_path().empty()) { | 207 if (!build_settings->secondary_source_path().empty()) { |
| 204 // Fall back to secondary source tree. | 208 // Fall back to secondary source tree. |
| 205 base::FilePath secondary_path = | 209 base::FilePath secondary_path = |
| 206 build_settings->GetFullPathSecondary(name); | 210 build_settings->GetFullPathSecondary(name); |
| 207 if (!file->Load(secondary_path)) { | 211 if (!file->Load(secondary_path)) { |
| 208 *err = Err(origin, "Can't load input file.", | 212 *err = Err(origin, "Can't load input file.", |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 callbacks.swap(data->scheduled_callbacks); | 260 callbacks.swap(data->scheduled_callbacks); |
| 257 } | 261 } |
| 258 | 262 |
| 259 // Run pending invocations. Theoretically we could schedule each of these | 263 // Run pending invocations. Theoretically we could schedule each of these |
| 260 // separately to get some parallelism. But normally there will only be one | 264 // separately to get some parallelism. But normally there will only be one |
| 261 // item in the list, so that's extra overhead and complexity for no gain. | 265 // item in the list, so that's extra overhead and complexity for no gain. |
| 262 for (size_t i = 0; i < callbacks.size(); i++) | 266 for (size_t i = 0; i < callbacks.size(); i++) |
| 263 callbacks[i].Run(unowned_root); | 267 callbacks[i].Run(unowned_root); |
| 264 return true; | 268 return true; |
| 265 } | 269 } |
| OLD | NEW |