OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/build_settings.h" | 5 #include "tools/gn/build_settings.h" |
6 #include "tools/gn/functions.h" | 6 #include "tools/gn/functions.h" |
7 #include "tools/gn/parse_tree.h" | 7 #include "tools/gn/parse_tree.h" |
8 #include "tools/gn/settings.h" | 8 #include "tools/gn/settings.h" |
9 #include "tools/gn/substitution_writer.h" | 9 #include "tools/gn/substitution_writer.h" |
10 #include "tools/gn/target.h" | 10 #include "tools/gn/target.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 | 85 |
86 // Find the referenced target. The targets previously encountered in this | 86 // Find the referenced target. The targets previously encountered in this |
87 // scope will have been stashed in the item collector (they'll be dispatched | 87 // scope will have been stashed in the item collector (they'll be dispatched |
88 // when this file is done running) so we can look through them. | 88 // when this file is done running) so we can look through them. |
89 const Target* target = NULL; | 89 const Target* target = NULL; |
90 Scope::ItemVector* collector = scope->GetItemCollector(); | 90 Scope::ItemVector* collector = scope->GetItemCollector(); |
91 if (!collector) { | 91 if (!collector) { |
92 *err = Err(function, "No targets defined in this context."); | 92 *err = Err(function, "No targets defined in this context."); |
93 return Value(); | 93 return Value(); |
94 } | 94 } |
95 for (const auto& cur : *collector) { | 95 for (const auto& item : *collector) { |
96 const Item* item = cur->get(); | |
97 if (item->label() != label) | 96 if (item->label() != label) |
98 continue; | 97 continue; |
99 | 98 |
100 const Target* as_target = item->AsTarget(); | 99 const Target* as_target = item->AsTarget(); |
101 if (!as_target) { | 100 if (!as_target) { |
102 *err = Err(function, "Label does not refer to a target.", | 101 *err = Err(function, "Label does not refer to a target.", |
103 label.GetUserVisibleName(false) + | 102 label.GetUserVisibleName(false) + |
104 "\nrefers to a " + item->GetItemTypeName()); | 103 "\nrefers to a " + item->GetItemTypeName()); |
105 return Value(); | 104 return Value(); |
106 } | 105 } |
(...skipping 25 matching lines...) Expand all Loading... |
132 // Convert to Values. | 131 // Convert to Values. |
133 Value ret(function, Value::LIST); | 132 Value ret(function, Value::LIST); |
134 ret.list_value().reserve(files.size()); | 133 ret.list_value().reserve(files.size()); |
135 for (const auto& file : files) | 134 for (const auto& file : files) |
136 ret.list_value().push_back(Value(function, file.value())); | 135 ret.list_value().push_back(Value(function, file.value())); |
137 | 136 |
138 return ret; | 137 return ret; |
139 } | 138 } |
140 | 139 |
141 } // namespace functions | 140 } // namespace functions |
OLD | NEW |