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/loader.h" | 5 #include "tools/gn/loader.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/single_thread_task_runner.h" |
10 #include "tools/gn/build_settings.h" | 11 #include "tools/gn/build_settings.h" |
11 #include "tools/gn/err.h" | 12 #include "tools/gn/err.h" |
12 #include "tools/gn/filesystem_utils.h" | 13 #include "tools/gn/filesystem_utils.h" |
13 #include "tools/gn/input_file_manager.h" | 14 #include "tools/gn/input_file_manager.h" |
14 #include "tools/gn/parse_tree.h" | 15 #include "tools/gn/parse_tree.h" |
15 #include "tools/gn/scheduler.h" | 16 #include "tools/gn/scheduler.h" |
16 #include "tools/gn/scope_per_file_provider.h" | 17 #include "tools/gn/scope_per_file_provider.h" |
17 #include "tools/gn/settings.h" | 18 #include "tools/gn/settings.h" |
18 #include "tools/gn/source_dir.h" | 19 #include "tools/gn/source_dir.h" |
19 #include "tools/gn/source_file.h" | 20 #include "tools/gn/source_file.h" |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 g_scheduler->FailWithError(err); | 232 g_scheduler->FailWithError(err); |
232 DecrementPendingLoads(); | 233 DecrementPendingLoads(); |
233 } | 234 } |
234 } | 235 } |
235 | 236 |
236 void LoaderImpl::BackgroundLoadFile(const Settings* settings, | 237 void LoaderImpl::BackgroundLoadFile(const Settings* settings, |
237 const SourceFile& file_name, | 238 const SourceFile& file_name, |
238 const LocationRange& origin, | 239 const LocationRange& origin, |
239 const ParseNode* root) { | 240 const ParseNode* root) { |
240 if (!root) { | 241 if (!root) { |
241 main_loop_->PostTask(FROM_HERE, | 242 main_loop_->task_runner()->PostTask( |
242 base::Bind(&LoaderImpl::DecrementPendingLoads, this)); | 243 FROM_HERE, base::Bind(&LoaderImpl::DecrementPendingLoads, this)); |
243 return; | 244 return; |
244 } | 245 } |
245 | 246 |
246 if (g_scheduler->verbose_logging()) { | 247 if (g_scheduler->verbose_logging()) { |
247 g_scheduler->Log("Running", file_name.value() + " with toolchain " + | 248 g_scheduler->Log("Running", file_name.value() + " with toolchain " + |
248 settings->toolchain_label().GetUserVisibleName(false)); | 249 settings->toolchain_label().GetUserVisibleName(false)); |
249 } | 250 } |
250 | 251 |
251 Scope our_scope(settings->base_config()); | 252 Scope our_scope(settings->base_config()); |
252 ScopePerFileProvider per_file_provider(&our_scope, true); | 253 ScopePerFileProvider per_file_provider(&our_scope, true); |
(...skipping 19 matching lines...) Expand all Loading... |
272 | 273 |
273 | 274 |
274 // Pass all of the items that were defined off to the builder. | 275 // Pass all of the items that were defined off to the builder. |
275 for (auto& item : collected_items) { | 276 for (auto& item : collected_items) { |
276 settings->build_settings()->ItemDefined(base::WrapUnique(item)); | 277 settings->build_settings()->ItemDefined(base::WrapUnique(item)); |
277 item = nullptr; | 278 item = nullptr; |
278 } | 279 } |
279 | 280 |
280 trace.Done(); | 281 trace.Done(); |
281 | 282 |
282 main_loop_->PostTask(FROM_HERE, base::Bind(&LoaderImpl::DidLoadFile, this)); | 283 main_loop_->task_runner()->PostTask( |
| 284 FROM_HERE, base::Bind(&LoaderImpl::DidLoadFile, this)); |
283 } | 285 } |
284 | 286 |
285 void LoaderImpl::BackgroundLoadBuildConfig( | 287 void LoaderImpl::BackgroundLoadBuildConfig( |
286 Settings* settings, | 288 Settings* settings, |
287 const Scope::KeyValueMap& toolchain_overrides, | 289 const Scope::KeyValueMap& toolchain_overrides, |
288 const ParseNode* root) { | 290 const ParseNode* root) { |
289 if (!root) { | 291 if (!root) { |
290 main_loop_->PostTask(FROM_HERE, | 292 main_loop_->task_runner()->PostTask( |
291 base::Bind(&LoaderImpl::DecrementPendingLoads, this)); | 293 FROM_HERE, base::Bind(&LoaderImpl::DecrementPendingLoads, this)); |
292 return; | 294 return; |
293 } | 295 } |
294 | 296 |
295 Scope* base_config = settings->base_config(); | 297 Scope* base_config = settings->base_config(); |
296 base_config->set_source_dir(SourceDir("//")); | 298 base_config->set_source_dir(SourceDir("//")); |
297 | 299 |
298 settings->build_settings()->build_args().SetupRootScope( | 300 settings->build_settings()->build_args().SetupRootScope( |
299 base_config, toolchain_overrides); | 301 base_config, toolchain_overrides); |
300 | 302 |
301 base_config->SetProcessingBuildConfig(); | 303 base_config->SetProcessingBuildConfig(); |
(...skipping 28 matching lines...) Expand all Loading... |
330 g_scheduler->FailWithError(Err(Location(), | 332 g_scheduler->FailWithError(Err(Location(), |
331 "The default build config file did not call set_default_toolchain()", | 333 "The default build config file did not call set_default_toolchain()", |
332 "If you don't call this, I can't figure out what toolchain to use\n" | 334 "If you don't call this, I can't figure out what toolchain to use\n" |
333 "for all of this code.")); | 335 "for all of this code.")); |
334 } else { | 336 } else { |
335 DCHECK(settings->toolchain_label().is_null()); | 337 DCHECK(settings->toolchain_label().is_null()); |
336 settings->set_toolchain_label(default_toolchain_label); | 338 settings->set_toolchain_label(default_toolchain_label); |
337 } | 339 } |
338 } | 340 } |
339 | 341 |
340 main_loop_->PostTask(FROM_HERE, | 342 main_loop_->task_runner()->PostTask( |
341 base::Bind(&LoaderImpl::DidLoadBuildConfig, this, | 343 FROM_HERE, base::Bind(&LoaderImpl::DidLoadBuildConfig, this, |
342 settings->toolchain_label())); | 344 settings->toolchain_label())); |
343 } | 345 } |
344 | 346 |
345 void LoaderImpl::DidLoadFile() { | 347 void LoaderImpl::DidLoadFile() { |
346 DecrementPendingLoads(); | 348 DecrementPendingLoads(); |
347 } | 349 } |
348 | 350 |
349 void LoaderImpl::DidLoadBuildConfig(const Label& label) { | 351 void LoaderImpl::DidLoadBuildConfig(const Label& label) { |
350 // Do not return early, we must call DecrementPendingLoads() at the bottom. | 352 // Do not return early, we must call DecrementPendingLoads() at the bottom. |
351 | 353 |
352 ToolchainRecordMap::iterator found_toolchain = toolchain_records_.find(label); | 354 ToolchainRecordMap::iterator found_toolchain = toolchain_records_.find(label); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 const SourceFile& file_name, | 421 const SourceFile& file_name, |
420 const base::Callback<void(const ParseNode*)>& callback, | 422 const base::Callback<void(const ParseNode*)>& callback, |
421 Err* err) { | 423 Err* err) { |
422 if (async_load_file_.is_null()) { | 424 if (async_load_file_.is_null()) { |
423 return g_scheduler->input_file_manager()->AsyncLoadFile( | 425 return g_scheduler->input_file_manager()->AsyncLoadFile( |
424 origin, build_settings, file_name, callback, err); | 426 origin, build_settings, file_name, callback, err); |
425 } | 427 } |
426 return async_load_file_.Run( | 428 return async_load_file_.Run( |
427 origin, build_settings, file_name, callback, err); | 429 origin, build_settings, file_name, callback, err); |
428 } | 430 } |
OLD | NEW |