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

Side by Side Diff: build/secondary/tools/grit/grit_rule.gni

Issue 361633002: [Android][gn] Add android resources templates (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gn-java
Patch Set: Created 6 years, 5 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
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 # Instantiate grit. This will produce a script target to run grit, and a 5 # Instantiate grit. This will produce a script target to run grit, and a
6 # static library that compiles the .cc files. 6 # static library that compiles the .cc files.
7 # 7 #
8 # Parameters 8 # Parameters
9 # 9 #
10 # source 10 # source
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 grit_defines += [ "-D", "image_loader_extension" ] 84 grit_defines += [ "-D", "image_loader_extension" ]
85 } 85 }
86 86
87 if (enable_remoting) { 87 if (enable_remoting) {
88 grit_defines += [ "-D", "remoting" ] 88 grit_defines += [ "-D", "remoting" ]
89 } 89 }
90 90
91 if (is_android) { 91 if (is_android) {
92 grit_defines += [ 92 grit_defines += [
93 "-t", "android", 93 "-t", "android",
94 "-E", "ANDROID_JAVA_TAGGED_ONLY=true",
95 ] 94 ]
96 } 95 }
97 96
98 if (is_mac || is_ios) { 97 if (is_mac || is_ios) {
99 grit_defines += [ "-D", "scale_factors=2x" ] 98 grit_defines += [ "-D", "scale_factors=2x" ]
100 } 99 }
101 100
102 if (is_ios) { 101 if (is_ios) {
103 grit_defines += [ 102 grit_defines += [
104 "-t", "ios", 103 "-t", "ios",
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 grit_resource_id_file = "//tools/gritsettings/resource_ids" 153 grit_resource_id_file = "//tools/gritsettings/resource_ids"
155 grit_info_script = "//tools/grit/grit_info.py" 154 grit_info_script = "//tools/grit/grit_info.py"
156 155
157 template("grit") { 156 template("grit") {
158 assert(defined(invoker.source), 157 assert(defined(invoker.source),
159 "\"source\" must be defined for the grit template $target_name") 158 "\"source\" must be defined for the grit template $target_name")
160 assert(!defined(invoker.sources) && !defined(invoker.outputs), 159 assert(!defined(invoker.sources) && !defined(invoker.outputs),
161 "Neither \"sources\" nor \"outputs\" can be defined for the grit " + 160 "Neither \"sources\" nor \"outputs\" can be defined for the grit " +
162 "template $target_name") 161 "template $target_name")
163 162
163 if (defined(invoker.resource_ids)) {
164 resource_ids = invoker.resource_ids
165 } else {
166 resource_ids = grit_resource_id_file
167 }
168
169 if (defined(invoker.output_dir)) {
170 output_dir = invoker.output_dir
171 } else {
172 output_dir = target_gen_dir
173 }
174
164 # These are all passed as arguments to the script so have to be relative to 175 # These are all passed as arguments to the script so have to be relative to
165 # the build directory. 176 # the build directory.
166 resource_ids = 177 if (resource_ids != "") {
167 rebase_path(grit_resource_id_file, root_build_dir) 178 resource_ids = rebase_path(resource_ids, root_build_dir)
168 output_dir = rebase_path(target_gen_dir, root_build_dir) 179 }
180 rebased_output_dir = rebase_path(output_dir, root_build_dir)
169 source_path = rebase_path(invoker.source, root_build_dir) 181 source_path = rebase_path(invoker.source, root_build_dir)
170 182
171 if (defined(invoker.grit_flags)) { 183 if (defined(invoker.grit_flags)) {
172 grit_flags = invoker.grit_flags 184 grit_flags = invoker.grit_flags
173 } else { 185 } else {
174 grit_flags = [] # These are optional so default to empty list. 186 grit_flags = [] # These are optional so default to empty list.
175 } 187 }
176 188
177 grit_inputs_build_rel = exec_script(grit_info_script, 189 grit_inputs_build_rel = exec_script(grit_info_script,
178 [ "--inputs", source_path, "-f", resource_ids] + grit_flags, "list lines") 190 [ "--inputs", source_path, "-f", resource_ids] + grit_flags, "list lines")
179 # The inputs are relative to the current (build) directory, rebase to 191 # The inputs are relative to the current (build) directory, rebase to
180 # the current one. 192 # the current one.
181 grit_inputs = rebase_path(grit_inputs_build_rel, ".", root_build_dir) + [ 193 grit_inputs = rebase_path(grit_inputs_build_rel, ".", root_build_dir) + [
182 grit_resource_id_file, 194 grit_resource_id_file,
183 ] 195 ]
184 196
185 grit_outputs_build_rel = exec_script(grit_info_script, 197 grit_outputs_build_rel = exec_script(grit_info_script,
186 [ "--outputs", "$output_dir", source_path, "-f", resource_ids ] + 198 [ "--outputs", "$rebased_output_dir", source_path, "-f", resource_ids ] +
187 grit_flags, 199 grit_flags,
188 "list lines") 200 "list lines")
189 201
190 # The inputs are relative to the current (build) directory, rebase to 202 # The inputs are relative to the current (build) directory, rebase to
191 # the current one. 203 # the current one.
192 grit_outputs = rebase_path(grit_outputs_build_rel, ".", root_build_dir) 204 grit_outputs = rebase_path(grit_outputs_build_rel, ".", root_build_dir)
193 205
194 # The config and the action below get this visibility son only the generated 206 # The config and the action below get this visibility son only the generated
195 # source set can depend on them. The variable "target_name" will get 207 # source set can depend on them. The variable "target_name" will get
196 # overwritten inside the innter classes so we need to compute it here. 208 # overwritten inside the innter classes so we need to compute it here.
197 target_visibility = ":$target_name" 209 target_visibility = ":$target_name"
198 210
199 # The current grit setup makes an file in $target_gen_dir/grit/foo.h that 211 # The current grit setup makes an file in $output_dir/grit/foo.h that
200 # the source code expects to include via "grit/foo.h". It would be nice to 212 # the source code expects to include via "grit/foo.h". It would be nice to
201 # change this to including absolute paths relative to the root gen directory 213 # change this to including absolute paths relative to the root gen directory
202 # (like "mycomponent/foo.h"). This config sets up the include path. 214 # (like "mycomponent/foo.h"). This config sets up the include path.
203 grit_config = target_name + "_grit_config" 215 grit_config = target_name + "_grit_config"
204 config(grit_config) { 216 config(grit_config) {
205 include_dirs = [ target_gen_dir ] 217 include_dirs = [ output_dir ]
206 visibility = target_visibility 218 visibility = target_visibility
207 } 219 }
208 220
209 grit_custom_target = target_name + "_grit" 221 grit_custom_target = target_name + "_grit"
210 action(grit_custom_target) { 222 action(grit_custom_target) {
211 script = "//tools/grit/grit.py" 223 script = "//tools/grit/grit.py"
212 source_prereqs = grit_inputs 224 source_prereqs = grit_inputs
213 outputs = grit_outputs 225 outputs = grit_outputs
214 226
215 args = [ 227 args = [
216 "-i", source_path, "build", 228 "-i", source_path, "build",
217 "-f", resource_ids, 229 "-f", resource_ids,
218 "-o", output_dir, 230 "-o", rebased_output_dir,
219 ] + grit_defines + grit_flags 231 ] + grit_defines + grit_flags
220 232
221 visibility = target_visibility 233 visibility = target_visibility
222 234
223 if (defined(invoker.deps)) { 235 if (defined(invoker.deps)) {
224 deps = invoker.deps 236 deps = invoker.deps
225 } 237 }
226 } 238 }
227 239
228 # This is the thing that people actually link with, it must be named the 240 # This is the thing that people actually link with, it must be named the
229 # same as the argument the template was invoked with. 241 # same as the argument the template was invoked with.
230 source_set(target_name) { 242 source_set(target_name) {
231 # Since we generate a file, we need to be run before the targets that 243 # Since we generate a file, we need to be run before the targets that
232 # depend on us. 244 # depend on us.
233 sources = grit_outputs 245 sources = grit_outputs
234 246
235 # Deps set on the template invocation will go on the grit script running 247 # Deps set on the template invocation will go on the grit script running
236 # target rather than this library. 248 # target rather than this library.
237 deps = [ ":$grit_custom_target" ] 249 deps = [ ":$grit_custom_target" ]
238 direct_dependent_configs = [ ":$grit_config" ] 250 direct_dependent_configs = [ ":$grit_config" ]
239 251
240 if (defined(invoker.visibility)) { 252 if (defined(invoker.visibility)) {
241 visibility = invoker.visibility 253 visibility = invoker.visibility
242 } 254 }
243 if (defined(invoker.output_name)) { 255 if (defined(invoker.output_name)) {
244 output_name = invoker.output_name 256 output_name = invoker.output_name
245 } 257 }
246 } 258 }
247 } 259 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698