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/import_manager.h" | 5 #include "tools/gn/import_manager.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include <memory> |
| 8 |
8 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
9 #include "tools/gn/parse_tree.h" | 10 #include "tools/gn/parse_tree.h" |
10 #include "tools/gn/scheduler.h" | 11 #include "tools/gn/scheduler.h" |
11 #include "tools/gn/scope_per_file_provider.h" | 12 #include "tools/gn/scope_per_file_provider.h" |
12 | 13 |
13 namespace { | 14 namespace { |
14 | 15 |
15 // Returns a newly-allocated scope on success, null on failure. | 16 // Returns a newly-allocated scope on success, null on failure. |
16 Scope* UncachedImport(const Settings* settings, | 17 Scope* UncachedImport(const Settings* settings, |
17 const SourceFile& file, | 18 const SourceFile& file, |
18 const ParseNode* node_for_err, | 19 const ParseNode* node_for_err, |
19 Err* err) { | 20 Err* err) { |
20 const ParseNode* node = g_scheduler->input_file_manager()->SyncLoadFile( | 21 const ParseNode* node = g_scheduler->input_file_manager()->SyncLoadFile( |
21 node_for_err->GetRange(), settings->build_settings(), file, err); | 22 node_for_err->GetRange(), settings->build_settings(), file, err); |
22 if (!node) | 23 if (!node) |
23 return nullptr; | 24 return nullptr; |
24 | 25 |
25 scoped_ptr<Scope> scope(new Scope(settings->base_config())); | 26 std::unique_ptr<Scope> scope(new Scope(settings->base_config())); |
26 scope->set_source_dir(file.GetDir()); | 27 scope->set_source_dir(file.GetDir()); |
27 | 28 |
28 // Don't allow ScopePerFileProvider to provide target-related variables. | 29 // Don't allow ScopePerFileProvider to provide target-related variables. |
29 // These will be relative to the imported file, which is probably not what | 30 // These will be relative to the imported file, which is probably not what |
30 // people mean when they use these. | 31 // people mean when they use these. |
31 ScopePerFileProvider per_file_provider(scope.get(), false); | 32 ScopePerFileProvider per_file_provider(scope.get(), false); |
32 | 33 |
33 scope->SetProcessingImport(); | 34 scope->SetProcessingImport(); |
34 node->Execute(scope.get(), err); | 35 node->Execute(scope.get(), err); |
35 if (err->has_error()) | 36 if (err->has_error()) |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 } | 84 } |
84 } | 85 } |
85 } | 86 } |
86 | 87 |
87 Scope::MergeOptions options; | 88 Scope::MergeOptions options; |
88 options.skip_private_vars = true; | 89 options.skip_private_vars = true; |
89 options.mark_dest_used = true; // Don't require all imported values be used. | 90 options.mark_dest_used = true; // Don't require all imported values be used. |
90 return imported_scope->NonRecursiveMergeTo(scope, options, node_for_err, | 91 return imported_scope->NonRecursiveMergeTo(scope, options, node_for_err, |
91 "import", err); | 92 "import", err); |
92 } | 93 } |
OLD | NEW |