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/functions.h" | 5 #include "tools/gn/functions.h" |
6 #include "tools/gn/parse_tree.h" | 6 #include "tools/gn/parse_tree.h" |
7 #include "tools/gn/scope.h" | 7 #include "tools/gn/scope.h" |
8 #include "tools/gn/settings.h" | 8 #include "tools/gn/settings.h" |
9 #include "tools/gn/substitution_list.h" | 9 #include "tools/gn/substitution_list.h" |
10 #include "tools/gn/substitution_writer.h" | 10 #include "tools/gn/substitution_writer.h" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 if (!subst.Parse(list, template_arg.origin(), err)) | 86 if (!subst.Parse(list, template_arg.origin(), err)) |
87 return Value(); | 87 return Value(); |
88 } else if (template_arg.type() == Value::LIST) { | 88 } else if (template_arg.type() == Value::LIST) { |
89 if (!subst.Parse(template_arg, err)) | 89 if (!subst.Parse(template_arg, err)) |
90 return Value(); | 90 return Value(); |
91 } else { | 91 } else { |
92 *err = Err(template_arg, "Not a string or a list."); | 92 *err = Err(template_arg, "Not a string or a list."); |
93 return Value(); | 93 return Value(); |
94 } | 94 } |
95 | 95 |
| 96 auto& types = subst.required_types(); |
| 97 if (std::find(types.begin(), types.end(), |
| 98 SUBSTITUTION_SOURCE_TARGET_RELATIVE) != types.end()) { |
| 99 *err = Err(template_arg, "Not a valid substitution type for the function."); |
| 100 return Value(); |
| 101 } |
| 102 |
96 SubstitutionWriter::ApplyListToSourcesAsString( | 103 SubstitutionWriter::ApplyListToSourcesAsString( |
97 scope->settings(), subst, input_files, &result_files); | 104 nullptr, scope->settings(), subst, input_files, &result_files); |
98 | 105 |
99 // Convert the list of strings to the return Value. | 106 // Convert the list of strings to the return Value. |
100 Value ret(function, Value::LIST); | 107 Value ret(function, Value::LIST); |
101 ret.list_value().reserve(result_files.size()); | 108 ret.list_value().reserve(result_files.size()); |
102 for (const auto& file : result_files) | 109 for (const auto& file : result_files) |
103 ret.list_value().push_back(Value(function, file)); | 110 ret.list_value().push_back(Value(function, file)); |
104 | 111 |
105 return ret; | 112 return ret; |
106 } | 113 } |
107 | 114 |
108 } // namespace functions | 115 } // namespace functions |
OLD | NEW |