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

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

Issue 2101243005: Add a snapshot of flutter/engine/src/build to our sdk (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: add README.dart Created 4 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
« no previous file with comments | « build/secondary/tools/grit/BUILD.gn ('k') | build/secondary/tools/grit/repack.gni » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 # found in the LICENSE file.
4
5 # Instantiate grit. This will produce a script target to run grit, and a
6 # static library that compiles the .cc files.
7 #
8 # Parameters
9 #
10 # source (required)
11 # Path to .grd file.
12 #
13 # outputs (required)
14 # List of outputs from grit, relative to the target_gen_dir. Grit will
15 # verify at build time that this list is correct and will fail if there
16 # is a mismatch between the outputs specified by the .grd file and the
17 # outputs list here.
18 #
19 # To get this list, you can look in the .grd file for
20 # <output filename="..." and put those filename here. The base directory
21 # of the list in Grit and the output list specified in the GN grit target
22 # are the same (the target_gen_dir) so you can generally copy the names
23 # exactly.
24 #
25 # To get the list of outputs programatically, run:
26 # python tools/grit/grit_info.py --outputs . path/to/your.grd
27 # And strip the leading "./" from the output files.
28 #
29 # defines (optional)
30 # Extra defines to pass to grit (on top of the global grit_defines list).
31 #
32 # grit_flags (optional)
33 # List of strings containing extra command-line flags to pass to Grit.
34 #
35 # resource_ids (optional)
36 # Path to a grit "firstidsfile". Default is
37 # //tools/gritsettings/resource_ids. Set to "" to use the value specified
38 # in the <grit> nodes of the processed files.
39 #
40 # output_dir (optional)
41 # Directory for generated files. If you specify this, you will often
42 # want to specify output_name if the target name is not particularly
43 # unique, since this can cause files from multiple grit targets to
44 # overwrite each other.
45 #
46 # output_name (optiona)
47 # Provide an alternate base name for the generated files, like the .d
48 # files. Normally these are based on the target name and go in the
49 # output_dir, but if multiple targets with the same name end up in
50 # the same output_dir, they can collide.
51 #
52 # depfile_dir (optional)
53 # If set, used to store the depfile and corresponding stamp file.
54 # Defaults to output_dir
55 #
56 # use_qualified_include (optional)
57 # If set, output_dir is not added to include_dirs.
58 #
59 # configs (optional)
60 # List of additional configs to be applied to the generated target.
61 # deps (optional)
62 # inputs (optional)
63 # List of additional files, required for grit to process source file.
64 # visibility (optional)
65 # Normal meaning.
66 #
67 # Example
68 #
69 # grit("my_resources") {
70 # # Source and outputs are required.
71 # source = "myfile.grd"
72 # outputs = [
73 # "foo_strings.h",
74 # "foo_strings.pak",
75 # ]
76 #
77 # grit_flags = [ "-E", "foo=bar" ] # Optional extra flags.
78 # # You can also put deps here if the grit source depends on generated
79 # # files.
80 # }
81 import("//build/config/chrome_build.gni")
82 import("//build/config/crypto.gni")
83 import("//build/config/features.gni")
84 import("//build/config/ui.gni")
85
86 grit_defines = []
87
88 # Mac and iOS want Title Case strings.
89 use_titlecase_in_grd_files = is_mac || is_ios
90 if (use_titlecase_in_grd_files) {
91 grit_defines += [
92 "-D",
93 "use_titlecase",
94 ]
95 }
96
97 if (is_chrome_branded) {
98 grit_defines += [
99 "-D",
100 "_google_chrome",
101 "-E",
102 "CHROMIUM_BUILD=google_chrome",
103 ]
104 } else {
105 grit_defines += [
106 "-D",
107 "_chromium",
108 "-E",
109 "CHROMIUM_BUILD=chromium",
110 ]
111 }
112
113 if (is_chromeos) {
114 grit_defines += [
115 "-D",
116 "chromeos",
117 "-D",
118 "scale_factors=2x",
119 ]
120 }
121
122 if (is_desktop_linux) {
123 grit_defines += [
124 "-D",
125 "desktop_linux",
126 ]
127 }
128
129 if (toolkit_views) {
130 grit_defines += [
131 "-D",
132 "toolkit_views",
133 ]
134 }
135
136 if (use_aura) {
137 grit_defines += [
138 "-D",
139 "use_aura",
140 ]
141 }
142
143 if (use_ash) {
144 grit_defines += [
145 "-D",
146 "use_ash",
147 ]
148 }
149
150 if (use_nss_certs) {
151 grit_defines += [
152 "-D",
153 "use_nss_certs",
154 ]
155 }
156
157 if (use_ozone) {
158 grit_defines += [
159 "-D",
160 "use_ozone",
161 ]
162 }
163
164 if (enable_image_loader_extension) {
165 grit_defines += [
166 "-D",
167 "image_loader_extension",
168 ]
169 }
170
171 if (enable_remoting) {
172 grit_defines += [
173 "-D",
174 "remoting",
175 ]
176 }
177
178 if (is_android) {
179 grit_defines += [
180 "-t",
181 "android",
182 "-E",
183 "ANDROID_JAVA_TAGGED_ONLY=true",
184 ]
185 }
186
187 if (is_mac || is_ios) {
188 grit_defines += [
189 "-D",
190 "scale_factors=2x",
191 ]
192 }
193
194 if (is_ios) {
195 grit_defines += [
196 "-t",
197 "ios",
198
199 # iOS uses a whitelist to filter resources.
200 "-w",
201 rebase_path("//build/ios/grit_whitelist.txt", root_build_dir),
202 ]
203 }
204
205 if (enable_extensions) {
206 grit_defines += [
207 "-D",
208 "enable_extensions",
209 ]
210 }
211 if (enable_media_router) {
212 grit_defines += [
213 "-D",
214 "enable_media_router",
215 ]
216 }
217 if (enable_plugins) {
218 grit_defines += [
219 "-D",
220 "enable_plugins",
221 ]
222 }
223 if (enable_basic_printing || enable_print_preview) {
224 grit_defines += [
225 "-D",
226 "enable_printing",
227 ]
228 if (enable_print_preview) {
229 grit_defines += [
230 "-D",
231 "enable_print_preview",
232 ]
233 }
234 }
235 if (enable_themes) {
236 grit_defines += [
237 "-D",
238 "enable_themes",
239 ]
240 }
241 if (enable_app_list) {
242 grit_defines += [
243 "-D",
244 "enable_app_list",
245 ]
246 }
247 if (enable_settings_app) {
248 grit_defines += [
249 "-D",
250 "enable_settings_app",
251 ]
252 }
253 if (enable_google_now) {
254 grit_defines += [
255 "-D",
256 "enable_google_now",
257 ]
258 }
259
260 # Note: use_concatenated_impulse_responses is omitted. It is never used and
261 # should probably be removed from GYP build.
262 if (enable_webrtc) {
263 grit_defines += [
264 "-D",
265 "enable_webrtc",
266 ]
267 }
268 if (enable_hangout_services_extension) {
269 grit_defines += [
270 "-D",
271 "enable_hangout_services_extension",
272 ]
273 }
274 if (enable_task_manager) {
275 grit_defines += [
276 "-D",
277 "enable_task_manager",
278 ]
279 }
280 if (enable_notifications) {
281 grit_defines += [
282 "-D",
283 "enable_notifications",
284 ]
285 }
286 if (enable_wifi_bootstrapping) {
287 grit_defines += [
288 "-D",
289 "enable_wifi_bootstrapping",
290 ]
291 }
292 if (enable_service_discovery) {
293 grit_defines += [
294 "-D",
295 "enable_service_discovery",
296 ]
297 }
298 if (mac_views_browser) {
299 grit_defines += [
300 "-D",
301 "mac_views_browser",
302 ]
303 }
304
305 grit_resource_id_file = "//tools/gritsettings/resource_ids"
306 grit_info_script = "//tools/grit/grit_info.py"
307
308 template("grit") {
309 assert(defined(invoker.source),
310 "\"source\" must be defined for the grit template $target_name")
311
312 grit_inputs = [ invoker.source ]
313
314 if (defined(invoker.resource_ids)) {
315 resource_ids = invoker.resource_ids
316 } else {
317 resource_ids = grit_resource_id_file
318 }
319 if (resource_ids != "") {
320 # The script depends on the ID file. Only add this dependency if the ID
321 # file is specified.
322 grit_inputs += [ resource_ids ]
323 }
324
325 if (defined(invoker.output_dir)) {
326 output_dir = invoker.output_dir
327 } else {
328 output_dir = target_gen_dir
329 }
330
331 if (defined(invoker.output_name)) {
332 grit_output_name = invoker.output_name
333 } else {
334 grit_output_name = target_name
335 }
336
337 if (defined(invoker.depfile_dir)) {
338 depfile_dir = invoker.depfile_dir
339 } else {
340 depfile_dir = output_dir
341 }
342
343 # These are all passed as arguments to the script so have to be relative to
344 # the build directory.
345 if (resource_ids != "") {
346 resource_ids = rebase_path(resource_ids, root_build_dir)
347 }
348 rebased_output_dir = rebase_path(output_dir, root_build_dir)
349 source_path = rebase_path(invoker.source, root_build_dir)
350
351 if (defined(invoker.grit_flags)) {
352 grit_flags = invoker.grit_flags
353 } else {
354 grit_flags = [] # These are optional so default to empty list.
355 }
356
357 assert_files_flags = []
358
359 # We want to make sure the declared outputs actually match what Grit is
360 # writing. We write the list to a file (some of the output lists are long
361 # enough to not fit on a Windows command line) and ask Grit to verify those
362 # are the actual outputs at runtime.
363 asserted_list_file =
364 "$target_out_dir/${grit_output_name}_expected_outputs.txt"
365 write_file(asserted_list_file,
366 rebase_path(invoker.outputs, root_build_dir, output_dir))
367 assert_files_flags += [ "--assert-file-list=" +
368 rebase_path(asserted_list_file, root_build_dir) ]
369 grit_outputs =
370 get_path_info(rebase_path(invoker.outputs, ".", output_dir), "abspath")
371
372 # The config and the action below get this visibility son only the generated
373 # source set can depend on them. The variable "target_name" will get
374 # overwritten inside the inner classes so we need to compute it here.
375 target_visibility = [ ":$target_name" ]
376
377 # The current grit setup makes an file in $output_dir/grit/foo.h that
378 # the source code expects to include via "grit/foo.h". It would be nice to
379 # change this to including absolute paths relative to the root gen directory
380 # (like "mycomponent/foo.h"). This config sets up the include path.
381 grit_config = target_name + "_grit_config"
382 config(grit_config) {
383 if (!defined(invoker.use_qualified_include) ||
384 !invoker.use_qualified_include) {
385 include_dirs = [ output_dir ]
386 }
387 visibility = target_visibility
388 }
389
390 grit_custom_target = target_name + "_grit"
391 action(grit_custom_target) {
392 script = "//tools/grit/grit.py"
393 inputs = grit_inputs
394
395 depfile = "$depfile_dir/${grit_output_name}_stamp.d"
396 outputs = [ "${depfile}.stamp" ] + grit_outputs
397
398 args = [
399 "-i",
400 source_path,
401 "build",
402 ]
403 if (resource_ids != "") {
404 args += [
405 "-f",
406 resource_ids,
407 ]
408 }
409 args += [
410 "-o",
411 rebased_output_dir,
412 "--depdir",
413 ".",
414 "--depfile",
415 rebase_path(depfile, root_build_dir),
416 "--write-only-new=1",
417 "--depend-on-stamp",
418 ] + grit_defines
419
420 # Add extra defines with -D flags.
421 if (defined(invoker.defines)) {
422 foreach(i, invoker.defines) {
423 args += [
424 "-D",
425 i,
426 ]
427 }
428 }
429
430 args += grit_flags + assert_files_flags
431
432 if (defined(invoker.visibility)) {
433 # This needs to include both what the invoker specified (since they
434 # probably include generated headers from this target), as well as the
435 # generated source set (since there's no guarantee that the visibility
436 # specified by the invoker includes our target).
437 #
438 # Only define visibility at all if the invoker specified it. Otherwise,
439 # we want to keep the public "no visibility specified" default.
440 visibility = target_visibility + invoker.visibility
441 }
442
443 deps = [
444 "//tools/grit:grit_sources",
445 ]
446 if (defined(invoker.deps)) {
447 deps += invoker.deps
448 }
449 if (defined(invoker.inputs)) {
450 inputs += invoker.inputs
451 }
452 }
453
454 # This is the thing that people actually link with, it must be named the
455 # same as the argument the template was invoked with.
456 source_set(target_name) {
457 # Since we generate a file, we need to be run before the targets that
458 # depend on us.
459 sources = grit_outputs
460
461 # Deps set on the template invocation will go on the action that runs
462 # grit above rather than this library. This target needs to depend on the
463 # action publicly so other scripts can take the outputs from the grit
464 # script as inputs.
465 public_deps = [
466 ":$grit_custom_target",
467 ]
468 public_configs = [ ":$grit_config" ]
469
470 if (defined(invoker.public_configs)) {
471 public_configs += invoker.public_configs
472 }
473
474 if (defined(invoker.configs)) {
475 configs += invoker.configs
476 }
477
478 if (defined(invoker.visibility)) {
479 visibility = invoker.visibility
480 }
481 output_name = grit_output_name
482 }
483 }
OLDNEW
« no previous file with comments | « build/secondary/tools/grit/BUILD.gn ('k') | build/secondary/tools/grit/repack.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698