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 "tools/gn/parse_tree.h" | 7 #include "tools/gn/parse_tree.h" |
8 #include "tools/gn/scheduler.h" | 8 #include "tools/gn/scheduler.h" |
9 #include "tools/gn/scope_per_file_provider.h" | 9 #include "tools/gn/scope_per_file_provider.h" |
10 | 10 |
(...skipping 12 matching lines...) Expand all Loading... |
23 std::unique_ptr<Scope> scope(new Scope(settings->base_config())); | 23 std::unique_ptr<Scope> scope(new Scope(settings->base_config())); |
24 scope->set_source_dir(file.GetDir()); | 24 scope->set_source_dir(file.GetDir()); |
25 | 25 |
26 // Don't allow ScopePerFileProvider to provide target-related variables. | 26 // Don't allow ScopePerFileProvider to provide target-related variables. |
27 // These will be relative to the imported file, which is probably not what | 27 // These will be relative to the imported file, which is probably not what |
28 // people mean when they use these. | 28 // people mean when they use these. |
29 ScopePerFileProvider per_file_provider(scope.get(), false); | 29 ScopePerFileProvider per_file_provider(scope.get(), false); |
30 | 30 |
31 scope->SetProcessingImport(); | 31 scope->SetProcessingImport(); |
32 node->Execute(scope.get(), err); | 32 node->Execute(scope.get(), err); |
33 if (err->has_error()) | 33 if (err->has_error()) { |
| 34 // If there was an error, append the caller location so the error message |
| 35 // displays a why the file was imported (esp. useful for failed asserts). |
| 36 err->AppendSubErr(Err(node_for_err, "whence it was imported.")); |
34 return nullptr; | 37 return nullptr; |
| 38 } |
35 scope->ClearProcessingImport(); | 39 scope->ClearProcessingImport(); |
36 | 40 |
37 return scope; | 41 return scope; |
38 } | 42 } |
39 | 43 |
40 } // namesapce | 44 } // namesapce |
41 | 45 |
42 ImportManager::ImportManager() { | 46 ImportManager::ImportManager() { |
43 } | 47 } |
44 | 48 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 } | 84 } |
81 } | 85 } |
82 } | 86 } |
83 | 87 |
84 Scope::MergeOptions options; | 88 Scope::MergeOptions options; |
85 options.skip_private_vars = true; | 89 options.skip_private_vars = true; |
86 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. |
87 return imported_scope->NonRecursiveMergeTo(scope, options, node_for_err, | 91 return imported_scope->NonRecursiveMergeTo(scope, options, node_for_err, |
88 "import", err); | 92 "import", err); |
89 } | 93 } |
OLD | NEW |