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

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

Issue 2369583002: [Mac/GN] Add a product_type option to mac_app_bundle. (Closed)
Patch Set: '' Created 4 years, 3 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 | « no previous file | no next file » | 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 2015 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 import("//build/config/mac/base_rules.gni") 5 import("//build/config/mac/base_rules.gni")
6 6
7 # Generates Info.plist files for Mac apps and frameworks. 7 # Generates Info.plist files for Mac apps and frameworks.
8 # 8 #
9 # Arguments 9 # Arguments
10 # 10 #
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 } 393 }
394 394
395 set_defaults("mac_framework_bundle") { 395 set_defaults("mac_framework_bundle") {
396 configs = default_shared_library_configs 396 configs = default_shared_library_configs
397 } 397 }
398 398
399 # Template to create a Mac executable application bundle. 399 # Template to create a Mac executable application bundle.
400 # 400 #
401 # Arguments 401 # Arguments
402 # 402 #
403 # package_type:
404 # (optional) string, the product package type to create. Options are:
405 # "app" to create a .app bundle (default)
406 # "xpc" to create an .xpc service bundle
407 #
403 # info_plist: 408 # info_plist:
404 # (optional) string, path to the Info.plist file that will be used for 409 # (optional) string, path to the Info.plist file that will be used for
405 # the bundle. 410 # the bundle.
406 # 411 #
407 # info_plist_target: 412 # info_plist_target:
408 # (optional) string, if the info_plist is generated from an action, 413 # (optional) string, if the info_plist is generated from an action,
409 # rather than a regular source file, specify the target name in lieu 414 # rather than a regular source file, specify the target name in lieu
410 # of info_plist. The two arguments are mutually exclusive. 415 # of info_plist. The two arguments are mutually exclusive.
411 # 416 #
412 # output_name: 417 # output_name:
(...skipping 10 matching lines...) Expand all
423 # extra_substitutions: 428 # extra_substitutions:
424 # (optional) string array, 'key=value' pairs for extra fields which are 429 # (optional) string array, 'key=value' pairs for extra fields which are
425 # specified in a source Info.plist template. 430 # specified in a source Info.plist template.
426 template("mac_app_bundle") { 431 template("mac_app_bundle") {
427 _target_name = target_name 432 _target_name = target_name
428 _output_name = target_name 433 _output_name = target_name
429 if (defined(invoker.output_name)) { 434 if (defined(invoker.output_name)) {
430 _output_name = invoker.output_name 435 _output_name = invoker.output_name
431 } 436 }
432 437
438 _package_type = "app"
439 if (defined(invoker.package_type)) {
440 _package_type = invoker.package_type
441 }
442
443 if (_package_type == "app") {
444 _output_extension = "app"
445 _product_type = "com.apple.product-type.application"
446 _write_pkg_info = true
447 } else if (_package_type == "xpc") {
448 _output_extension = "xpc"
449 _product_type = "com.apple.product-type.xpc-service"
450 _write_pkg_info = false
451 } else {
452 assert(false, "Unsupported packge_type: " + packge_type)
453 }
454
433 _executable_target = target_name + "_executable" 455 _executable_target = target_name + "_executable"
434 _executable_bundle_data = _executable_target + "_bundle_data" 456 _executable_bundle_data = _executable_target + "_bundle_data"
435 457
436 _info_plist_target = target_name + "_info_plist" 458 _info_plist_target = target_name + "_info_plist"
437 459
438 mac_info_plist(_info_plist_target) { 460 mac_info_plist(_info_plist_target) {
439 executable_name = _output_name 461 executable_name = _output_name
440 forward_variables_from(invoker, 462 forward_variables_from(invoker,
441 [ 463 [
442 "extra_substitutions", 464 "extra_substitutions",
443 "info_plist", 465 "info_plist",
444 "info_plist_target", 466 "info_plist_target",
445 "testonly", 467 "testonly",
446 ]) 468 ])
447 } 469 }
448 470
449 _pkg_info_target = target_name + "_pkg_info" 471 if (_write_pkg_info) {
472 _pkg_info_target = target_name + "_pkg_info"
450 473
451 action(_pkg_info_target) { 474 action(_pkg_info_target) {
452 forward_variables_from(invoker, [ "testonly" ]) 475 forward_variables_from(invoker, [ "testonly" ])
453 script = "//build/config/mac/write_pkg_info.py" 476 script = "//build/config/mac/write_pkg_info.py"
454 sources = get_target_outputs(":$_info_plist_target") 477 sources = get_target_outputs(":$_info_plist_target")
455 outputs = [ 478 outputs = [
456 "$target_gen_dir/$_pkg_info_target", 479 "$target_gen_dir/$_pkg_info_target",
457 ] 480 ]
458 args = [ "--plist" ] + rebase_path(sources, root_build_dir) + 481 args = [ "--plist" ] + rebase_path(sources, root_build_dir) +
459 [ "--output" ] + rebase_path(outputs, root_build_dir) 482 [ "--output" ] + rebase_path(outputs, root_build_dir)
460 deps = [ 483 deps = [
461 ":$_info_plist_target", 484 ":$_info_plist_target",
462 ] 485 ]
486 }
463 } 487 }
464 488
465 executable(_executable_target) { 489 executable(_executable_target) {
466 visibility = [ ":$_executable_bundle_data" ] 490 visibility = [ ":$_executable_bundle_data" ]
467 forward_variables_from(invoker, 491 forward_variables_from(invoker,
468 "*", 492 "*",
469 [ 493 [
470 "assert_no_deps", 494 "assert_no_deps",
471 "data_deps", 495 "data_deps",
472 "info_plist", 496 "info_plist",
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 visibility = [ ":$_target_name" ] 528 visibility = [ ":$_target_name" ]
505 sources = get_target_outputs(":$_info_plist_target") 529 sources = get_target_outputs(":$_info_plist_target")
506 outputs = [ 530 outputs = [
507 "{{bundle_root_dir}}/Info.plist", 531 "{{bundle_root_dir}}/Info.plist",
508 ] 532 ]
509 public_deps = [ 533 public_deps = [
510 ":$_info_plist_target", 534 ":$_info_plist_target",
511 ] 535 ]
512 } 536 }
513 537
514 _pkg_info_bundle_data = _pkg_info_target + "_bundle_data" 538 if (_write_pkg_info) {
539 _pkg_info_bundle_data = _pkg_info_target + "_bundle_data"
515 540
516 bundle_data(_pkg_info_bundle_data) { 541 bundle_data(_pkg_info_bundle_data) {
517 forward_variables_from(invoker, [ "testonly" ]) 542 forward_variables_from(invoker, [ "testonly" ])
518 visibility = [ ":$_target_name" ] 543 visibility = [ ":$_target_name" ]
519 sources = get_target_outputs(":$_pkg_info_target") 544 sources = get_target_outputs(":$_pkg_info_target")
520 outputs = [ 545 outputs = [
521 "{{bundle_root_dir}}/PkgInfo", 546 "{{bundle_root_dir}}/PkgInfo",
522 ] 547 ]
523 public_deps = [ 548 public_deps = [
524 ":$_pkg_info_target", 549 ":$_pkg_info_target",
525 ] 550 ]
551 }
526 } 552 }
527 553
528 create_bundle(_target_name) { 554 create_bundle(_target_name) {
529 forward_variables_from(invoker, 555 forward_variables_from(invoker,
530 [ 556 [
531 "data_deps", 557 "data_deps",
532 "deps", 558 "deps",
533 "public_deps", 559 "public_deps",
534 "testonly", 560 "testonly",
535 ]) 561 ])
536 if (!defined(deps)) { 562 if (!defined(deps)) {
537 deps = [] 563 deps = []
538 } 564 }
539 deps += [ 565 deps += [
540 ":$_executable_bundle_data", 566 ":$_executable_bundle_data",
541 ":$_info_plist_bundle_data", 567 ":$_info_plist_bundle_data",
542 ":$_pkg_info_bundle_data",
543 ] 568 ]
544 product_type = "com.apple.product-type.application" 569 if (_write_pkg_info) {
545 bundle_root_dir = "$root_out_dir/${_output_name}.app/Contents" 570 deps += [ ":$_pkg_info_bundle_data" ]
571 }
572 product_type = _product_type
573 bundle_root_dir =
574 "$root_out_dir/${_output_name}.${_output_extension}/Contents"
546 bundle_resources_dir = "$bundle_root_dir/Resources" 575 bundle_resources_dir = "$bundle_root_dir/Resources"
547 bundle_executable_dir = "$bundle_root_dir/MacOS" 576 bundle_executable_dir = "$bundle_root_dir/MacOS"
548 } 577 }
549 } 578 }
550 579
551 # Template to package a loadable_module into a .plugin bundle. 580 # Template to package a loadable_module into a .plugin bundle.
552 # 581 #
553 # This takes no extra arguments that differ from a loadable_module. 582 # This takes no extra arguments that differ from a loadable_module.
554 template("mac_plugin_bundle") { 583 template("mac_plugin_bundle") {
555 assert(defined(invoker.deps), 584 assert(defined(invoker.deps),
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 ]) 632 ])
604 if (!defined(deps)) { 633 if (!defined(deps)) {
605 deps = [] 634 deps = []
606 } 635 }
607 deps += [ ":$_loadable_module_bundle_data" ] 636 deps += [ ":$_loadable_module_bundle_data" ]
608 637
609 bundle_root_dir = "$root_out_dir/$_output_name.plugin/Contents" 638 bundle_root_dir = "$root_out_dir/$_output_name.plugin/Contents"
610 bundle_executable_dir = "$bundle_root_dir/MacOS" 639 bundle_executable_dir = "$bundle_root_dir/MacOS"
611 } 640 }
612 } 641 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698