| 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 # 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 Loading... |
| 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 += [ |
| 184 } | 250 "-D", |
| 185 # Note: enable_hangout_services_extension is omitted. It is never set in the | 251 "enable_webrtc", |
| 186 # GYP build. Need to figure out what it's for. | 252 ] |
| 253 } |
| 254 if (enable_hangout_services_extension) { |
| 255 grit_defines += [ |
| 256 "-D", |
| 257 "enable_hangout_services_extension", |
| 258 ] |
| 259 } |
| 187 if (enable_task_manager) { | 260 if (enable_task_manager) { |
| 188 grit_defines += [ "-D", "enable_task_manager" ] | 261 grit_defines += [ |
| 262 "-D", |
| 263 "enable_task_manager", |
| 264 ] |
| 189 } | 265 } |
| 190 if (enable_notifications) { | 266 if (enable_notifications) { |
| 191 grit_defines += [ "-D", "enable_notifications" ] | 267 grit_defines += [ |
| 268 "-D", |
| 269 "enable_notifications", |
| 270 ] |
| 192 } | 271 } |
| 193 if (enable_wifi_bootstrapping) { | 272 if (enable_wifi_bootstrapping) { |
| 194 grit_defines += [ "-D", "enable_wifi_bootstrapping" ] | 273 grit_defines += [ |
| 274 "-D", |
| 275 "enable_wifi_bootstrapping", |
| 276 ] |
| 195 } | 277 } |
| 196 if (enable_service_discovery) { | 278 if (enable_service_discovery) { |
| 197 grit_defines += [ "-D", "enable_service_discovery" ] | 279 grit_defines += [ |
| 280 "-D", |
| 281 "enable_service_discovery", |
| 282 ] |
| 198 } | 283 } |
| 199 | 284 |
| 200 grit_resource_id_file = "//tools/gritsettings/resource_ids" | 285 grit_resource_id_file = "//tools/gritsettings/resource_ids" |
| 201 grit_info_script = "//tools/grit/grit_info.py" | 286 grit_info_script = "//tools/grit/grit_info.py" |
| 202 | 287 |
| 203 template("grit") { | 288 template("grit") { |
| 204 assert(defined(invoker.source), | 289 assert(defined(invoker.source), |
| 205 "\"source\" must be defined for the grit template $target_name") | 290 "\"source\" must be defined for the grit template $target_name") |
| 206 | 291 |
| 207 if (defined(invoker.resource_ids)) { | 292 if (defined(invoker.resource_ids)) { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 assert_files_flags = [] | 326 assert_files_flags = [] |
| 242 | 327 |
| 243 # 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 |
| 244 # 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 |
| 245 # 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 |
| 246 # are the actual outputs at runtime. | 331 # are the actual outputs at runtime. |
| 247 asserted_list_file = | 332 asserted_list_file = |
| 248 "$target_out_dir/${grit_output_name}_expected_outputs.txt" | 333 "$target_out_dir/${grit_output_name}_expected_outputs.txt" |
| 249 write_file(asserted_list_file, | 334 write_file(asserted_list_file, |
| 250 rebase_path(invoker.outputs, root_build_dir, output_dir)) | 335 rebase_path(invoker.outputs, root_build_dir, output_dir)) |
| 251 assert_files_flags += [ | 336 assert_files_flags += [ "--assert-file-list=" + |
| 252 "--assert-file-list=" + rebase_path(asserted_list_file, root_build_dir), | 337 rebase_path(asserted_list_file, root_build_dir) ] |
| 253 ] | 338 grit_outputs = |
| 254 grit_outputs = get_path_info( | 339 get_path_info(rebase_path(invoker.outputs, ".", output_dir), "abspath") |
| 255 rebase_path(invoker.outputs, ".", output_dir), | |
| 256 "abspath") | |
| 257 | 340 |
| 258 # 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 |
| 259 # 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 |
| 260 # 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. |
| 261 target_visibility = [ ":$target_name" ] | 344 target_visibility = [ ":$target_name" ] |
| 262 | 345 |
| 263 # 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 |
| 264 # 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 |
| 265 # 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 |
| 266 # (like "mycomponent/foo.h"). This config sets up the include path. | 349 # (like "mycomponent/foo.h"). This config sets up the include path. |
| 267 grit_config = target_name + "_grit_config" | 350 grit_config = target_name + "_grit_config" |
| 268 config(grit_config) { | 351 config(grit_config) { |
| 269 if (!defined(invoker.use_qualified_include) || | 352 if (!defined(invoker.use_qualified_include) || |
| 270 !invoker.use_qualified_include) { | 353 !invoker.use_qualified_include) { |
| 271 include_dirs = [ output_dir ] | 354 include_dirs = [ output_dir ] |
| 272 } | 355 } |
| 273 visibility = target_visibility | 356 visibility = target_visibility |
| 274 } | 357 } |
| 275 | 358 |
| 276 grit_custom_target = target_name + "_grit" | 359 grit_custom_target = target_name + "_grit" |
| 277 action(grit_custom_target) { | 360 action(grit_custom_target) { |
| 278 script = "//tools/grit/grit.py" | 361 script = "//tools/grit/grit.py" |
| 279 inputs = grit_inputs | 362 inputs = grit_inputs |
| 280 outputs = grit_outputs | 363 outputs = grit_outputs |
| 281 depfile = "$output_dir/${grit_output_name}.d" | 364 depfile = "$output_dir/${grit_output_name}.d" |
| 282 | 365 |
| 283 args = [ | 366 args = [ |
| 284 "-i", source_path, "build", | 367 "-i", |
| 368 source_path, |
| 369 "build", |
| 285 ] | 370 ] |
| 286 if (resource_ids != "") { | 371 if (resource_ids != "") { |
| 287 args += [ "-f", resource_ids ] | 372 args += [ |
| 373 "-f", |
| 374 resource_ids, |
| 375 ] |
| 288 } | 376 } |
| 289 args += [ | 377 args += [ |
| 290 "-o", rebased_output_dir, | 378 "-o", |
| 291 "--depdir", ".", | 379 rebased_output_dir, |
| 292 "--depfile", rebase_path(depfile, root_build_dir), | 380 "--depdir", |
| 293 ] + grit_defines | 381 ".", |
| 382 "--depfile", |
| 383 rebase_path(depfile, root_build_dir), |
| 384 ] + grit_defines |
| 294 | 385 |
| 295 # Add extra defines with -D flags. | 386 # Add extra defines with -D flags. |
| 296 if (defined(invoker.defines)) { | 387 if (defined(invoker.defines)) { |
| 297 foreach (i, invoker.defines) { | 388 foreach(i, invoker.defines) { |
| 298 args += [ "-D", i ] | 389 args += [ |
| 390 "-D", |
| 391 i, |
| 392 ] |
| 299 } | 393 } |
| 300 } | 394 } |
| 301 | 395 |
| 302 args += grit_flags + assert_files_flags | 396 args += grit_flags + assert_files_flags |
| 303 | 397 |
| 304 if (defined(invoker.visibility)) { | 398 if (defined(invoker.visibility)) { |
| 305 # This needs to include both what the invoker specified (since they | 399 # This needs to include both what the invoker specified (since they |
| 306 # probably include generated headers from this target), as well as the | 400 # probably include generated headers from this target), as well as the |
| 307 # generated source set (since there's no guarantee that the visibility | 401 # generated source set (since there's no guarantee that the visibility |
| 308 # specified by the invoker includes our target). | 402 # specified by the invoker includes our target). |
| 309 # | 403 # |
| 310 # Only define visibility at all if the invoker specified it. Otherwise, | 404 # Only define visibility at all if the invoker specified it. Otherwise, |
| 311 # we want to keep the public "no visibility specified" default. | 405 # we want to keep the public "no visibility specified" default. |
| 312 visibility = target_visibility + invoker.visibility | 406 visibility = target_visibility + invoker.visibility |
| 313 } | 407 } |
| 314 | 408 |
| 315 deps = [ "//tools/grit:grit_sources" ] | 409 deps = [ |
| 410 "//tools/grit:grit_sources", |
| 411 ] |
| 316 if (defined(invoker.deps)) { | 412 if (defined(invoker.deps)) { |
| 317 deps += invoker.deps | 413 deps += invoker.deps |
| 318 } | 414 } |
| 319 } | 415 } |
| 320 | 416 |
| 321 # 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 |
| 322 # same as the argument the template was invoked with. | 418 # same as the argument the template was invoked with. |
| 323 source_set(target_name) { | 419 source_set(target_name) { |
| 324 # 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 |
| 325 # depend on us. | 421 # depend on us. |
| 326 sources = grit_outputs | 422 sources = grit_outputs |
| 327 | 423 |
| 328 # 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 |
| 329 # target rather than this library. | 425 # target rather than this library. |
| 330 deps = [ ":$grit_custom_target" ] | 426 deps = [ |
| 427 ":$grit_custom_target", |
| 428 ] |
| 331 public_configs = [ ":$grit_config" ] | 429 public_configs = [ ":$grit_config" ] |
| 332 | 430 |
| 333 if (defined(invoker.public_configs)) { | 431 if (defined(invoker.public_configs)) { |
| 334 public_configs += invoker.public_configs | 432 public_configs += invoker.public_configs |
| 335 } | 433 } |
| 336 | 434 |
| 337 if (defined(invoker.visibility)) { | 435 if (defined(invoker.visibility)) { |
| 338 visibility = invoker.visibility | 436 visibility = invoker.visibility |
| 339 } | 437 } |
| 340 output_name = grit_output_name | 438 output_name = grit_output_name |
| 341 } | 439 } |
| 342 } | 440 } |
| OLD | NEW |