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

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

Issue 766573003: gn format //build (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years 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/toolchain/android/BUILD.gn » ('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 # 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 (required) 10 # source (required)
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 # source = "myfile.grd" 64 # source = "myfile.grd"
65 # outputs = [ 65 # outputs = [
66 # "foo_strings.h", 66 # "foo_strings.h",
67 # "foo_strings.pak", 67 # "foo_strings.pak",
68 # ] 68 # ]
69 # 69 #
70 # grit_flags = [ "-E", "foo=bar" ] # Optional extra flags. 70 # grit_flags = [ "-E", "foo=bar" ] # Optional extra flags.
71 # # You can also put deps here if the grit source depends on generated 71 # # You can also put deps here if the grit source depends on generated
72 # # files. 72 # # files.
73 # } 73 # }
74 import ("//build/config/crypto.gni") 74 import("//build/config/crypto.gni")
75 import ("//build/config/features.gni") 75 import("//build/config/features.gni")
76 import ("//build/config/ui.gni") 76 import("//build/config/ui.gni")
77 77
78 grit_defines = [] 78 grit_defines = []
79 79
80 # Mac and iOS want Title Case strings. 80 # Mac and iOS want Title Case strings.
81 use_titlecase_in_grd_files = is_mac || is_ios 81 use_titlecase_in_grd_files = is_mac || is_ios
82 if (use_titlecase_in_grd_files) { 82 if (use_titlecase_in_grd_files) {
83 grit_defines += [ "-D", "use_titlecase" ] 83 grit_defines += [
84 "-D",
85 "use_titlecase",
86 ]
84 } 87 }
85 88
86 if (is_chrome_branded) { 89 if (is_chrome_branded) {
87 grit_defines += [ 90 grit_defines += [
88 "-D", "_google_chrome", 91 "-D",
89 "-E", "CHROMIUM_BUILD=google_chrome", 92 "_google_chrome",
93 "-E",
94 "CHROMIUM_BUILD=google_chrome",
90 ] 95 ]
91 } else { 96 } else {
92 grit_defines += [ 97 grit_defines += [
93 "-D", "_chromium", 98 "-D",
94 "-E", "CHROMIUM_BUILD=chromium", 99 "_chromium",
100 "-E",
101 "CHROMIUM_BUILD=chromium",
95 ] 102 ]
96 } 103 }
97 104
98 if (is_chromeos) { 105 if (is_chromeos) {
99 grit_defines += [ 106 grit_defines += [
100 "-D", "chromeos", 107 "-D",
101 "-D", "scale_factors=2x" 108 "chromeos",
109 "-D",
110 "scale_factors=2x",
102 ] 111 ]
103 } 112 }
104 113
105 if (is_desktop_linux) { 114 if (is_desktop_linux) {
106 grit_defines += [ "-D", "desktop_linux" ] 115 grit_defines += [
116 "-D",
117 "desktop_linux",
118 ]
107 } 119 }
108 120
109 if (toolkit_views) { 121 if (toolkit_views) {
110 grit_defines += [ "-D", "toolkit_views" ] 122 grit_defines += [
123 "-D",
124 "toolkit_views",
125 ]
111 } 126 }
112 127
113 if (use_aura) { 128 if (use_aura) {
114 grit_defines += [ "-D", "use_aura" ] 129 grit_defines += [
130 "-D",
131 "use_aura",
132 ]
115 } 133 }
116 134
117 if (use_ash) { 135 if (use_ash) {
118 grit_defines += [ "-D", "use_ash" ] 136 grit_defines += [
137 "-D",
138 "use_ash",
139 ]
119 } 140 }
120 141
121 if (use_nss_certs) { 142 if (use_nss_certs) {
122 grit_defines += [ "-D", "use_nss" ] 143 grit_defines += [
144 "-D",
145 "use_nss",
146 ]
123 } 147 }
124 148
125 if (use_ozone) { 149 if (use_ozone) {
126 grit_defines += [ "-D", "use_ozone" ] 150 grit_defines += [
151 "-D",
152 "use_ozone",
153 ]
127 } 154 }
128 155
129 if (enable_image_loader_extension) { 156 if (enable_image_loader_extension) {
130 grit_defines += [ "-D", "image_loader_extension" ] 157 grit_defines += [
158 "-D",
159 "image_loader_extension",
160 ]
131 } 161 }
132 162
133 if (enable_remoting) { 163 if (enable_remoting) {
134 grit_defines += [ "-D", "remoting" ] 164 grit_defines += [
165 "-D",
166 "remoting",
167 ]
135 } 168 }
136 169
137 if (is_android) { 170 if (is_android) {
138 grit_defines += [ 171 grit_defines += [
139 "-t", "android", 172 "-t",
140 "-E", "ANDROID_JAVA_TAGGED_ONLY=true", 173 "android",
174 "-E",
175 "ANDROID_JAVA_TAGGED_ONLY=true",
141 ] 176 ]
142 } 177 }
143 178
144 if (is_mac || is_ios) { 179 if (is_mac || is_ios) {
145 grit_defines += [ "-D", "scale_factors=2x" ] 180 grit_defines += [
181 "-D",
182 "scale_factors=2x",
183 ]
146 } 184 }
147 185
148 if (is_ios) { 186 if (is_ios) {
149 grit_defines += [ 187 grit_defines += [
150 "-t", "ios", 188 "-t",
189 "ios",
190
151 # iOS uses a whitelist to filter resources. 191 # iOS uses a whitelist to filter resources.
152 "-w", rebase_path("//build/ios/grit_whitelist.txt", root_build_dir), 192 "-w",
193 rebase_path("//build/ios/grit_whitelist.txt", root_build_dir),
153 ] 194 ]
154 } 195 }
155 196
156 if (enable_extensions) { 197 if (enable_extensions) {
157 grit_defines += [ "-D", "enable_extensions" ] 198 grit_defines += [
199 "-D",
200 "enable_extensions",
201 ]
158 } 202 }
159 if (enable_plugins) { 203 if (enable_plugins) {
160 grit_defines += [ "-D", "enable_plugins" ] 204 grit_defines += [
205 "-D",
206 "enable_plugins",
207 ]
161 } 208 }
162 if (enable_basic_printing || enable_print_preview) { 209 if (enable_basic_printing || enable_print_preview) {
163 grit_defines += [ "-D", "enable_printing" ] 210 grit_defines += [
211 "-D",
212 "enable_printing",
213 ]
164 if (enable_print_preview) { 214 if (enable_print_preview) {
165 grit_defines += [ "-D", "enable_print_preview" ] 215 grit_defines += [
216 "-D",
217 "enable_print_preview",
218 ]
166 } 219 }
167 } 220 }
168 if (enable_themes) { 221 if (enable_themes) {
169 grit_defines += [ "-D", "enable_themes" ] 222 grit_defines += [
223 "-D",
224 "enable_themes",
225 ]
170 } 226 }
171 if (enable_app_list) { 227 if (enable_app_list) {
172 grit_defines += [ "-D", "enable_app_list" ] 228 grit_defines += [
229 "-D",
230 "enable_app_list",
231 ]
173 } 232 }
174 if (enable_settings_app) { 233 if (enable_settings_app) {
175 grit_defines += [ "-D", "enable_settings_app" ] 234 grit_defines += [
235 "-D",
236 "enable_settings_app",
237 ]
176 } 238 }
177 if (enable_google_now) { 239 if (enable_google_now) {
178 grit_defines += [ "-D", "enable_google_now" ] 240 grit_defines += [
179 } 241 "-D",
242 "enable_google_now",
243 ]
244 }
245
180 # Note: use_concatenated_impulse_responses is omitted. It is never used and 246 # Note: use_concatenated_impulse_responses is omitted. It is never used and
181 # should probably be removed from GYP build. 247 # should probably be removed from GYP build.
182 if (enable_webrtc) { 248 if (enable_webrtc) {
183 grit_defines += [ "-D", "enable_webrtc" ] 249 grit_defines += [
250 "-D",
251 "enable_webrtc",
252 ]
184 } 253 }
185 if (enable_hangout_services_extension) { 254 if (enable_hangout_services_extension) {
186 grit_defines += [ "-D", "enable_hangout_services_extension" ] 255 grit_defines += [
256 "-D",
257 "enable_hangout_services_extension",
258 ]
187 } 259 }
188 if (enable_task_manager) { 260 if (enable_task_manager) {
189 grit_defines += [ "-D", "enable_task_manager" ] 261 grit_defines += [
262 "-D",
263 "enable_task_manager",
264 ]
190 } 265 }
191 if (enable_notifications) { 266 if (enable_notifications) {
192 grit_defines += [ "-D", "enable_notifications" ] 267 grit_defines += [
268 "-D",
269 "enable_notifications",
270 ]
193 } 271 }
194 if (enable_wifi_bootstrapping) { 272 if (enable_wifi_bootstrapping) {
195 grit_defines += [ "-D", "enable_wifi_bootstrapping" ] 273 grit_defines += [
274 "-D",
275 "enable_wifi_bootstrapping",
276 ]
196 } 277 }
197 if (enable_service_discovery) { 278 if (enable_service_discovery) {
198 grit_defines += [ "-D", "enable_service_discovery" ] 279 grit_defines += [
280 "-D",
281 "enable_service_discovery",
282 ]
199 } 283 }
200 284
201 grit_resource_id_file = "//tools/gritsettings/resource_ids" 285 grit_resource_id_file = "//tools/gritsettings/resource_ids"
202 grit_info_script = "//tools/grit/grit_info.py" 286 grit_info_script = "//tools/grit/grit_info.py"
203 287
204 template("grit") { 288 template("grit") {
205 assert(defined(invoker.source), 289 assert(defined(invoker.source),
206 "\"source\" must be defined for the grit template $target_name") 290 "\"source\" must be defined for the grit template $target_name")
207 291
208 if (defined(invoker.resource_ids)) { 292 if (defined(invoker.resource_ids)) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 assert_files_flags = [] 326 assert_files_flags = []
243 327
244 # We want to make sure the declared outputs actually match what Grit is 328 # We want to make sure the declared outputs actually match what Grit is
245 # writing. We write the list to a file (some of the output lists are long 329 # writing. We write the list to a file (some of the output lists are long
246 # enough to not fit on a Windows command line) and ask Grit to verify those 330 # enough to not fit on a Windows command line) and ask Grit to verify those
247 # are the actual outputs at runtime. 331 # are the actual outputs at runtime.
248 asserted_list_file = 332 asserted_list_file =
249 "$target_out_dir/${grit_output_name}_expected_outputs.txt" 333 "$target_out_dir/${grit_output_name}_expected_outputs.txt"
250 write_file(asserted_list_file, 334 write_file(asserted_list_file,
251 rebase_path(invoker.outputs, root_build_dir, output_dir)) 335 rebase_path(invoker.outputs, root_build_dir, output_dir))
252 assert_files_flags += [ 336 assert_files_flags += [ "--assert-file-list=" +
253 "--assert-file-list=" + rebase_path(asserted_list_file, root_build_dir), 337 rebase_path(asserted_list_file, root_build_dir) ]
254 ] 338 grit_outputs =
255 grit_outputs = get_path_info( 339 get_path_info(rebase_path(invoker.outputs, ".", output_dir), "abspath")
256 rebase_path(invoker.outputs, ".", output_dir),
257 "abspath")
258 340
259 # The config and the action below get this visibility son only the generated 341 # The config and the action below get this visibility son only the generated
260 # source set can depend on them. The variable "target_name" will get 342 # source set can depend on them. The variable "target_name" will get
261 # overwritten inside the inner classes so we need to compute it here. 343 # overwritten inside the inner classes so we need to compute it here.
262 target_visibility = [ ":$target_name" ] 344 target_visibility = [ ":$target_name" ]
263 345
264 # The current grit setup makes an file in $output_dir/grit/foo.h that 346 # The current grit setup makes an file in $output_dir/grit/foo.h that
265 # the source code expects to include via "grit/foo.h". It would be nice to 347 # the source code expects to include via "grit/foo.h". It would be nice to
266 # change this to including absolute paths relative to the root gen directory 348 # change this to including absolute paths relative to the root gen directory
267 # (like "mycomponent/foo.h"). This config sets up the include path. 349 # (like "mycomponent/foo.h"). This config sets up the include path.
268 grit_config = target_name + "_grit_config" 350 grit_config = target_name + "_grit_config"
269 config(grit_config) { 351 config(grit_config) {
270 if (!defined(invoker.use_qualified_include) || 352 if (!defined(invoker.use_qualified_include) ||
271 !invoker.use_qualified_include) { 353 !invoker.use_qualified_include) {
272 include_dirs = [ output_dir ] 354 include_dirs = [ output_dir ]
273 } 355 }
274 visibility = target_visibility 356 visibility = target_visibility
275 } 357 }
276 358
277 grit_custom_target = target_name + "_grit" 359 grit_custom_target = target_name + "_grit"
278 action(grit_custom_target) { 360 action(grit_custom_target) {
279 script = "//tools/grit/grit.py" 361 script = "//tools/grit/grit.py"
280 inputs = grit_inputs 362 inputs = grit_inputs
281 outputs = grit_outputs 363 outputs = grit_outputs
282 depfile = "$output_dir/${grit_output_name}.d" 364 depfile = "$output_dir/${grit_output_name}.d"
283 365
284 args = [ 366 args = [
285 "-i", source_path, "build", 367 "-i",
368 source_path,
369 "build",
286 ] 370 ]
287 if (resource_ids != "") { 371 if (resource_ids != "") {
288 args += [ "-f", resource_ids ] 372 args += [
373 "-f",
374 resource_ids,
375 ]
289 } 376 }
290 args += [ 377 args += [
291 "-o", rebased_output_dir, 378 "-o",
292 "--depdir", ".", 379 rebased_output_dir,
293 "--depfile", rebase_path(depfile, root_build_dir), 380 "--depdir",
294 ] + grit_defines 381 ".",
382 "--depfile",
383 rebase_path(depfile, root_build_dir),
384 ] + grit_defines
295 385
296 # Add extra defines with -D flags. 386 # Add extra defines with -D flags.
297 if (defined(invoker.defines)) { 387 if (defined(invoker.defines)) {
298 foreach (i, invoker.defines) { 388 foreach(i, invoker.defines) {
299 args += [ "-D", i ] 389 args += [
390 "-D",
391 i,
392 ]
300 } 393 }
301 } 394 }
302 395
303 args += grit_flags + assert_files_flags 396 args += grit_flags + assert_files_flags
304 397
305 if (defined(invoker.visibility)) { 398 if (defined(invoker.visibility)) {
306 # This needs to include both what the invoker specified (since they 399 # This needs to include both what the invoker specified (since they
307 # probably include generated headers from this target), as well as the 400 # probably include generated headers from this target), as well as the
308 # generated source set (since there's no guarantee that the visibility 401 # generated source set (since there's no guarantee that the visibility
309 # specified by the invoker includes our target). 402 # specified by the invoker includes our target).
310 # 403 #
311 # Only define visibility at all if the invoker specified it. Otherwise, 404 # Only define visibility at all if the invoker specified it. Otherwise,
312 # we want to keep the public "no visibility specified" default. 405 # we want to keep the public "no visibility specified" default.
313 visibility = target_visibility + invoker.visibility 406 visibility = target_visibility + invoker.visibility
314 } 407 }
315 408
316 deps = [ "//tools/grit:grit_sources" ] 409 deps = [
410 "//tools/grit:grit_sources",
411 ]
317 if (defined(invoker.deps)) { 412 if (defined(invoker.deps)) {
318 deps += invoker.deps 413 deps += invoker.deps
319 } 414 }
320 } 415 }
321 416
322 # This is the thing that people actually link with, it must be named the 417 # This is the thing that people actually link with, it must be named the
323 # same as the argument the template was invoked with. 418 # same as the argument the template was invoked with.
324 source_set(target_name) { 419 source_set(target_name) {
325 # Since we generate a file, we need to be run before the targets that 420 # Since we generate a file, we need to be run before the targets that
326 # depend on us. 421 # depend on us.
327 sources = grit_outputs 422 sources = grit_outputs
328 423
329 # Deps set on the template invocation will go on the grit script running 424 # Deps set on the template invocation will go on the grit script running
330 # target rather than this library. 425 # target rather than this library.
331 deps = [ ":$grit_custom_target" ] 426 deps = [
427 ":$grit_custom_target",
428 ]
332 public_configs = [ ":$grit_config" ] 429 public_configs = [ ":$grit_config" ]
333 430
334 if (defined(invoker.public_configs)) { 431 if (defined(invoker.public_configs)) {
335 public_configs += invoker.public_configs 432 public_configs += invoker.public_configs
336 } 433 }
337 434
338 if (defined(invoker.visibility)) { 435 if (defined(invoker.visibility)) {
339 visibility = invoker.visibility 436 visibility = invoker.visibility
340 } 437 }
341 output_name = grit_output_name 438 output_name = grit_output_name
342 } 439 }
343 } 440 }
OLDNEW
« no previous file with comments | « build/secondary/tools/grit/BUILD.gn ('k') | build/toolchain/android/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698