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/file_template.h" | 6 #include "tools/gn/file_template.h" |
7 #include "tools/gn/functions.h" | 7 #include "tools/gn/functions.h" |
8 #include "tools/gn/ninja_helper.h" | 8 #include "tools/gn/ninja_helper.h" |
9 #include "tools/gn/parse_tree.h" | 9 #include "tools/gn/parse_tree.h" |
10 #include "tools/gn/settings.h" | 10 #include "tools/gn/settings.h" |
11 #include "tools/gn/target.h" | 11 #include "tools/gn/target.h" |
12 #include "tools/gn/value.h" | 12 #include "tools/gn/value.h" |
13 | 13 |
14 namespace functions { | 14 namespace functions { |
15 | 15 |
16 namespace { | 16 namespace { |
17 | 17 |
18 void GetOutputsForTarget(const Settings* settings, | 18 void GetOutputsForTarget(const Settings* settings, |
19 const Target* target, | 19 const Target* target, |
20 std::vector<std::string>* ret) { | 20 std::vector<std::string>* ret) { |
21 switch (target->output_type()) { | 21 switch (target->output_type()) { |
22 case Target::ACTION: | 22 case Target::ACTION: { |
23 case Target::COPY_FILES: { | 23 // Actions: return the outputs specified. |
24 // Actions and copy targets: return the outputs specified. | 24 const std::vector<std::string>& outs = target->action_values().outputs(); |
25 const std::vector<SourceFile>& outs = target->action_values().outputs(); | |
26 ret->reserve(outs.size()); | 25 ret->reserve(outs.size()); |
27 for (size_t i = 0; i < outs.size(); i++) | 26 for (size_t i = 0; i < outs.size(); i++) |
28 ret->push_back(outs[i].value()); | 27 ret->push_back(outs[i]); |
29 break; | 28 break; |
30 } | 29 } |
31 | 30 |
| 31 case Target::COPY_FILES: |
32 case Target::ACTION_FOREACH: { | 32 case Target::ACTION_FOREACH: { |
33 // Action_foreach: return the result of the template in the outputs. | 33 // Copy/action_foreach: return the result of the template in the outputs. |
34 FileTemplate file_template(settings, target->action_values().outputs()); | 34 FileTemplate file_template(settings, target->action_values().outputs(), |
| 35 FileTemplate::OUTPUT_ABSOLUTE, SourceDir()); |
35 const std::vector<SourceFile>& sources = target->sources(); | 36 const std::vector<SourceFile>& sources = target->sources(); |
36 for (size_t i = 0; i < sources.size(); i++) | 37 for (size_t i = 0; i < sources.size(); i++) |
37 file_template.Apply(sources[i], ret); | 38 file_template.Apply(sources[i], ret); |
38 break; | 39 break; |
39 } | 40 } |
40 | 41 |
41 case Target::EXECUTABLE: | 42 case Target::EXECUTABLE: |
42 case Target::SHARED_LIBRARY: | 43 case Target::SHARED_LIBRARY: |
43 case Target::STATIC_LIBRARY: | 44 case Target::STATIC_LIBRARY: |
44 // Return the resulting binary file. Currently, fall through to the | 45 // Return the resulting binary file. Currently, fall through to the |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 | 174 |
174 Value ret(function, Value::LIST); | 175 Value ret(function, Value::LIST); |
175 ret.list_value().reserve(files.size()); | 176 ret.list_value().reserve(files.size()); |
176 for (size_t i = 0; i < files.size(); i++) | 177 for (size_t i = 0; i < files.size(); i++) |
177 ret.list_value().push_back(Value(function, files[i])); | 178 ret.list_value().push_back(Value(function, files[i])); |
178 | 179 |
179 return ret; | 180 return ret; |
180 } | 181 } |
181 | 182 |
182 } // namespace functions | 183 } // namespace functions |
OLD | NEW |