Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(354)

Side by Side Diff: tools/gn/function_get_target_outputs.cc

Issue 537013002: Add outputs to GN's header checker. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/gn/command_desc.cc ('k') | tools/gn/header_checker.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 if (!target) { 111 if (!target) {
112 *err = Err(function, "Target not found in this context.", 112 *err = Err(function, "Target not found in this context.",
113 label.GetUserVisibleName(false) + 113 label.GetUserVisibleName(false) +
114 "\nwas not found. get_target_outputs() can only be used for targets\n" 114 "\nwas not found. get_target_outputs() can only be used for targets\n"
115 "previously defined in the current file."); 115 "previously defined in the current file.");
116 return Value(); 116 return Value();
117 } 117 }
118 118
119 // Compute the output list. 119 // Compute the output list.
120 std::vector<SourceFile> files; 120 std::vector<SourceFile> files;
121 if (target->output_type() == Target::ACTION) { 121 if (target->output_type() == Target::ACTION ||
122 // Actions just use the output list with no substitution. 122 target->output_type() == Target::COPY_FILES ||
123 SubstitutionWriter::GetListAsSourceFiles( 123 target->output_type() == Target::ACTION_FOREACH) {
124 target->action_values().outputs(), &files); 124 target->action_values().GetOutputsAsSourceFiles(target, &files);
125 } else if (target->output_type() == Target::COPY_FILES ||
126 target->output_type() == Target::ACTION_FOREACH) {
127 // Copy and foreach appllies the outputs to the sources.
128 SubstitutionWriter::ApplyListToSources(
129 target->settings(), target->action_values().outputs(),
130 target->sources(), &files);
131 } else { 125 } else {
132 // Other types of targets are not supported. 126 // Other types of targets are not supported.
133 *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.",
134 "Only these target types are supported by get_target_outputs."); 128 "Only these target types are supported by get_target_outputs.");
135 return Value(); 129 return Value();
136 } 130 }
137 131
138 // Convert to Values. 132 // Convert to Values.
139 Value ret(function, Value::LIST); 133 Value ret(function, Value::LIST);
140 ret.list_value().reserve(files.size()); 134 ret.list_value().reserve(files.size());
141 for (size_t i = 0; i < files.size(); i++) 135 for (size_t i = 0; i < files.size(); i++)
142 ret.list_value().push_back(Value(function, files[i].value())); 136 ret.list_value().push_back(Value(function, files[i].value()));
143 137
144 return ret; 138 return ret;
145 } 139 }
146 140
147 } // namespace functions 141 } // namespace functions
OLDNEW
« no previous file with comments | « tools/gn/command_desc.cc ('k') | tools/gn/header_checker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698