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 (size_t i = 0; i < collector->size(); i++) { | 95 for (const auto& cur : *collector) { |
96 const Item* item = (*collector)[i]->get(); | 96 const Item* item = cur->get(); |
97 if (item->label() != label) | 97 if (item->label() != label) |
98 continue; | 98 continue; |
99 | 99 |
100 const Target* as_target = item->AsTarget(); | 100 const Target* as_target = item->AsTarget(); |
101 if (!as_target) { | 101 if (!as_target) { |
102 *err = Err(function, "Label does not refer to a target.", | 102 *err = Err(function, "Label does not refer to a target.", |
103 label.GetUserVisibleName(false) + | 103 label.GetUserVisibleName(false) + |
104 "\nrefers to a " + item->GetItemTypeName()); | 104 "\nrefers to a " + item->GetItemTypeName()); |
105 return Value(); | 105 return Value(); |
106 } | 106 } |
(...skipping 18 matching lines...) Expand all Loading... |
125 } else { | 125 } else { |
126 // Other types of targets are not supported. | 126 // Other types of targets are not supported. |
127 *err = Err(args[0], "Target is not an action, action_foreach, or copy.", | 127 *err = Err(args[0], "Target is not an action, action_foreach, or copy.", |
128 "Only these target types are supported by get_target_outputs."); | 128 "Only these target types are supported by get_target_outputs."); |
129 return Value(); | 129 return Value(); |
130 } | 130 } |
131 | 131 |
132 // Convert to Values. | 132 // Convert to Values. |
133 Value ret(function, Value::LIST); | 133 Value ret(function, Value::LIST); |
134 ret.list_value().reserve(files.size()); | 134 ret.list_value().reserve(files.size()); |
135 for (size_t i = 0; i < files.size(); i++) | 135 for (const auto& file : files) |
136 ret.list_value().push_back(Value(function, files[i].value())); | 136 ret.list_value().push_back(Value(function, file.value())); |
137 | 137 |
138 return ret; | 138 return ret; |
139 } | 139 } |
140 | 140 |
141 } // namespace functions | 141 } // namespace functions |
OLD | NEW |