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

Side by Side Diff: build/config/mac/base_rules.gni

Issue 1918263002: [iOS/Mac/GN] Split out common iOS and Mac rules into base_rules.gni. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Do'h, SDK path Created 4 years, 7 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/config/ios/rules.gni ('k') | build/config/mac/rules.gni » ('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 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2016 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 # This file contains rules that are shared between Mac and iOS.
6
5 import("//build/toolchain/toolchain.gni") 7 import("//build/toolchain/toolchain.gni")
6 import("//build/config/mac/mac_sdk.gni") 8
9 if (is_mac) {
10 import("//build/config/mac/mac_sdk.gni")
11 } else if (is_ios) {
12 import("//build/config/ios/ios_sdk.gni")
13 }
7 14
8 # The base template used to generate Info.plist files for iOS and Mac apps and 15 # The base template used to generate Info.plist files for iOS and Mac apps and
9 # frameworks. 16 # frameworks.
10 # 17 #
11 # Arguments 18 # Arguments
12 # 19 #
13 # plist_templates: 20 # plist_templates:
14 # string array, paths to plist files which will be used for the bundle. 21 # string array, paths to plist files which will be used for the bundle.
15 # 22 #
16 # executable_name: 23 # executable_name:
(...skipping 29 matching lines...) Expand all
46 "-s=GCC_VERSION=com.apple.compilers.llvm.clang.1_0", 53 "-s=GCC_VERSION=com.apple.compilers.llvm.clang.1_0",
47 "-s=PRODUCT_NAME=$executable_name", 54 "-s=PRODUCT_NAME=$executable_name",
48 "-s=XCODE_BUILD=$xcode_build", 55 "-s=XCODE_BUILD=$xcode_build",
49 "-s=XCODE_VERSION=$xcode_version", 56 "-s=XCODE_VERSION=$xcode_version",
50 "-o=" + rebase_path(outputs[0], root_build_dir), 57 "-o=" + rebase_path(outputs[0], root_build_dir),
51 ] + rebase_path(sources, root_build_dir) 58 ] + rebase_path(sources, root_build_dir)
52 args = [ "@{{response_file_name}}" ] 59 args = [ "@{{response_file_name}}" ]
53 } 60 }
54 } 61 }
55 62
56 # Generates Info.plist files for Mac apps and frameworks.
57 #
58 # Arguments
59 #
60 # info_plist:
61 # string, the path to an plist file that will be included in the final
62 # Info.plist generated.
63 #
64 # executable_name:
65 # string, name of the generated target used for the product
66 # and executable name as specified in the output Info.plist.
67 #
68 # extra_substitutions:
69 # (optional) string array, 'key=value' pairs for extra fields which are
70 # specified in a source Info.plist template.
71 template("mac_info_plist") {
72 info_plist(target_name) {
73 extra_substitutions = []
74 if (defined(invoker.extra_substitutions)) {
75 extra_substitutions = invoker.extra_substitutions
76 }
77 extra_substitutions += [
78 "MAC_SDK_BUILD=$mac_sdk_build",
79 "MAC_SDK_NAME=$mac_sdk_name$mac_sdk_version",
80 ]
81 plist_templates = [
82 "//build/config/mac/BuildInfo.plist",
83 invoker.info_plist,
84 ]
85 forward_variables_from(invoker, [ "executable_name" ])
86 }
87 }
88
89 # This is used as the base template for both iOS and Mac frameworks. 63 # This is used as the base template for both iOS and Mac frameworks.
90 # 64 #
91 # By default, the bundle target this template generates does not link the 65 # By default, the bundle target this template generates does not link the
92 # resulting framework into anything that depends on it. If a dependency wants 66 # resulting framework into anything that depends on it. If a dependency wants
93 # a link-time (as well as build-time) dependency on the framework bundle, 67 # a link-time (as well as build-time) dependency on the framework bundle,
94 # depend against "$target_name+link". If only the build-time dependency is 68 # depend against "$target_name+link". If only the build-time dependency is
95 # required (e.g., for copying into another bundle), then use "$target_name". 69 # required (e.g., for copying into another bundle), then use "$target_name".
96 # 70 #
97 # Arguments 71 # Arguments
98 # 72 #
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 ]) 270 ])
297 public_deps = [ 271 public_deps = [
298 ":$_target_name", 272 ":$_target_name",
299 ] 273 ]
300 public_configs = [ ":$_framework_public_config" ] 274 public_configs = [ ":$_framework_public_config" ]
301 } 275 }
302 } 276 }
303 277
304 # Template to combile .xib or .storyboard files. 278 # Template to combile .xib or .storyboard files.
305 # 279 #
306 #
307 # Arguments 280 # Arguments
308 # 281 #
309 # sources: 282 # sources:
310 # list of string, sources to compile 283 # list of string, sources to compile
311 # 284 #
312 # ibtool_flags: 285 # ibtool_flags:
313 # (optional) list of string, additional flags to pass to the ibtool 286 # (optional) list of string, additional flags to pass to the ibtool
314 template("compile_xibs") { 287 template("compile_xibs") {
315 action_foreach(target_name) { 288 action_foreach(target_name) {
316 forward_variables_from(invoker, 289 forward_variables_from(invoker,
(...skipping 15 matching lines...) Expand all
332 "$target_gen_dir/{{source_name_part}}.nib", 305 "$target_gen_dir/{{source_name_part}}.nib",
333 ] 306 ]
334 args = [ 307 args = [
335 "--input", 308 "--input",
336 "{{source}}", 309 "{{source}}",
337 "--output", 310 "--output",
338 rebase_path("$target_gen_dir/{{source_name_part}}.nib"), 311 rebase_path("$target_gen_dir/{{source_name_part}}.nib"),
339 ] + ibtool_flags 312 ] + ibtool_flags
340 } 313 }
341 } 314 }
342
343 # Template to compile and package Mac XIB files as bundle data.
344 #
345 # Arguments
346 #
347 # sources:
348 # list of string, sources to comiple
349 #
350 # output_path:
351 # (optional) string, the path to use for the outputs list in the
352 # bundle_data step. If unspecified, defaults to bundle_resources_dir.
353 template("mac_xib_bundle_data") {
354 _target_name = target_name
355 _compile_target_name = _target_name + "_compile_ibtool"
356
357 compile_xibs(_compile_target_name) {
358 forward_variables_from(invoker, [ "testonly" ])
359 visibility = [ ":$_target_name" ]
360 sources = invoker.sources
361 ibtool_flags = [
362 "--minimum-deployment-target",
363 mac_deployment_target,
364 "--target-device",
365 "mac",
366 ]
367 }
368
369 bundle_data(_target_name) {
370 forward_variables_from(invoker,
371 [
372 "testonly",
373 "visibility",
374 ])
375
376 public_deps = [
377 ":$_compile_target_name",
378 ]
379 sources = get_target_outputs(":$_compile_target_name")
380
381 _output_path = "{{bundle_resources_dir}}"
382 if (defined(invoker.output_path)) {
383 _output_path = invoker.output_path
384 }
385
386 outputs = [
387 "$_output_path/{{source_file_part}}",
388 ]
389 }
390 }
391
392 # Template to package a shared library into a Mac framework bundle.
393 #
394 # This template provides two targets to control whether the framework is
395 # merely built when targets depend on it, or whether it is linked as well:
396 # "$target_name" and "$target_name+link".
397 #
398 # See the //build/config/mac/rules.gni:framework_bundle for a discussion
399 # and examples.
400 #
401 # Arguments
402 #
403 # info_plist:
404 # string, path to the Info.plist file that will be used for the bundle.
405 #
406 # output_name:
407 # (optional) string, name of the generated framework without the
408 # .framework suffix. If omitted, defaults to target_name.
409 #
410 # framework_version:
411 # (optional) string, version of the framework. Typically this is a
412 # single letter, like "A". If omitted, the Versions/ subdirectory
413 # structure will not be created, and build output will go directly
414 # into the framework subdirectory.
415 #
416 # See "gn help shared_library" for more information on arguments supported
417 # by shared library target.
418 template("mac_framework_bundle") {
419 assert(defined(invoker.deps),
420 "Dependencies must be specified for $target_name")
421 assert(defined(invoker.info_plist),
422 "The Info.plist file must be specified for $target_name")
423
424 _info_plist_target = target_name + "_info_plist"
425
426 mac_info_plist(_info_plist_target) {
427 executable_name = target_name
428 if (defined(invoker.output_name)) {
429 executable_name = invoker.output_name
430 }
431 forward_variables_from(invoker, [ "info_plist" ])
432 }
433
434 _info_plist_bundle_data = _info_plist_target + "_bundle_data"
435
436 bundle_data(_info_plist_bundle_data) {
437 forward_variables_from(invoker, [ "testonly" ])
438 sources = get_target_outputs(":$_info_plist_target")
439 outputs = [
440 "{{bundle_root_dir}}/Info.plist",
441 ]
442 public_deps = [
443 ":$_info_plist_target",
444 ]
445 }
446
447 framework_bundle(target_name) {
448 forward_variables_from(invoker, "*", [ "info_plist" ])
449
450 if (!defined(deps)) {
451 deps = []
452 }
453 deps += [ ":$_info_plist_bundle_data" ]
454 }
455 }
456
457 # Template to create a Mac executable application bundle.
458 #
459 # Arguments
460 #
461 # info_plist:
462 # string, path to the Info.plist file that will be used for the bundle.
463 #
464 # output_name:
465 # (optional) string, name of the generated app without the
466 # .app suffix. If omitted, defaults to target_name.
467 template("mac_app_bundle") {
468 assert(defined(invoker.info_plist),
469 "The Info.plist file must be specified for $target_name")
470
471 _target_name = target_name
472 _output_name = target_name
473 if (defined(invoker.output_name)) {
474 _output_name = invoker.output_name
475 }
476
477 _executable_target = target_name + "_executable"
478 _executable_bundle_data = _executable_target + "_bundle_data"
479
480 executable(_executable_target) {
481 visibility = [ ":$_executable_bundle_data" ]
482 forward_variables_from(invoker,
483 "*",
484 [
485 "assert_no_deps",
486 "data_deps",
487 "info_plist",
488 "output_name",
489 "visibility",
490 ])
491 output_name = _output_name
492 output_dir = "$target_out_dir/$_executable_target"
493 }
494
495 bundle_data(_executable_bundle_data) {
496 visibility = [ ":$_target_name" ]
497 forward_variables_from(invoker, [ "testonly" ])
498 sources = [
499 "$target_out_dir/$_executable_target/$_output_name",
500 ]
501 outputs = [
502 "{{bundle_executable_dir}}/$_output_name",
503 ]
504 public_deps = [
505 ":$_executable_target",
506 ]
507 }
508
509 _info_plist_target = target_name + "_info_plist"
510
511 mac_info_plist(_info_plist_target) {
512 executable_name = _output_name
513 forward_variables_from(invoker, [ "info_plist" ])
514 }
515
516 _info_plist_bundle_data = _info_plist_target + "_bundle_data"
517
518 bundle_data(_info_plist_bundle_data) {
519 forward_variables_from(invoker, [ "testonly" ])
520 visibility = [ ":$_target_name" ]
521 sources = get_target_outputs(":$_info_plist_target")
522 outputs = [
523 "{{bundle_root_dir}}/Info.plist",
524 ]
525 public_deps = [
526 ":$_info_plist_target",
527 ]
528 }
529
530 create_bundle(_target_name) {
531 forward_variables_from(invoker,
532 [
533 "data_deps",
534 "deps",
535 "public_deps",
536 "testonly",
537 ])
538 if (!defined(deps)) {
539 deps = []
540 }
541 deps += [
542 ":$_executable_bundle_data",
543 ":$_info_plist_bundle_data",
544 ]
545
546 bundle_root_dir = "$root_out_dir/${_output_name}.app/Contents"
547 bundle_resources_dir = "$bundle_root_dir/Resources"
548 bundle_executable_dir = "$bundle_root_dir/MacOS"
549 }
550 }
551
552 # Template to package a loadable_module into a .plugin bundle.
553 #
554 # This takes no extra arguments that differ from a loadable_module.
555 template("mac_plugin_bundle") {
556 assert(defined(invoker.deps),
557 "Dependencies must be specified for $target_name")
558
559 _target_name = target_name
560 _loadable_module_target = _target_name + "_loadable_module"
561 _loadable_module_bundle_data = _loadable_module_target + "_bundle_data"
562
563 _output_name = _target_name
564 if (defined(invoker.output_name)) {
565 _output_name = invoker.output_name
566 }
567
568 loadable_module(_loadable_module_target) {
569 visibility = [ ":$_loadable_module_bundle_data" ]
570 forward_variables_from(invoker,
571 "*",
572 [
573 "assert_no_deps",
574 "data_deps",
575 "output_name",
576 "visibility",
577 ])
578 output_dir = "$target_out_dir"
579 output_name = _output_name
580 }
581
582 bundle_data(_loadable_module_bundle_data) {
583 forward_variables_from(invoker, [ "testonly" ])
584 visibility = [ ":$_target_name" ]
585 sources = [
586 "$target_out_dir/${_output_name}.so",
587 ]
588 outputs = [
589 "{{bundle_executable_dir}}/$_output_name",
590 ]
591 public_deps = [
592 ":$_loadable_module_target",
593 ]
594 }
595
596 create_bundle(_target_name) {
597 forward_variables_from(invoker,
598 [
599 "data_deps",
600 "deps",
601 "public_deps",
602 "testonly",
603 "visibility",
604 ])
605 if (!defined(deps)) {
606 deps = []
607 }
608 deps += [ ":$_loadable_module_bundle_data" ]
609
610 bundle_root_dir = "$root_out_dir/$_output_name.plugin/Contents"
611 bundle_executable_dir = "$bundle_root_dir/MacOS"
612 }
613 }
OLDNEW
« no previous file with comments | « build/config/ios/rules.gni ('k') | build/config/mac/rules.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698