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/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "tools/gn/build_settings.h" | 10 #include "tools/gn/build_settings.h" |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 | 240 |
241 if (g_scheduler->verbose_logging()) { | 241 if (g_scheduler->verbose_logging()) { |
242 g_scheduler->Log("Running", file_name.value() + " with toolchain " + | 242 g_scheduler->Log("Running", file_name.value() + " with toolchain " + |
243 settings->toolchain_label().GetUserVisibleName(false)); | 243 settings->toolchain_label().GetUserVisibleName(false)); |
244 } | 244 } |
245 | 245 |
246 Scope our_scope(settings->base_config()); | 246 Scope our_scope(settings->base_config()); |
247 ScopePerFileProvider per_file_provider(&our_scope, true); | 247 ScopePerFileProvider per_file_provider(&our_scope, true); |
248 our_scope.set_source_dir(file_name.GetDir()); | 248 our_scope.set_source_dir(file_name.GetDir()); |
249 | 249 |
| 250 // Targets, etc. generated as part of running this file will end up here. |
| 251 Scope::ItemVector collected_items; |
| 252 our_scope.set_item_collector(&collected_items); |
| 253 |
250 ScopedTrace trace(TraceItem::TRACE_FILE_EXECUTE, file_name.value()); | 254 ScopedTrace trace(TraceItem::TRACE_FILE_EXECUTE, file_name.value()); |
251 trace.SetToolchain(settings->toolchain_label()); | 255 trace.SetToolchain(settings->toolchain_label()); |
252 | 256 |
253 Err err; | 257 Err err; |
254 root->Execute(&our_scope, &err); | 258 root->Execute(&our_scope, &err); |
255 if (err.has_error()) | 259 if (err.has_error()) |
256 g_scheduler->FailWithError(err); | 260 g_scheduler->FailWithError(err); |
257 | 261 |
| 262 // Pass all of the items that were defined off to the builder. |
| 263 for (size_t i = 0; i < collected_items.size(); i++) |
| 264 settings->build_settings()->ItemDefined(collected_items[i]->Pass()); |
| 265 |
258 trace.Done(); | 266 trace.Done(); |
259 | 267 |
260 main_loop_->PostTask(FROM_HERE, base::Bind(&LoaderImpl::DidLoadFile, this)); | 268 main_loop_->PostTask(FROM_HERE, base::Bind(&LoaderImpl::DidLoadFile, this)); |
261 } | 269 } |
262 | 270 |
263 void LoaderImpl::BackgroundLoadBuildConfig( | 271 void LoaderImpl::BackgroundLoadBuildConfig( |
264 Settings* settings, | 272 Settings* settings, |
265 const Scope::KeyValueMap& toolchain_overrides, | 273 const Scope::KeyValueMap& toolchain_overrides, |
266 const ParseNode* root) { | 274 const ParseNode* root) { |
267 if (!root) { | 275 if (!root) { |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 const SourceFile& file_name, | 400 const SourceFile& file_name, |
393 const base::Callback<void(const ParseNode*)>& callback, | 401 const base::Callback<void(const ParseNode*)>& callback, |
394 Err* err) { | 402 Err* err) { |
395 if (async_load_file_.is_null()) { | 403 if (async_load_file_.is_null()) { |
396 return g_scheduler->input_file_manager()->AsyncLoadFile( | 404 return g_scheduler->input_file_manager()->AsyncLoadFile( |
397 origin, build_settings, file_name, callback, err); | 405 origin, build_settings, file_name, callback, err); |
398 } | 406 } |
399 return async_load_file_.Run( | 407 return async_load_file_.Run( |
400 origin, build_settings, file_name, callback, err); | 408 origin, build_settings, file_name, callback, err); |
401 } | 409 } |
OLD | NEW |