| OLD | NEW |
| 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/ios/ios_sdk.gni") | 5 import("//build/config/ios/ios_sdk.gni") |
| 6 import("//build/config/mac/base_rules.gni") | 6 import("//build/config/mac/base_rules.gni") |
| 7 import("//build/config/mac/symbols.gni") | 7 import("//build/config/mac/symbols.gni") |
| 8 | 8 |
| 9 _is_secondary_build = | 9 # Control whether an intermediate source_set is used when building executables |
| 10 additional_toolchains != [] && current_toolchain != default_toolchain | 10 # and shared_libraries for ios_app_bundle and ios_framework_bundle. This is a |
| 11 | 11 # temporary flag that will be removed once scoped_nsobject_unittest{_arc}.mm |
| 12 _code_signing_script_path = "//build/config/ios/codesign.py" | 12 # tests are passing with this flag set to true (see crbug.com/637065) |
| 13 _default_entitlements_path = "//build/config/ios/entitlements.plist" | 13 _use_intermediate_source_set = false |
| 14 |
| 15 # Invokes lipo on multiple arch-specific binaries to create a fat binary. |
| 16 # |
| 17 # Arguments |
| 18 # |
| 19 # arch_binary_target |
| 20 # name of the target generating the arch-specific binaries, they must |
| 21 # be named $target_out_dir/$toolchain_cpu/$arch_binary_output. |
| 22 # |
| 23 # arch_binary_output |
| 24 # (optional, defaults to the name of $arch_binary_target) base name of |
| 25 # the arch-specific binary generated by arch_binary_target. |
| 26 # |
| 27 # output_name |
| 28 # (optional, defaults to $target_name) base name of the target output, |
| 29 # the full path will be $target_out_dir/$output_name. |
| 30 # |
| 31 # configs |
| 32 # (optional) a list of configurations, this is used to check whether |
| 33 # the binary should be stripped, when "enable_stripping" is true. |
| 34 # |
| 35 template("lipo_binary") { |
| 36 assert(defined(invoker.arch_binary_target), |
| 37 "arch_binary_target must be defined for $target_name") |
| 38 |
| 39 _target_name = target_name |
| 40 _output_name = target_name |
| 41 if (defined(invoker.output_name)) { |
| 42 _output_name = invoker.output_name |
| 43 } |
| 44 |
| 45 _all_target_cpu = [ current_cpu ] + additional_target_cpus |
| 46 _all_toolchains = [ current_toolchain ] + additional_toolchains |
| 47 |
| 48 _arch_binary_target = invoker.arch_binary_target |
| 49 _arch_binary_output = get_label_info(_arch_binary_target, "name") |
| 50 if (defined(invoker.arch_binary_output)) { |
| 51 _arch_binary_output = invoker.arch_binary_output |
| 52 } |
| 53 |
| 54 action(_target_name) { |
| 55 forward_variables_from(invoker, |
| 56 "*", |
| 57 [ |
| 58 "arch_binary_output", |
| 59 "arch_binary_target", |
| 60 "configs", |
| 61 "output_name", |
| 62 ]) |
| 63 |
| 64 script = "//build/toolchain/mac/linker_driver.py" |
| 65 |
| 66 outputs = [ |
| 67 "$target_out_dir/$_output_name", |
| 68 ] |
| 69 |
| 70 deps = [] |
| 71 _index = 0 |
| 72 inputs = [] |
| 73 foreach(_cpu, _all_target_cpu) { |
| 74 _toolchain = _all_toolchains[_index] |
| 75 _index = _index + 1 |
| 76 |
| 77 inputs += |
| 78 [ get_label_info("$_arch_binary_target($_toolchain)", |
| 79 "target_out_dir") + "/$_cpu/$_arch_binary_output" ] |
| 80 |
| 81 deps += [ "$_arch_binary_target($_toolchain)" ] |
| 82 } |
| 83 |
| 84 args = [ |
| 85 "xcrun", |
| 86 "lipo", |
| 87 "-create", |
| 88 "-output", |
| 89 rebase_path("$target_out_dir/$_output_name", root_build_dir), |
| 90 ] + rebase_path(inputs, root_build_dir) |
| 91 |
| 92 if (enable_dsyms) { |
| 93 _dsyms_output_dir = "$root_out_dir/$_output_name.dSYM" |
| 94 outputs += [ |
| 95 "$_dsyms_output_dir/", |
| 96 "$_dsyms_output_dir/Contents/Info.plist", |
| 97 "$_dsyms_output_dir/Contents/Resources/DWARF/$_output_name", |
| 98 ] |
| 99 args += [ "-Wcrl,dsym," + rebase_path("$root_out_dir/.", root_build_dir) ] |
| 100 } |
| 101 |
| 102 if (enable_stripping) { |
| 103 # Check whether //build/config/mac:strip_all has been removed from the |
| 104 # configs variables (as this is how stripping is disabled for a single |
| 105 # target). |
| 106 _strip_all_in_config = false |
| 107 if (defined(invoker.configs)) { |
| 108 foreach(_config, invoker.configs) { |
| 109 if (_config == "//build/config/mac:strip_all") { |
| 110 _strip_all_in_config = true |
| 111 } |
| 112 } |
| 113 } |
| 114 |
| 115 if (_strip_all_in_config) { |
| 116 args += [ "-Wcrl,strip,-x,-S" ] |
| 117 if (save_unstripped_output) { |
| 118 outputs += [ "$root_out_dir/$_output_name.unstripped" ] |
| 119 args += [ "-Wcrl,unstripped," + |
| 120 rebase_path("$root_out_dir/.", root_build_dir) ] |
| 121 } |
| 122 } |
| 123 } |
| 124 } |
| 125 } |
| 126 |
| 127 # Wrapper around create_bundle taking care of code signature settings. |
| 128 # |
| 129 # Arguments |
| 130 # |
| 131 # product_type |
| 132 # string, product type for the generated Xcode project. |
| 133 # |
| 134 # bundle_extension |
| 135 # string, extension of the bundle, used to generate bundle name. |
| 136 # |
| 137 # bundle_binary_target |
| 138 # string, label of the target generating the bundle main binary. |
| 139 # |
| 140 # bundle_binary_output |
| 141 # (optional) string, base name of the binary generated by the |
| 142 # bundle_binary_target target, defaults to the target name. |
| 143 # |
| 144 # extra_system_frameworks |
| 145 # (optional) list of system framework to copy to the bundle. |
| 146 # |
| 147 # enable_code_signing |
| 148 # (optional) boolean, control whether code signing is enabled or not, |
| 149 # default to ios_enable_code_signing if not defined. |
| 150 # |
| 151 template("create_signed_bundle") { |
| 152 assert(defined(invoker.product_type), |
| 153 "product_type must be defined for $target_name") |
| 154 assert(defined(invoker.bundle_extension), |
| 155 "bundle_extension must be defined for $target_name") |
| 156 assert(defined(invoker.bundle_binary_target), |
| 157 "bundle_binary_target must be defined for $target_name") |
| 158 |
| 159 _target_name = target_name |
| 160 _output_name = target_name |
| 161 if (defined(invoker.output_name)) { |
| 162 _output_name = invoker.output_name |
| 163 } |
| 164 |
| 165 _bundle_binary_target = invoker.bundle_binary_target |
| 166 _bundle_binary_output = get_label_info(_bundle_binary_target, "name") |
| 167 if (defined(invoker.bundle_binary_output)) { |
| 168 _bundle_binary_output = invoker.bundle_binary_output |
| 169 } |
| 170 |
| 171 _bundle_extension = invoker.bundle_extension |
| 172 _bundle_root_dir = "$root_out_dir/$_output_name$_bundle_extension" |
| 173 |
| 174 _entitlements_path = "//build/config/ios/entitlements.plist" |
| 175 if (defined(invoker.entitlements_path)) { |
| 176 _entitlements_path = invoker.entitlements_path |
| 177 } |
| 178 |
| 179 _enable_code_signing = ios_enable_code_signing |
| 180 if (defined(invoker.enable_code_signing)) { |
| 181 _enable_code_signing = invoker.enable_code_signing |
| 182 } |
| 183 |
| 184 create_bundle(_target_name) { |
| 185 forward_variables_from(invoker, |
| 186 [ |
| 187 "data_deps", |
| 188 "deps", |
| 189 "product_type", |
| 190 "public_configs", |
| 191 "public_deps", |
| 192 "testonly", |
| 193 "visibility", |
| 194 ]) |
| 195 |
| 196 bundle_root_dir = _bundle_root_dir |
| 197 bundle_resources_dir = _bundle_root_dir |
| 198 bundle_executable_dir = _bundle_root_dir |
| 199 bundle_plugins_dir = "$_bundle_root_dir/PlugIns" |
| 200 |
| 201 if (!defined(public_deps)) { |
| 202 public_deps = [] |
| 203 } |
| 204 public_deps += [ _bundle_binary_target ] |
| 205 |
| 206 if (defined(invoker.bundle_deps)) { |
| 207 if (!defined(deps)) { |
| 208 deps = [] |
| 209 } |
| 210 deps += invoker.bundle_deps |
| 211 } |
| 212 |
| 213 code_signing_script = "//build/config/ios/codesign.py" |
| 214 code_signing_sources = [ |
| 215 _entitlements_path, |
| 216 get_label_info(_bundle_binary_target, "target_out_dir") + |
| 217 "/$_bundle_binary_output", |
| 218 ] |
| 219 code_signing_outputs = [ "$_bundle_root_dir/$_output_name" ] |
| 220 if (_enable_code_signing) { |
| 221 code_signing_outputs += |
| 222 [ "$_bundle_root_dir/_CodeSignature/CodeResources" ] |
| 223 } |
| 224 if (ios_code_signing_identity != "" && ios_sdk_name != "iphonesimulator") { |
| 225 code_signing_outputs += [ "$_bundle_root_dir/embedded.mobileprovision" ] |
| 226 } |
| 227 |
| 228 if (defined(invoker.extra_system_frameworks)) { |
| 229 foreach(_framework, invoker.extra_system_frameworks) { |
| 230 code_signing_outputs += [ "$bundle_root_dir/Frameworks/" + |
| 231 get_path_info(_framework, "file") ] |
| 232 } |
| 233 } |
| 234 |
| 235 code_signing_args = [ |
| 236 "code-sign-bundle", |
| 237 "-t=" + ios_sdk_name, |
| 238 "-i=" + ios_code_signing_identity, |
| 239 "-e=" + rebase_path(_entitlements_path, root_build_dir), |
| 240 "-b=" + rebase_path("$target_out_dir/$_output_name", root_build_dir), |
| 241 rebase_path(bundle_root_dir, root_build_dir), |
| 242 ] |
| 243 if (!_enable_code_signing) { |
| 244 code_signing_args += [ "--disable-code-signature" ] |
| 245 } |
| 246 if (defined(invoker.extra_system_frameworks)) { |
| 247 # All framework in extra_system_frameworks are expected to be |
| 248 # system framework and the path to be already system absolute |
| 249 # so do not use rebase_path here. |
| 250 foreach(_framework, invoker.extra_system_frameworks) { |
| 251 code_signing_args += [ "-F=" + _framework ] |
| 252 } |
| 253 } |
| 254 } |
| 255 } |
| 14 | 256 |
| 15 # Generates Info.plist files for Mac apps and frameworks. | 257 # Generates Info.plist files for Mac apps and frameworks. |
| 16 # | 258 # |
| 17 # Arguments | 259 # Arguments |
| 18 # | 260 # |
| 19 # info_plist: | 261 # info_plist: |
| 20 # (optional) string, path to the Info.plist file that will be used for | 262 # (optional) string, path to the Info.plist file that will be used for |
| 21 # the bundle. | 263 # the bundle. |
| 22 # | 264 # |
| 23 # info_plist_target: | 265 # info_plist_target: |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 # //build/config/ios/entitlements.plist. | 352 # //build/config/ios/entitlements.plist. |
| 111 # | 353 # |
| 112 # bundle_extension: | 354 # bundle_extension: |
| 113 # (optional) bundle extension including the dot, default to ".app". | 355 # (optional) bundle extension including the dot, default to ".app". |
| 114 # | 356 # |
| 115 # product_type | 357 # product_type |
| 116 # (optional) string, product type for the generated Xcode project, | 358 # (optional) string, product type for the generated Xcode project, |
| 117 # default to "com.apple.product-type.application". Should generally | 359 # default to "com.apple.product-type.application". Should generally |
| 118 # not be overridden. | 360 # not be overridden. |
| 119 # | 361 # |
| 362 # enable_code_signing |
| 363 # (optional) boolean, control whether code signing is enabled or not, |
| 364 # default to ios_enable_code_signing if not defined. |
| 365 # |
| 120 # For more information, see "gn help executable". | 366 # For more information, see "gn help executable". |
| 121 template("ios_app_bundle") { | 367 template("ios_app_bundle") { |
| 122 _output_name = target_name | 368 _output_name = target_name |
| 123 _target_name = target_name | 369 _target_name = target_name |
| 124 if (defined(invoker.output_name)) { | 370 if (defined(invoker.output_name)) { |
| 125 _output_name = invoker.output_name | 371 _output_name = invoker.output_name |
| 126 } | 372 } |
| 127 | 373 |
| 128 # This template expands to multiple targets with some differences between | 374 _arch_executable_source = _target_name + "_arch_executable_sources" |
| 129 # the the different build configuration. | 375 _arch_executable_target = _target_name + "_arch_executable" |
| 130 # | 376 _lipo_executable_target = _target_name + "_executable" |
| 131 # For a thin build (i.e. when additional_target_cpus is an empty list), | |
| 132 # it compiles the final application binary with an "executable" target, | |
| 133 # performs variable expansions on the Info.plist, defines some "bundle_data" | |
| 134 # target to pack Info.plist and the executable into the .app bundle, and | |
| 135 # finally a "create_bundle" target that packs everything the bundle. If the | |
| 136 # bundle needs to be signed, then the binary is copied into the bundle by | |
| 137 # the "create_bundle" target and the intermediate "bundle_data" target is | |
| 138 # not generated. | |
| 139 # | |
| 140 # For a multi-architecture build (aka fat-build), the template expands to | |
| 141 # a simple "executable" target for non-default toolchain. This is because | |
| 142 # the real application bundle will contains a single binary that supports | |
| 143 # all the architectures and creating a separate .app bundle for every | |
| 144 # architecture would be a waste of time. | |
| 145 # | |
| 146 # The target for the default toolchain of a multi-architecture build will | |
| 147 # build the executable for current_cpu in a temporary location. The real | |
| 148 # fat binary will be created by "lipo" command from all those "executable" | |
| 149 # target (including those of the non-default toolchains). This additional | |
| 150 # target has the same role as the "executable" target of a thin build. | |
| 151 # | |
| 152 # The rest of the build, including the codesigning step, are the same for | |
| 153 # thin and fat builds. | |
| 154 | 377 |
| 155 _executable_extra_deps = [] | 378 if (_use_intermediate_source_set) { |
| 156 _executable_extra_inputs = [] | 379 source_set(_arch_executable_source) { |
| 157 _executable_extra_ldflags = [] | |
| 158 | |
| 159 # Embeds the entitlements file if building for simulator. This is optional | |
| 160 # with Xcode 7 or older but required with Xcode 8. This is not necessary for | |
| 161 # device build as the entitlement is embedded via the codesigning step. | |
| 162 if (use_ios_simulator) { | |
| 163 _generate_entitlements_target = _target_name + "_gen_entitlements" | |
| 164 _generate_entitlements_target_with_toolchain_suffix = | |
| 165 "$_generate_entitlements_target($default_toolchain)" | |
| 166 | |
| 167 _generate_entitlements_output = | |
| 168 get_label_info(_generate_entitlements_target_with_toolchain_suffix, | |
| 169 "target_gen_dir") + "/$_output_name.xcent" | |
| 170 | |
| 171 _executable_extra_inputs += [ _generate_entitlements_output ] | |
| 172 _executable_extra_deps += | |
| 173 [ ":$_generate_entitlements_target_with_toolchain_suffix" ] | |
| 174 _executable_extra_ldflags += [ | |
| 175 "-Xlinker", | |
| 176 "-sectcreate", | |
| 177 "-Xlinker", | |
| 178 "__TEXT", | |
| 179 "-Xlinker", | |
| 180 "__entitlements", | |
| 181 "-Xlinker", | |
| 182 rebase_path(_generate_entitlements_output, root_build_dir), | |
| 183 ] | |
| 184 } | |
| 185 | |
| 186 if (_is_secondary_build) { | |
| 187 # For the non-default toolchain of a fat-build, the template expands to a | |
| 188 # single "executable" target that creates "$root_out_dir/$_output_name". | |
| 189 executable(_target_name) { | |
| 190 forward_variables_from(invoker, | 380 forward_variables_from(invoker, |
| 191 "*", | 381 "*", |
| 192 [ | 382 [ |
| 193 "bundle_deps", | 383 "bundle_deps", |
| 194 "bundle_deps_filter", | 384 "bundle_deps_filter", |
| 195 "bundle_extension", | 385 "bundle_extension", |
| 386 "enable_code_signing", |
| 196 "entitlements_path", | 387 "entitlements_path", |
| 197 "extra_substitutions", | 388 "extra_substitutions", |
| 198 "extra_system_frameworks", | 389 "extra_system_frameworks", |
| 199 "info_plist", | 390 "info_plist", |
| 200 "info_plist_target", | 391 "info_plist_target", |
| 201 "output_name", | 392 "output_name", |
| 202 "product_type", | 393 "product_type", |
| 394 "visibility", |
| 203 ]) | 395 ]) |
| 204 | 396 |
| 205 if (defined(visibility)) { | 397 visibility = [ ":$_arch_executable_target" ] |
| 206 visibility += [ ":*($default_toolchain)" ] | 398 } |
| 399 } else { |
| 400 assert(_arch_executable_source != "", |
| 401 "mark _arch_executable_source as used") |
| 402 } |
| 403 |
| 404 if (use_ios_simulator) { |
| 405 _generate_entitlements_target = _target_name + "_gen_entitlements" |
| 406 _generate_entitlements_output = |
| 407 get_label_info(":$_generate_entitlements_target($default_toolchain)", |
| 408 "target_out_dir") + "/$_output_name.xcent" |
| 409 } |
| 410 |
| 411 executable(_arch_executable_target) { |
| 412 forward_variables_from(invoker, |
| 413 "*", |
| 414 [ |
| 415 "bundle_deps", |
| 416 "bundle_deps_filter", |
| 417 "bundle_extension", |
| 418 "enable_code_signing", |
| 419 "entitlements_path", |
| 420 "extra_substitutions", |
| 421 "extra_system_frameworks", |
| 422 "info_plist", |
| 423 "info_plist_target", |
| 424 "output_name", |
| 425 "product_type", |
| 426 "sources", |
| 427 "visibility", |
| 428 ]) |
| 429 if (!_use_intermediate_source_set) { |
| 430 forward_variables_from(invoker, [ "sources" ]) |
| 431 } |
| 432 |
| 433 visibility = [ ":$_lipo_executable_target($default_toolchain)" ] |
| 434 if (current_toolchain != default_toolchain) { |
| 435 visibility += [ ":$_target_name" ] |
| 436 } |
| 437 |
| 438 if (!defined(deps)) { |
| 439 deps = [] |
| 440 } |
| 441 if (_use_intermediate_source_set) { |
| 442 deps += [ ":$_arch_executable_source" ] |
| 443 } |
| 444 |
| 445 if (!defined(libs)) { |
| 446 libs = [] |
| 447 } |
| 448 libs += [ "UIKit.framework" ] |
| 449 |
| 450 if (use_ios_simulator) { |
| 451 deps += [ ":$_generate_entitlements_target($default_toolchain)" ] |
| 452 |
| 453 if (!defined(inputs)) { |
| 454 inputs = [] |
| 207 } | 455 } |
| 208 | 456 inputs += [ _generate_entitlements_output ] |
| 209 if (!defined(deps)) { | |
| 210 deps = [] | |
| 211 } | |
| 212 deps += _executable_extra_deps | |
| 213 | 457 |
| 214 if (!defined(ldflags)) { | 458 if (!defined(ldflags)) { |
| 215 ldflags = [] | 459 ldflags = [] |
| 216 } | 460 } |
| 217 ldflags += _executable_extra_ldflags | 461 ldflags += [ |
| 462 "-Xlinker", |
| 463 "-sectcreate", |
| 464 "-Xlinker", |
| 465 "__TEXT", |
| 466 "-Xlinker", |
| 467 "__entitlements", |
| 468 "-Xlinker", |
| 469 rebase_path(_generate_entitlements_output, root_build_dir), |
| 470 ] |
| 471 } |
| 218 | 472 |
| 219 if (!defined(inputs)) { | 473 output_name = _output_name |
| 220 inputs = [] | 474 output_prefix_override = true |
| 221 } | 475 output_dir = "$target_out_dir/$current_cpu" |
| 222 inputs += _executable_extra_inputs | 476 } |
| 223 | 477 |
| 224 output_name = _output_name | 478 if (current_toolchain != default_toolchain) { |
| 225 if (!defined(libs)) { | 479 # For fat builds, only the default toolchain will generate an application |
| 226 libs = [] | 480 # bundle. For the other toolchains, the template is only used for building |
| 227 } | 481 # the arch-specific binary, thus the default target is just a group(). |
| 228 libs += [ "UIKit.framework" ] | 482 |
| 483 group(_target_name) { |
| 484 forward_variables_from(invoker, |
| 485 [ |
| 486 "visibility", |
| 487 "testonly", |
| 488 ]) |
| 489 public_deps = [ |
| 490 ":$_arch_executable_target", |
| 491 ] |
| 229 } | 492 } |
| 230 } else { | 493 } else { |
| 231 # This is either a thin build or the default toolchain of a fat-build. | 494 lipo_binary(_lipo_executable_target) { |
| 232 # The template will expand in many different target ($target_name is the | 495 forward_variables_from(invoker, |
| 233 # create_bundle target) used as input to the create_bundle target. | 496 [ |
| 234 _generate_info_plist = target_name + "_generate_info_plist" | 497 "configs", |
| 235 _bundle_data_info_plist = target_name + "_bundle_data_info_plist" | 498 "testonly", |
| 499 ]) |
| 236 | 500 |
| 237 _entitlements_path = _default_entitlements_path | 501 visibility = [ ":$_target_name" ] |
| 238 if (defined(invoker.entitlements_path)) { | 502 output_name = _output_name |
| 239 _entitlements_path = invoker.entitlements_path | 503 arch_binary_target = ":$_arch_executable_target" |
| 504 arch_binary_output = _output_name |
| 240 } | 505 } |
| 241 | 506 |
| 507 _generate_info_plist = target_name + "_generate_info_plist" |
| 242 ios_info_plist(_generate_info_plist) { | 508 ios_info_plist(_generate_info_plist) { |
| 243 visibility = [ ":$_bundle_data_info_plist" ] | |
| 244 if (use_ios_simulator) { | |
| 245 visibility += [ ":$_generate_entitlements_target" ] | |
| 246 } | |
| 247 executable_name = _output_name | |
| 248 forward_variables_from(invoker, | 509 forward_variables_from(invoker, |
| 249 [ | 510 [ |
| 250 "extra_substitutions", | 511 "extra_substitutions", |
| 251 "info_plist", | 512 "info_plist", |
| 252 "info_plist_target", | 513 "info_plist_target", |
| 253 ]) | 514 ]) |
| 254 } | |
| 255 | 515 |
| 256 bundle_data(_bundle_data_info_plist) { | 516 executable_name = _output_name |
| 257 visibility = [ ":$_target_name" ] | |
| 258 forward_variables_from(invoker, [ "testonly" ]) | |
| 259 sources = get_target_outputs(":$_generate_info_plist") | |
| 260 outputs = [ | |
| 261 "{{bundle_root_dir}}/Info.plist", | |
| 262 ] | |
| 263 public_deps = [ | |
| 264 ":$_generate_info_plist", | |
| 265 ] | |
| 266 } | 517 } |
| 267 | 518 |
| 268 if (use_ios_simulator) { | 519 if (use_ios_simulator) { |
| 520 _entitlements_path = "//build/config/ios/entitlements.plist" |
| 521 if (defined(invoker.entitlements_path)) { |
| 522 _entitlements_path = invoker.entitlements_path |
| 523 } |
| 524 |
| 269 action(_generate_entitlements_target) { | 525 action(_generate_entitlements_target) { |
| 270 _gen_info_plist_target = ":$_generate_info_plist" | 526 _gen_info_plist_outputs = get_target_outputs(":$_generate_info_plist") |
| 271 _gen_info_plist_outputs = get_target_outputs(_gen_info_plist_target) | |
| 272 _info_plist_path = _gen_info_plist_outputs[0] | 527 _info_plist_path = _gen_info_plist_outputs[0] |
| 273 | 528 |
| 274 script = _code_signing_script_path | 529 script = "//build/config/ios/codesign.py" |
| 275 deps = [ | 530 deps = [ |
| 276 _gen_info_plist_target, | 531 ":$_generate_info_plist", |
| 277 ] | 532 ] |
| 278 sources = [ | 533 sources = [ |
| 279 _entitlements_path, | 534 _entitlements_path, |
| 280 _info_plist_path, | 535 _info_plist_path, |
| 281 ] | 536 ] |
| 282 outputs = [ | 537 outputs = [ |
| 283 _generate_entitlements_output, | 538 _generate_entitlements_output, |
| 284 ] | 539 ] |
| 285 args = [ | 540 args = [ |
| 286 "generate-entitlements", | 541 "generate-entitlements", |
| 287 "-e=" + rebase_path(_entitlements_path, root_build_dir), | 542 "-e=" + rebase_path(_entitlements_path, root_build_dir), |
| 288 "-p=" + rebase_path(_info_plist_path, root_build_dir), | 543 "-p=" + rebase_path(_info_plist_path, root_build_dir), |
| 289 ] + rebase_path(outputs, root_build_dir) | 544 ] + rebase_path(outputs, root_build_dir) |
| 290 } | 545 } |
| 291 } | 546 } |
| 292 | 547 |
| 293 _link_executable = _target_name + "_arch_executable" | 548 _bundle_data_info_plist = target_name + "_bundle_data_info_plist" |
| 294 _lipo_executable = _target_name + "_executable" | 549 bundle_data(_bundle_data_info_plist) { |
| 550 forward_variables_from(invoker, [ "testonly" ]) |
| 295 | 551 |
| 296 _link_executable_visibility = [ ":$_lipo_executable" ] | 552 sources = get_target_outputs(":$_generate_info_plist") |
| 297 _lipo_executable_visibility = [ ":$_target_name" ] | 553 outputs = [ |
| 554 "{{bundle_root_dir}}/Info.plist", |
| 555 ] |
| 556 public_deps = [ |
| 557 ":$_generate_info_plist", |
| 558 ] |
| 559 } |
| 298 | 560 |
| 299 executable(_link_executable) { | 561 create_signed_bundle(_target_name) { |
| 300 forward_variables_from(invoker, | 562 forward_variables_from(invoker, |
| 301 "*", | |
| 302 [ | 563 [ |
| 303 "bundle_deps", | 564 "bundle_deps", |
| 304 "bundle_deps_filter", | |
| 305 "bundle_extension", | 565 "bundle_extension", |
| 306 "data_deps", | 566 "data_deps", |
| 567 "deps", |
| 568 "enable_code_signing", |
| 307 "entitlements_path", | 569 "entitlements_path", |
| 308 "extra_substitutions", | |
| 309 "extra_system_frameworks", | 570 "extra_system_frameworks", |
| 310 "info_plist", | |
| 311 "info_plist_target", | |
| 312 "output_name", | |
| 313 "product_type", | 571 "product_type", |
| 314 "visibility", | 572 "public_configs", |
| 315 ]) | |
| 316 | |
| 317 visibility = _link_executable_visibility | |
| 318 | |
| 319 output_name = _output_name | |
| 320 output_prefix_override = true | |
| 321 output_dir = "$target_out_dir/$current_cpu" | |
| 322 | |
| 323 if (!defined(deps)) { | |
| 324 deps = [] | |
| 325 } | |
| 326 deps += _executable_extra_deps | |
| 327 | |
| 328 if (!defined(ldflags)) { | |
| 329 ldflags = [] | |
| 330 } | |
| 331 ldflags += _executable_extra_ldflags | |
| 332 | |
| 333 if (!defined(inputs)) { | |
| 334 inputs = [] | |
| 335 } | |
| 336 inputs += _executable_extra_inputs | |
| 337 | |
| 338 if (!defined(libs)) { | |
| 339 libs = [] | |
| 340 } | |
| 341 libs += [ "UIKit.framework" ] | |
| 342 } | |
| 343 | |
| 344 # Create the multi-architecture binary from all the single architecture | |
| 345 # binaries using "lipo". This target exists for the default toolchain | |
| 346 # of a fat-build only and depends on the expansion of "ios_app_bundle" | |
| 347 # for the other toolchains (i.e. a single "executable" target). | |
| 348 # | |
| 349 # This action only happens once per "ios_app_bundle" template (for the | |
| 350 # main toolchain). | |
| 351 action(_lipo_executable) { | |
| 352 forward_variables_from(invoker, [ "testonly" ]) | |
| 353 visibility = _lipo_executable_visibility | |
| 354 script = "//build/toolchain/mac/linker_driver.py" | |
| 355 outputs = [ | |
| 356 "$target_out_dir/$_output_name", | |
| 357 ] | |
| 358 inputs = [ | |
| 359 "$target_out_dir/$current_cpu/$_output_name", | |
| 360 ] | |
| 361 deps = [ | |
| 362 ":$_link_executable", | |
| 363 ] | |
| 364 foreach(_additional_toolchain, additional_toolchains) { | |
| 365 _additional_toolchain_target = "$_target_name($_additional_toolchain)" | |
| 366 deps += [ ":$_additional_toolchain_target" ] | |
| 367 inputs += [ get_label_info(_additional_toolchain_target, | |
| 368 "root_out_dir") + "/$_output_name" ] | |
| 369 } | |
| 370 args = [ | |
| 371 "xcrun", | |
| 372 "lipo", | |
| 373 "-create", | |
| 374 "-output", | |
| 375 rebase_path(outputs[0], root_build_dir), | |
| 376 ] + rebase_path(inputs, root_build_dir) | |
| 377 | |
| 378 if (enable_dsyms) { | |
| 379 _dsyms_dir = "$root_out_dir/$_output_name.dSYM/" | |
| 380 outputs += [ | |
| 381 "$_dsyms_dir/", | |
| 382 "$_dsyms_dir/Contents/Info.plist", | |
| 383 "$_dsyms_dir/Contents/Resources/DWARF/$_output_name", | |
| 384 ] | |
| 385 args += | |
| 386 [ "-Wcrl,dsym," + rebase_path("$root_out_dir/.", root_build_dir) ] | |
| 387 } | |
| 388 | |
| 389 if (enable_stripping) { | |
| 390 # Check whether //build/config/mac:strip_all has been removed from | |
| 391 # the configs variable (as this is how stripping is disabled for a | |
| 392 # single target). | |
| 393 _strip_all_in_config = false | |
| 394 if (defined(invoker.configs)) { | |
| 395 foreach(_config, invoker.configs) { | |
| 396 if (_config == "//build/config/mac:strip_all") { | |
| 397 _strip_all_in_config = true | |
| 398 } | |
| 399 } | |
| 400 } | |
| 401 | |
| 402 if (_strip_all_in_config) { | |
| 403 args += [ "-Wcrl,strip,-x,-S" ] | |
| 404 | |
| 405 if (save_unstripped_output) { | |
| 406 outputs += [ outputs[0] + ".unstripped" ] | |
| 407 args += [ "-Wcrl,unstripped," + | |
| 408 rebase_path(get_path_info(outputs[0], "dir"), | |
| 409 root_build_dir) ] | |
| 410 } | |
| 411 } | |
| 412 } | |
| 413 } | |
| 414 | |
| 415 create_bundle(target_name) { | |
| 416 forward_variables_from(invoker, | |
| 417 [ | |
| 418 "bundle_deps_filter", | |
| 419 "data_deps", | |
| 420 "deps", | |
| 421 "public_deps", | 573 "public_deps", |
| 422 "testonly", | 574 "testonly", |
| 423 "visibility", | 575 "visibility", |
| 424 ]) | 576 ]) |
| 425 | 577 |
| 426 if (!defined(deps)) { | 578 output_name = _output_name |
| 427 deps = [] | 579 bundle_binary_target = ":$_lipo_executable_target" |
| 580 bundle_binary_output = _output_name |
| 581 |
| 582 if (!defined(bundle_deps)) { |
| 583 bundle_deps = [] |
| 428 } | 584 } |
| 429 deps += [ ":$_bundle_data_info_plist" ] | 585 bundle_deps += [ ":$_bundle_data_info_plist" ] |
| 430 if (!defined(public_deps)) { | |
| 431 public_deps = [] | |
| 432 } | |
| 433 public_deps += [ ":$_lipo_executable" ] | |
| 434 if (defined(invoker.bundle_deps)) { | |
| 435 deps += invoker.bundle_deps | |
| 436 } | |
| 437 | 586 |
| 438 if (use_ios_simulator) { | 587 if (use_ios_simulator) { |
| 439 if (!defined(data_deps)) { | 588 if (!defined(data_deps)) { |
| 440 data_deps = [] | 589 data_deps = [] |
| 441 } | 590 } |
| 442 data_deps += [ "//testing/iossim" ] | 591 data_deps += [ "//testing/iossim" ] |
| 443 } | 592 } |
| 444 | 593 |
| 445 if (defined(invoker.product_type)) { | 594 if (!defined(product_type)) { |
| 446 product_type = invoker.product_type | |
| 447 } else { | |
| 448 product_type = "com.apple.product-type.application" | 595 product_type = "com.apple.product-type.application" |
| 449 } | 596 } |
| 450 | 597 |
| 451 if (defined(invoker.bundle_extension)) { | 598 if (!defined(bundle_extension)) { |
| 452 _bundle_extension = invoker.bundle_extension | 599 bundle_extension = ".app" |
| 453 } else { | |
| 454 _bundle_extension = ".app" | |
| 455 } | |
| 456 | |
| 457 bundle_root_dir = "$root_out_dir/$_output_name$_bundle_extension" | |
| 458 bundle_resources_dir = bundle_root_dir | |
| 459 bundle_executable_dir = bundle_root_dir | |
| 460 bundle_plugins_dir = "$bundle_root_dir/PlugIns" | |
| 461 | |
| 462 code_signing_script = _code_signing_script_path | |
| 463 code_signing_sources = [ | |
| 464 _entitlements_path, | |
| 465 "$target_out_dir/$_output_name", | |
| 466 ] | |
| 467 code_signing_outputs = [ "$bundle_root_dir/$_output_name" ] | |
| 468 if (ios_enable_code_signing) { | |
| 469 code_signing_outputs += | |
| 470 [ "$bundle_root_dir/_CodeSignature/CodeResources" ] | |
| 471 } | |
| 472 if (ios_code_signing_identity != "") { | |
| 473 code_signing_outputs += [ "$bundle_root_dir/embedded.mobileprovision" ] | |
| 474 } | |
| 475 if (defined(invoker.extra_system_frameworks)) { | |
| 476 foreach(_framework, invoker.extra_system_frameworks) { | |
| 477 code_signing_outputs += [ "$bundle_root_dir/Frameworks/" + | |
| 478 get_path_info(_framework, "file") ] | |
| 479 } | |
| 480 } | |
| 481 code_signing_args = [ | |
| 482 "code-sign-bundle", | |
| 483 "-t=" + ios_sdk_name, | |
| 484 "-i=" + ios_code_signing_identity, | |
| 485 "-e=" + rebase_path(_entitlements_path, root_build_dir), | |
| 486 "-b=" + rebase_path("$target_out_dir/$_output_name", root_build_dir), | |
| 487 rebase_path(bundle_root_dir, root_build_dir), | |
| 488 ] | |
| 489 if (defined(invoker.extra_system_frameworks)) { | |
| 490 # All framework in extra_system_frameworks are expected to be | |
| 491 # system framework and the path to be already system absolute | |
| 492 # so do not use rebase_path here. | |
| 493 foreach(_framework, invoker.extra_system_frameworks) { | |
| 494 code_signing_args += [ "-F=" + _framework ] | |
| 495 } | |
| 496 } | |
| 497 if (!ios_enable_code_signing) { | |
| 498 code_signing_args += [ "--disable-code-signature" ] | |
| 499 } | 600 } |
| 500 } | 601 } |
| 501 } | 602 } |
| 502 | |
| 503 # TODO(crbug.com/395883): ensure those variables are marked as used to | |
| 504 # avoid errors while running "gn gen". | |
| 505 if (defined(invoker.entitlements_path)) { | |
| 506 assert(invoker.entitlements_path != "", | |
| 507 "mark invoker.entitlements_path as used") | |
| 508 } | |
| 509 if (defined(invoker.bundle_extension)) { | |
| 510 assert(invoker.bundle_extension != "", | |
| 511 "mark invoker.bundle_extension as used") | |
| 512 } | |
| 513 if (defined(invoker.bundle_extension)) { | |
| 514 assert(invoker.bundle_extension != "", | |
| 515 "mark invoker.bundle_extension as used") | |
| 516 } | |
| 517 if (defined(invoker.entitlements_path)) { | |
| 518 assert(invoker.entitlements_path != "", | |
| 519 "mark invoker.entitlements_path as used") | |
| 520 } | |
| 521 if (defined(invoker.extra_substitutions)) { | |
| 522 assert(invoker.extra_substitutions != [], | |
| 523 "mark invoker.extra_substitutions as used") | |
| 524 } | |
| 525 if (defined(invoker.info_plist)) { | |
| 526 assert(invoker.info_plist != "", "mark invoker.info_plist as used") | |
| 527 } | |
| 528 if (defined(invoker.info_plist_target)) { | |
| 529 assert(invoker.info_plist_target != "", | |
| 530 "mark invoker.info_plist_target as used") | |
| 531 } | |
| 532 if (defined(invoker.product_type)) { | |
| 533 assert(invoker.product_type != "", "mark product_type as used") | |
| 534 } | |
| 535 if (defined(invoker.bundle_deps)) { | |
| 536 assert(invoker.bundle_deps != [], "mark bundle_deps as used") | |
| 537 } | |
| 538 if (defined(invoker.bundle_deps_filter)) { | |
| 539 assert(invoker.bundle_deps_filter != [], "mark bundle_deps_filter as used") | |
| 540 } | |
| 541 } | 603 } |
| 542 | 604 |
| 543 set_defaults("ios_app_bundle") { | 605 set_defaults("ios_app_bundle") { |
| 544 configs = default_executable_configs | 606 configs = default_executable_configs |
| 545 } | 607 } |
| 546 | 608 |
| 547 # Template to build an application extension bundle for iOS. | 609 # Template to build an application extension bundle for iOS. |
| 548 # | 610 # |
| 549 # This should be used instead of "executable" built-in target type on iOS. | 611 # This should be used instead of "executable" built-in target type on iOS. |
| 550 # As the template forward the generation of the application executable to | 612 # As the template forward the generation of the application executable to |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 710 # a link-time (as well as build-time) dependency on the framework bundle, | 772 # a link-time (as well as build-time) dependency on the framework bundle, |
| 711 # depend against "$target_name+link". If only the build-time dependency is | 773 # depend against "$target_name+link". If only the build-time dependency is |
| 712 # required (e.g., for copying into another bundle), then use "$target_name". | 774 # required (e.g., for copying into another bundle), then use "$target_name". |
| 713 # | 775 # |
| 714 # Arguments | 776 # Arguments |
| 715 # | 777 # |
| 716 # output_name: | 778 # output_name: |
| 717 # (optional) string, name of the generated framework without the | 779 # (optional) string, name of the generated framework without the |
| 718 # .framework suffix. If omitted, defaults to target_name. | 780 # .framework suffix. If omitted, defaults to target_name. |
| 719 # | 781 # |
| 720 # framework_version: | |
| 721 # (optional) string, version of the framework. Typically this is a | |
| 722 # single letter, like "A". If omitted, the Versions/ subdirectory | |
| 723 # structure will not be created, and build output will go directly | |
| 724 # into the framework subdirectory. | |
| 725 # | |
| 726 # public_headers: | 782 # public_headers: |
| 727 # (optional) list of paths to header file that needs to be copied | 783 # (optional) list of paths to header file that needs to be copied |
| 728 # into the framework bundle Headers subdirectory. If omitted or | 784 # into the framework bundle Headers subdirectory. If omitted or |
| 729 # empty then the Headers subdirectory is not created. | 785 # empty then the Headers subdirectory is not created. |
| 730 # | 786 # |
| 731 # sources | 787 # sources |
| 732 # (optional) list of files. Needs to be defined and non-empty if | 788 # (optional) list of files. Needs to be defined and non-empty if |
| 733 # public_headers is defined and non-empty. | 789 # public_headers is defined and non-empty. |
| 734 # | 790 # |
| 791 # enable_code_signing |
| 792 # (optional) boolean, control whether code signing is enabled or not, |
| 793 # default to ios_enable_code_signing if not defined. |
| 794 # |
| 735 # This template provides two targets for the resulting framework bundle. The | 795 # This template provides two targets for the resulting framework bundle. The |
| 736 # link-time behavior varies depending on which of the two targets below is | 796 # link-time behavior varies depending on which of the two targets below is |
| 737 # added as a dependency: | 797 # added as a dependency: |
| 738 # - $target_name only adds a build-time dependency. Targets that depend on | 798 # - $target_name only adds a build-time dependency. Targets that depend on |
| 739 # it will not link against the framework. | 799 # it will not link against the framework. |
| 740 # - $target_name+link adds a build-time and link-time dependency. Targets | 800 # - $target_name+link adds a build-time and link-time dependency. Targets |
| 741 # that depend on it will link against the framework. | 801 # that depend on it will link against the framework. |
| 742 # | 802 # |
| 743 # The build-time-only dependency is used for when a target needs to use the | 803 # The build-time-only dependency is used for when a target needs to use the |
| 744 # framework either only for resources, or because the target loads it at run- | 804 # framework either only for resources, or because the target loads it at run- |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 807 | 867 |
| 808 _has_public_headers = | 868 _has_public_headers = |
| 809 defined(invoker.public_headers) && invoker.public_headers != [] | 869 defined(invoker.public_headers) && invoker.public_headers != [] |
| 810 | 870 |
| 811 if (_has_public_headers) { | 871 if (_has_public_headers) { |
| 812 _framework_headers_target = _target_name + "_framework_headers" | 872 _framework_headers_target = _target_name + "_framework_headers" |
| 813 _framework_headers_config = _target_name + "_framework_headers_config" | 873 _framework_headers_config = _target_name + "_framework_headers_config" |
| 814 _headers_map_config = _target_name + "_headers_map" | 874 _headers_map_config = _target_name + "_headers_map" |
| 815 } | 875 } |
| 816 | 876 |
| 817 # The expansion of the template is different for fat and thin builds. For | 877 _arch_shared_library_source = _target_name + "_arch_shared_library_sources" |
| 818 # thin build (and default toolchain of a fat build), the template expands | 878 _arch_shared_library_target = _target_name + "_arch_shared_library" |
| 819 # to a "shared_library" target to create the bundle shared library and a | 879 _lipo_shared_library_target = _target_name + "_shared_library" |
| 820 # "create_bundle" target (the main target) to create the bundle structure. | |
| 821 # | |
| 822 # For a fat build, the template just expands to the "shared_library" target | |
| 823 # for the non-default toolchain, while the final library is created using | |
| 824 # "lipo" in the expansion of the template for the default toolchain. | |
| 825 # | |
| 826 # The "$target_name+link" group for the non-default toolchain depends on the | |
| 827 # target of the same name from the default toolchain as this is the target | |
| 828 # that defines the real framework bundle (it will support the current cpu | |
| 829 # as it is a fat framework). | |
| 830 | 880 |
| 831 if (_is_secondary_build) { | 881 if (_use_intermediate_source_set) { |
| 832 shared_library(_target_name) { | 882 source_set(_arch_shared_library_source) { |
| 833 forward_variables_from(invoker, | 883 forward_variables_from(invoker, |
| 834 "*", | 884 "*", |
| 835 [ | 885 [ |
| 836 "assert_no_deps", | |
| 837 "bundle_deps", | 886 "bundle_deps", |
| 887 "bundle_deps_filter", |
| 838 "data_deps", | 888 "data_deps", |
| 839 "enable_code_signing", | 889 "enable_code_signing", |
| 840 "info_plist", | 890 "info_plist", |
| 841 "info_plist_target", | 891 "info_plist_target", |
| 842 "output_name", | 892 "output_name", |
| 893 "visibility", |
| 843 ]) | 894 ]) |
| 844 if (defined(visibility)) { | 895 |
| 845 visibility += [ ":${_target_name}_shared_library($default_toolchain)" ] | 896 visibility = [ ":$_arch_shared_library_target" ] |
| 846 } | |
| 847 output_name = _output_name | |
| 848 output_prefix_override = true | |
| 849 output_extension = "" | |
| 850 output_dir = "$target_out_dir/$_target_name" | |
| 851 | 897 |
| 852 if (_has_public_headers) { | 898 if (_has_public_headers) { |
| 853 configs += [ | 899 configs += [ |
| 854 ":$_framework_headers_config($default_toolchain)", | 900 ":$_framework_headers_config($default_toolchain)", |
| 901 ":$_headers_map_config($default_toolchain)", |
| 902 ] |
| 903 |
| 904 if (!defined(deps)) { |
| 905 deps = [] |
| 906 } |
| 907 deps += [ ":$_framework_headers_target($default_toolchain)" ] |
| 908 } |
| 909 } |
| 910 } else { |
| 911 assert(_arch_shared_library_source != "", |
| 912 "mark _arch_shared_library_source as used") |
| 913 } |
| 914 |
| 915 shared_library(_arch_shared_library_target) { |
| 916 forward_variables_from(invoker, |
| 917 "*", |
| 918 [ |
| 919 "bundle_deps", |
| 920 "bundle_deps_filter", |
| 921 "data_deps", |
| 922 "enable_code_signing", |
| 923 "info_plist", |
| 924 "info_plist_target", |
| 925 "output_name", |
| 926 "sources", |
| 927 "visibility", |
| 928 ]) |
| 929 if (!_use_intermediate_source_set) { |
| 930 forward_variables_from(invoker, [ "sources" ]) |
| 931 } |
| 932 |
| 933 visibility = [ ":$_lipo_shared_library_target($default_toolchain)" ] |
| 934 if (current_toolchain != default_toolchain) { |
| 935 visibility += [ ":$_target_name" ] |
| 936 } |
| 937 |
| 938 if (!defined(deps)) { |
| 939 deps = [] |
| 940 } |
| 941 if (_use_intermediate_source_set) { |
| 942 deps += [ ":$_arch_shared_library_source" ] |
| 943 } else { |
| 944 if (_has_public_headers) { |
| 945 configs += [ |
| 946 ":$_framework_headers_config($default_toolchain)", |
| 855 ":$_headers_map_config($default_toolchain)", | 947 ":$_headers_map_config($default_toolchain)", |
| 856 ] | 948 ] |
| 857 | 949 |
| 858 if (!defined(deps)) { | 950 if (!defined(deps)) { |
| 859 deps = [] | 951 deps = [] |
| 860 } | 952 } |
| 861 deps += [ ":$_framework_headers_target($default_toolchain)" ] | 953 deps += [ ":$_framework_headers_target($default_toolchain)" ] |
| 862 } | 954 } |
| 863 } | 955 } |
| 864 | 956 |
| 957 output_extension = "" |
| 958 output_name = _output_name |
| 959 output_prefix_override = true |
| 960 output_dir = "$target_out_dir/$current_cpu" |
| 961 } |
| 962 |
| 963 if (current_toolchain != default_toolchain) { |
| 964 # For fat builds, only the default toolchain will generate a framework |
| 965 # bundle. For the other toolchains, the template is only used for building |
| 966 # the arch-specific binary, thus the default target is just a group(). |
| 967 |
| 968 group(_target_name) { |
| 969 forward_variables_from(invoker, |
| 970 [ |
| 971 "visibility", |
| 972 "testonly", |
| 973 ]) |
| 974 public_deps = [ |
| 975 ":$_arch_shared_library_target", |
| 976 ] |
| 977 } |
| 978 |
| 865 group(_target_name + "+link") { | 979 group(_target_name + "+link") { |
| 866 forward_variables_from(invoker, | 980 forward_variables_from(invoker, |
| 867 [ | 981 [ |
| 868 "visibility", | 982 "visibility", |
| 869 "testonly", | 983 "testonly", |
| 870 ]) | 984 ]) |
| 871 public_deps = [ | 985 public_deps = [ |
| 872 ":$_target_name+link($default_toolchain)", | 986 ":$_target_name+link($default_toolchain)", |
| 873 ] | 987 ] |
| 874 } | 988 } |
| 875 | 989 |
| 876 if (defined(invoker.bundle_deps)) { | 990 if (defined(invoker.bundle_deps)) { |
| 877 assert(invoker.bundle_deps != [], "mark bundle_deps as used") | 991 assert(invoker.bundle_deps != [], "mark bundle_deps as used") |
| 878 } | 992 } |
| 879 } else { | 993 } else { |
| 880 if (_has_public_headers) { | 994 if (_has_public_headers) { |
| 881 _public_headers = invoker.public_headers | 995 _public_headers = invoker.public_headers |
| 882 _framework_name = _output_name + ".framework" | 996 _framework_root = "$root_out_dir/$_output_name.framework" |
| 883 _framework_root = "$root_out_dir/$_framework_name" | |
| 884 | 997 |
| 885 _header_map_filename = "$target_gen_dir/$_output_name.headers.hmap" | 998 _header_map_filename = "$target_gen_dir/$_output_name.headers.hmap" |
| 886 | 999 |
| 887 _compile_headers_map_target = _target_name + "_compile_headers_map" | 1000 _compile_headers_map_target = _target_name + "_compile_headers_map" |
| 888 action(_compile_headers_map_target) { | 1001 action(_compile_headers_map_target) { |
| 889 visibility = [ ":$_framework_headers_target" ] | 1002 visibility = [ ":$_framework_headers_target" ] |
| 890 script = "//build/config/ios/write_framework_hmap.py" | 1003 script = "//build/config/ios/write_framework_hmap.py" |
| 891 outputs = [ | 1004 outputs = [ |
| 892 _header_map_filename, | 1005 _header_map_filename, |
| 893 ] | 1006 ] |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 929 outputs = [ | 1042 outputs = [ |
| 930 "$_framework_root/Headers/{{source_file_part}}", | 1043 "$_framework_root/Headers/{{source_file_part}}", |
| 931 ] | 1044 ] |
| 932 } | 1045 } |
| 933 | 1046 |
| 934 config(_headers_map_config) { | 1047 config(_headers_map_config) { |
| 935 visibility = [ ":$_target_name" ] | 1048 visibility = [ ":$_target_name" ] |
| 936 include_dirs = [ _header_map_filename ] | 1049 include_dirs = [ _header_map_filename ] |
| 937 ldflags = [ | 1050 ldflags = [ |
| 938 "-install_name", | 1051 "-install_name", |
| 939 "@rpath/$_framework_name/$_output_name", | 1052 "@rpath/$_output_name.framework/$_output_name", |
| 940 ] | 1053 ] |
| 941 } | 1054 } |
| 942 | 1055 |
| 943 group(_framework_headers_target) { | 1056 group(_framework_headers_target) { |
| 944 deps = [ | 1057 deps = [ |
| 945 ":$_compile_headers_map_target", | 1058 ":$_compile_headers_map_target", |
| 946 ":$_copy_public_headers_target", | 1059 ":$_copy_public_headers_target", |
| 947 ":$_create_module_map_target", | 1060 ":$_create_module_map_target", |
| 948 ] | 1061 ] |
| 949 } | 1062 } |
| 950 | 1063 |
| 951 config(_framework_headers_config) { | 1064 config(_framework_headers_config) { |
| 952 # The link settings are inherited from the framework_bundle config. | 1065 # The link settings are inherited from the framework_bundle config. |
| 953 cflags = [ | 1066 cflags = [ |
| 954 "-F", | 1067 "-F", |
| 955 rebase_path("$root_out_dir/.", root_build_dir), | 1068 rebase_path("$root_out_dir/.", root_build_dir), |
| 956 ] | 1069 ] |
| 957 } | 1070 } |
| 958 } | 1071 } |
| 959 | 1072 |
| 960 # If the framework is unversioned, the final _target_name will be the | 1073 lipo_binary(_lipo_shared_library_target) { |
| 961 # create_bundle(_framework_target), otherwise an action with the name | 1074 forward_variables_from(invoker, |
| 962 # _target_name will depends on the the create_bundle() in order to prepare | 1075 [ |
| 963 # the versioned directory structure. | 1076 "configs", |
| 964 _framework_target = _target_name | 1077 "testonly", |
| 965 _framework_name = _output_name + ".framework" | 1078 ]) |
| 966 _framework_root_dir = "$root_out_dir/$_framework_name" | |
| 967 if (defined(invoker.framework_version) && invoker.framework_version != "") { | |
| 968 _framework_version = invoker.framework_version | |
| 969 _framework_root_dir += "/Versions/$_framework_version" | |
| 970 _framework_target = _target_name + "_create_bundle" | |
| 971 } | |
| 972 | 1079 |
| 973 _link_shared_library_target = target_name + "_arch_shared_library" | 1080 visibility = [ ":$_target_name" ] |
| 974 _lipo_shared_library_target = target_name + "_shared_library" | |
| 975 | |
| 976 _lipo_shared_library_visibility = [ ":$_framework_target" ] | |
| 977 _link_shared_library_visibility = [ ":$_lipo_shared_library_target" ] | |
| 978 | |
| 979 _arch_shared_library_dir = "$target_out_dir/$_link_shared_library_target" | |
| 980 _shared_library_dir = "$target_out_dir/$_lipo_shared_library_target" | |
| 981 | |
| 982 shared_library(_link_shared_library_target) { | |
| 983 forward_variables_from(invoker, | |
| 984 "*", | |
| 985 [ | |
| 986 "assert_no_deps", | |
| 987 "bundle_deps", | |
| 988 "data_deps", | |
| 989 "enable_code_signing", | |
| 990 "info_plist", | |
| 991 "info_plist_target", | |
| 992 "output_name", | |
| 993 "visibility", | |
| 994 ]) | |
| 995 visibility = _link_shared_library_visibility | |
| 996 output_name = _output_name | 1081 output_name = _output_name |
| 997 output_prefix_override = true | 1082 arch_binary_target = ":$_arch_shared_library_target" |
| 998 output_extension = "" | 1083 arch_binary_output = _output_name |
| 999 output_dir = _arch_shared_library_dir | |
| 1000 | |
| 1001 if (_has_public_headers) { | |
| 1002 configs += [ ":$_headers_map_config($default_toolchain)" ] | |
| 1003 | |
| 1004 if (!defined(deps)) { | |
| 1005 deps = [] | |
| 1006 } | |
| 1007 deps += [ ":$_framework_headers_target($default_toolchain)" ] | |
| 1008 } | |
| 1009 } | |
| 1010 | |
| 1011 action(_lipo_shared_library_target) { | |
| 1012 forward_variables_from(invoker, [ "testonly" ]) | |
| 1013 visibility = _lipo_shared_library_visibility | |
| 1014 script = "//build/toolchain/mac/linker_driver.py" | |
| 1015 outputs = [ | |
| 1016 "$_shared_library_dir/$_output_name", | |
| 1017 ] | |
| 1018 inputs = [ | |
| 1019 "$_arch_shared_library_dir/$_output_name", | |
| 1020 ] | |
| 1021 deps = [ | |
| 1022 ":$_link_shared_library_target", | |
| 1023 ] | |
| 1024 foreach(_additional_toolchain, additional_toolchains) { | |
| 1025 _additional_toolchain_target = "$_target_name($_additional_toolchain)" | |
| 1026 deps += [ ":$_additional_toolchain_target" ] | |
| 1027 inputs += [ get_label_info(_additional_toolchain_target, | |
| 1028 "target_out_dir") + "/$_output_name" ] | |
| 1029 } | |
| 1030 args = [ | |
| 1031 "xcrun", | |
| 1032 "lipo", | |
| 1033 "-create", | |
| 1034 "-output", | |
| 1035 rebase_path(outputs[0], root_build_dir), | |
| 1036 ] + rebase_path(inputs, root_build_dir) | |
| 1037 | |
| 1038 if (enable_dsyms) { | |
| 1039 _dsyms_dir = "$root_out_dir/$_output_name.dSYM/" | |
| 1040 outputs += [ | |
| 1041 "$_dsyms_dir/", | |
| 1042 "$_dsyms_dir/Contents/Info.plist", | |
| 1043 "$_dsyms_dir/Contents/Resources/DWARF/$_output_name", | |
| 1044 ] | |
| 1045 args += | |
| 1046 [ "-Wcrl,dsym," + rebase_path("$root_out_dir/.", root_build_dir) ] | |
| 1047 } | |
| 1048 | |
| 1049 if (enable_stripping) { | |
| 1050 # Check whether //build/config/mac:strip_all has been removed from | |
| 1051 # the configs variable (as this is how stripping is disabled for a | |
| 1052 # single target). | |
| 1053 _strip_all_in_config = false | |
| 1054 if (defined(invoker.configs)) { | |
| 1055 foreach(_config, invoker.configs) { | |
| 1056 if (_config == "//build/config/mac:strip_all") { | |
| 1057 _strip_all_in_config = true | |
| 1058 } | |
| 1059 } | |
| 1060 } | |
| 1061 | |
| 1062 if (_strip_all_in_config) { | |
| 1063 args += [ "-Wcrl,strip,-x,-S" ] | |
| 1064 | |
| 1065 if (save_unstripped_output) { | |
| 1066 outputs += [ outputs[0] + ".unstripped" ] | |
| 1067 args += [ "-Wcrl,unstripped," + | |
| 1068 rebase_path(get_path_info(outputs[0], "dir"), | |
| 1069 root_build_dir) ] | |
| 1070 } | |
| 1071 } | |
| 1072 } | |
| 1073 } | 1084 } |
| 1074 | 1085 |
| 1075 _framework_public_config = _target_name + "_public_config" | 1086 _framework_public_config = _target_name + "_public_config" |
| 1076 config(_framework_public_config) { | 1087 config(_framework_public_config) { |
| 1077 # TODO(sdefresne): should we have a framework_dirs similar to lib_dirs | 1088 # TODO(sdefresne): should we have a framework_dirs similar to lib_dirs |
| 1078 # and include_dirs to avoid duplicate values on the command-line. | 1089 # and include_dirs to avoid duplicate values on the command-line. |
| 1079 visibility = [ ":$_framework_target" ] | 1090 visibility = [ ":$_target_name" ] |
| 1080 ldflags = [ | 1091 ldflags = [ |
| 1081 "-F", | 1092 "-F", |
| 1082 rebase_path("$root_out_dir/.", root_build_dir), | 1093 rebase_path("$root_out_dir/.", root_build_dir), |
| 1083 ] | 1094 ] |
| 1084 lib_dirs = [ root_out_dir ] | 1095 lib_dirs = [ root_out_dir ] |
| 1085 libs = [ _framework_name ] | 1096 libs = [ "$_output_name.framework" ] |
| 1086 } | 1097 } |
| 1087 | 1098 |
| 1088 _info_plist_target = _target_name + "_info_plist" | 1099 _info_plist_target = _target_name + "_info_plist" |
| 1089 _info_plist_bundle = _target_name + "_info_plist_bundle" | 1100 _info_plist_bundle = _target_name + "_info_plist_bundle" |
| 1090 ios_info_plist(_info_plist_target) { | 1101 ios_info_plist(_info_plist_target) { |
| 1091 visibility = [ ":$_info_plist_bundle" ] | 1102 visibility = [ ":$_info_plist_bundle" ] |
| 1092 executable_name = _output_name | 1103 executable_name = _output_name |
| 1093 forward_variables_from(invoker, | 1104 forward_variables_from(invoker, |
| 1094 [ | 1105 [ |
| 1095 "extra_substitutions", | 1106 "extra_substitutions", |
| 1096 "info_plist", | 1107 "info_plist", |
| 1097 "info_plist_target", | 1108 "info_plist_target", |
| 1098 ]) | 1109 ]) |
| 1099 } | 1110 } |
| 1100 | 1111 |
| 1101 bundle_data(_info_plist_bundle) { | 1112 bundle_data(_info_plist_bundle) { |
| 1102 visibility = [ ":$_target_name" ] | 1113 visibility = [ ":$_target_name" ] |
| 1103 forward_variables_from(invoker, [ "testonly" ]) | 1114 forward_variables_from(invoker, [ "testonly" ]) |
| 1104 sources = get_target_outputs(":$_info_plist_target") | 1115 sources = get_target_outputs(":$_info_plist_target") |
| 1105 outputs = [ | 1116 outputs = [ |
| 1106 "{{bundle_root_dir}}/Info.plist", | 1117 "{{bundle_root_dir}}/Info.plist", |
| 1107 ] | 1118 ] |
| 1108 public_deps = [ | 1119 public_deps = [ |
| 1109 ":$_info_plist_target", | 1120 ":$_info_plist_target", |
| 1110 ] | 1121 ] |
| 1111 } | 1122 } |
| 1112 | 1123 |
| 1113 create_bundle(_framework_target) { | 1124 create_signed_bundle(_target_name) { |
| 1114 forward_variables_from(invoker, | 1125 forward_variables_from(invoker, |
| 1115 [ | 1126 [ |
| 1127 "bundle_deps", |
| 1116 "data_deps", | 1128 "data_deps", |
| 1117 "deps", | 1129 "deps", |
| 1130 "enable_code_signing", |
| 1118 "public_configs", | 1131 "public_configs", |
| 1119 "public_deps", | 1132 "public_deps", |
| 1120 "testonly", | 1133 "testonly", |
| 1134 "visibility", |
| 1121 ]) | 1135 ]) |
| 1122 | 1136 |
| 1123 if (defined(_framework_version)) { | 1137 product_type = "com.apple.product-type.framework" |
| 1124 visibility = [ ":$_target_name" ] | 1138 bundle_extension = ".framework" |
| 1125 } else { | 1139 |
| 1126 if (defined(invoker.visibility)) { | 1140 output_name = _output_name |
| 1127 visibility = invoker.visibility | 1141 bundle_binary_target = ":$_lipo_shared_library_target" |
| 1128 visibility += [ ":$_target_name+link" ] | 1142 bundle_binary_output = _output_name |
| 1129 } | |
| 1130 } | |
| 1131 | 1143 |
| 1132 if (!defined(deps)) { | 1144 if (!defined(deps)) { |
| 1133 deps = [] | 1145 deps = [] |
| 1134 } | 1146 } |
| 1135 deps += [ ":$_info_plist_bundle" ] | 1147 deps += [ ":$_info_plist_bundle" ] |
| 1136 | |
| 1137 if (defined(invoker.bundle_deps)) { | |
| 1138 if (!defined(deps)) { | |
| 1139 deps = [] | |
| 1140 } | |
| 1141 deps += invoker.bundle_deps | |
| 1142 } | |
| 1143 | |
| 1144 bundle_root_dir = _framework_root_dir | |
| 1145 bundle_resources_dir = _framework_root_dir | |
| 1146 bundle_executable_dir = _framework_root_dir | |
| 1147 | |
| 1148 if (!defined(deps)) { | |
| 1149 deps = [] | |
| 1150 } | |
| 1151 deps += [ ":$_lipo_shared_library_target" ] | |
| 1152 | |
| 1153 _entitlements_path = _default_entitlements_path | |
| 1154 if (defined(invoker.entitlements_path)) { | |
| 1155 _entitlements_path = invoker.entitlements_path | |
| 1156 } | |
| 1157 | |
| 1158 _ios_enable_code_signing = ios_enable_code_signing | |
| 1159 if (defined(invoker.enable_code_signing)) { | |
| 1160 _ios_enable_code_signing = invoker.enable_code_signing | |
| 1161 } | |
| 1162 | |
| 1163 code_signing_script = _code_signing_script_path | |
| 1164 code_signing_sources = [ | |
| 1165 _entitlements_path, | |
| 1166 "$_shared_library_dir/$_output_name", | |
| 1167 ] | |
| 1168 code_signing_outputs = [ "$bundle_root_dir/$_output_name" ] | |
| 1169 if (_ios_enable_code_signing) { | |
| 1170 code_signing_outputs += | |
| 1171 [ "$bundle_root_dir/_CodeSignature/CodeResources" ] | |
| 1172 } | |
| 1173 if (ios_code_signing_identity != "") { | |
| 1174 code_signing_outputs += [ "$bundle_root_dir/embedded.mobileprovision" ] | |
| 1175 } | |
| 1176 code_signing_args = [ | |
| 1177 "code-sign-bundle", | |
| 1178 "-t=" + ios_sdk_name, | |
| 1179 "-i=" + ios_code_signing_identity, | |
| 1180 "-e=" + rebase_path(_entitlements_path, root_build_dir), | |
| 1181 "-b=" + | |
| 1182 rebase_path("$_shared_library_dir/$_output_name", root_build_dir), | |
| 1183 rebase_path(bundle_root_dir, root_build_dir), | |
| 1184 ] | |
| 1185 if (!_ios_enable_code_signing) { | |
| 1186 code_signing_args += [ "--disable-code-signature" ] | |
| 1187 } | |
| 1188 } | |
| 1189 | |
| 1190 if (defined(_framework_version)) { | |
| 1191 action(_target_name) { | |
| 1192 forward_variables_from(invoker, [ "testonly" ]) | |
| 1193 | |
| 1194 if (defined(invoker.visibility)) { | |
| 1195 visibility = invoker.visibility | |
| 1196 visibility += [ ":$_target_name+link" ] | |
| 1197 } | |
| 1198 | |
| 1199 script = "//build/config/mac/package_framework.py" | |
| 1200 outputs = [ | |
| 1201 "$root_out_dir/$_framework_name/Versions/Current", | |
| 1202 ] | |
| 1203 args = [ | |
| 1204 "$_framework_name", | |
| 1205 "$_framework_version", | |
| 1206 ] | |
| 1207 public_deps = [ | |
| 1208 ":$_framework_target", | |
| 1209 ] | |
| 1210 } | |
| 1211 } | 1148 } |
| 1212 | 1149 |
| 1213 group(_target_name + "+link") { | 1150 group(_target_name + "+link") { |
| 1214 forward_variables_from(invoker, | 1151 forward_variables_from(invoker, |
| 1215 [ | 1152 [ |
| 1216 "public_deps", | 1153 "public_deps", |
| 1217 "public_configs", | 1154 "public_configs", |
| 1218 "testonly", | 1155 "testonly", |
| 1219 "visibility", | 1156 "visibility", |
| 1220 ]) | 1157 ]) |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1265 if (defined(invoker.output_name)) { | 1202 if (defined(invoker.output_name)) { |
| 1266 _output_name = invoker.output_name | 1203 _output_name = invoker.output_name |
| 1267 } | 1204 } |
| 1268 | 1205 |
| 1269 _xctest_target = _target_name | 1206 _xctest_target = _target_name |
| 1270 _xctest_output = _output_name | 1207 _xctest_output = _output_name |
| 1271 | 1208 |
| 1272 _host_target = _target_name + "_host" | 1209 _host_target = _target_name + "_host" |
| 1273 _host_output = _output_name + "_host" | 1210 _host_output = _output_name + "_host" |
| 1274 | 1211 |
| 1275 if (_is_secondary_build) { | 1212 _xctest_arch_loadable_module_target = _xctest_target + "_arch_loadable_module" |
| 1276 loadable_module(_xctest_target) { | 1213 _xctest_lipo_loadable_module_target = _xctest_target + "_loadable_module" |
| 1277 visibility = [ ":${_xctest_target}_loadable_module($default_toolchain)" ] | 1214 |
| 1278 sources = [ | 1215 loadable_module(_xctest_arch_loadable_module_target) { |
| 1279 "//build/config/ios/xctest_shell.mm", | 1216 visibility = [ ":$_xctest_lipo_loadable_module_target($default_toolchain)" ] |
| 1217 if (current_toolchain != default_toolchain) { |
| 1218 visibility += [ ":$_target_name" ] |
| 1219 } |
| 1220 |
| 1221 sources = [ |
| 1222 "//build/config/ios/xctest_shell.mm", |
| 1223 ] |
| 1224 configs += [ "//build/config/ios:xctest_config" ] |
| 1225 |
| 1226 output_dir = "$target_out_dir/$current_cpu" |
| 1227 output_name = _xctest_output |
| 1228 output_prefix_override = true |
| 1229 output_extension = "" |
| 1230 } |
| 1231 |
| 1232 if (current_toolchain != default_toolchain) { |
| 1233 # For fat builds, only the default toolchain will generate a test bundle. |
| 1234 # For the other toolchains, the template is only used for building the |
| 1235 # arch-specific binary, thus the default target is just a group(). |
| 1236 group(_target_name) { |
| 1237 forward_variables_from(invoker, |
| 1238 [ |
| 1239 "visibility", |
| 1240 "testonly", |
| 1241 ]) |
| 1242 public_deps = [ |
| 1243 ":$_xctest_arch_loadable_module_target", |
| 1280 ] | 1244 ] |
| 1281 configs += [ "//build/config/ios:xctest_config" ] | |
| 1282 | |
| 1283 output_name = _xctest_output | |
| 1284 output_extension = "" | |
| 1285 } | 1245 } |
| 1286 } else { | 1246 } else { |
| 1287 _xctest_info_plist_target = _xctest_target + "_info_plist" | 1247 _xctest_info_plist_target = _xctest_target + "_info_plist" |
| 1288 _xctest_info_plist_bundle = _xctest_target + "_info_plist_bundle" | 1248 _xctest_info_plist_bundle = _xctest_target + "_info_plist_bundle" |
| 1289 ios_info_plist(_xctest_info_plist_target) { | 1249 ios_info_plist(_xctest_info_plist_target) { |
| 1290 visibility = [ ":$_xctest_info_plist_bundle" ] | 1250 visibility = [ ":$_xctest_info_plist_bundle" ] |
| 1291 info_plist = "//build/config/ios/Module-Info.plist" | 1251 info_plist = "//build/config/ios/Module-Info.plist" |
| 1292 executable_name = _output_name | 1252 executable_name = _output_name |
| 1293 } | 1253 } |
| 1294 | 1254 |
| 1295 bundle_data(_xctest_info_plist_bundle) { | 1255 bundle_data(_xctest_info_plist_bundle) { |
| 1296 visibility = [ ":$_xctest_target" ] | 1256 visibility = [ ":$_xctest_target" ] |
| 1297 public_deps = [ | 1257 public_deps = [ |
| 1298 ":$_xctest_info_plist_target", | 1258 ":$_xctest_info_plist_target", |
| 1299 ] | 1259 ] |
| 1300 sources = get_target_outputs(":$_xctest_info_plist_target") | 1260 sources = get_target_outputs(":$_xctest_info_plist_target") |
| 1301 outputs = [ | 1261 outputs = [ |
| 1302 "{{bundle_root_dir}}/Info.plist", | 1262 "{{bundle_root_dir}}/Info.plist", |
| 1303 ] | 1263 ] |
| 1304 } | 1264 } |
| 1305 | 1265 |
| 1306 _xctest_loadable_module_target = _xctest_target + "_arch_loadable_module" | 1266 lipo_binary(_xctest_lipo_loadable_module_target) { |
| 1307 _xctest_lipo_loadable_module_target = _xctest_target + "_loadable_module" | 1267 forward_variables_from(invoker, |
| 1268 [ |
| 1269 "configs", |
| 1270 "testonly", |
| 1271 ]) |
| 1308 | 1272 |
| 1309 _xctest_loadable_module_visibility = | 1273 visibility = [ ":$_xctest_target" ] |
| 1310 [ ":$_xctest_lipo_loadable_module_target" ] | |
| 1311 _xctest_lipo_loadable_module_visibility = [ ":$_xctest_target" ] | |
| 1312 | |
| 1313 loadable_module(_xctest_loadable_module_target) { | |
| 1314 visibility = _xctest_loadable_module_visibility | |
| 1315 sources = [ | |
| 1316 "//build/config/ios/xctest_shell.mm", | |
| 1317 ] | |
| 1318 configs += [ "//build/config/ios:xctest_config" ] | |
| 1319 | |
| 1320 output_dir = "$target_out_dir/$current_cpu" | |
| 1321 output_name = _xctest_output | 1274 output_name = _xctest_output |
| 1322 output_prefix_override = true | 1275 arch_binary_target = ":$_xctest_arch_loadable_module_target" |
| 1323 output_extension = "" | 1276 arch_binary_output = _xctest_output |
| 1324 } | |
| 1325 | |
| 1326 action(_xctest_lipo_loadable_module_target) { | |
| 1327 visibility = _xctest_lipo_loadable_module_visibility | |
| 1328 script = "//build/toolchain/mac/linker_driver.py" | |
| 1329 outputs = [ | |
| 1330 "$target_out_dir/$_xctest_output", | |
| 1331 ] | |
| 1332 inputs = [ | |
| 1333 "$target_out_dir/$current_cpu/$_xctest_output", | |
| 1334 ] | |
| 1335 deps = [ | |
| 1336 ":$_xctest_loadable_module_target", | |
| 1337 ] | |
| 1338 foreach(_additional_toolchain, additional_toolchains) { | |
| 1339 _additional_toolchain_target = "$_target_name($_additional_toolchain)" | |
| 1340 deps += [ ":$_additional_toolchain_target" ] | |
| 1341 inputs += [ get_label_info(_additional_toolchain_target, | |
| 1342 "root_out_dir") + "/$_xctest_output" ] | |
| 1343 } | |
| 1344 args = [ | |
| 1345 "xcrun", | |
| 1346 "lipo", | |
| 1347 "-create", | |
| 1348 "-output", | |
| 1349 rebase_path(outputs[0], root_build_dir), | |
| 1350 ] + rebase_path(inputs, root_build_dir) | |
| 1351 | |
| 1352 if (enable_dsyms) { | |
| 1353 _dsyms_dir = "$root_out_dir/$_output_name.dSYM/" | |
| 1354 outputs += [ | |
| 1355 "$_dsyms_dir/", | |
| 1356 "$_dsyms_dir/Contents/Info.plist", | |
| 1357 "$_dsyms_dir/Contents/Resources/DWARF/$_output_name", | |
| 1358 ] | |
| 1359 args += | |
| 1360 [ "-Wcrl,dsym," + rebase_path("$root_out_dir/.", root_build_dir) ] | |
| 1361 } | |
| 1362 | |
| 1363 if (enable_stripping) { | |
| 1364 # Check whether //build/config/mac:strip_all has been removed from | |
| 1365 # the configs variable (as this is how stripping is disabled for a | |
| 1366 # single target). | |
| 1367 _strip_all_in_config = false | |
| 1368 if (defined(invoker.configs)) { | |
| 1369 foreach(_config, invoker.configs) { | |
| 1370 if (_config == "//build/config/mac:strip_all") { | |
| 1371 _strip_all_in_config = true | |
| 1372 } | |
| 1373 } | |
| 1374 } | |
| 1375 | |
| 1376 if (_strip_all_in_config) { | |
| 1377 args += [ "-Wcrl,strip,-x,-S" ] | |
| 1378 | |
| 1379 if (save_unstripped_output) { | |
| 1380 outputs += [ outputs[0] + ".unstripped" ] | |
| 1381 args += [ "-Wcrl,unstripped," + | |
| 1382 rebase_path(get_path_info(outputs[0], "dir"), | |
| 1383 root_build_dir) ] | |
| 1384 } | |
| 1385 } | |
| 1386 } | |
| 1387 } | 1277 } |
| 1388 | 1278 |
| 1389 _xctest_bundle = _xctest_target + "_bundle" | 1279 _xctest_bundle = _xctest_target + "_bundle" |
| 1280 create_signed_bundle(_xctest_target) { |
| 1281 forward_variables_from(invoker, [ "enable_code_signing" ]) |
| 1282 visibility = [ ":$_xctest_bundle" ] |
| 1390 | 1283 |
| 1391 create_bundle(_xctest_target) { | |
| 1392 visibility = [ ":$_xctest_bundle" ] | |
| 1393 product_type = "com.apple.product-type.bundle.unit-test" | 1284 product_type = "com.apple.product-type.bundle.unit-test" |
| 1285 bundle_extension = ".xctest" |
| 1286 |
| 1287 output_name = _xctest_output |
| 1288 bundle_binary_target = ":$_xctest_lipo_loadable_module_target" |
| 1289 bundle_binary_output = _xctest_output |
| 1290 |
| 1394 deps = [ | 1291 deps = [ |
| 1395 ":$_xctest_info_plist_bundle", | 1292 ":$_xctest_info_plist_bundle", |
| 1396 ":$_xctest_lipo_loadable_module_target", | |
| 1397 ] | 1293 ] |
| 1398 bundle_root_dir = "$root_out_dir/$_xctest_output.xctest" | |
| 1399 | |
| 1400 _entitlements_path = _default_entitlements_path | |
| 1401 if (defined(invoker.entitlements_path)) { | |
| 1402 _entitlements_path = invoker.entitlements_path | |
| 1403 } | |
| 1404 | |
| 1405 code_signing_script = _code_signing_script_path | |
| 1406 code_signing_sources = [ | |
| 1407 _entitlements_path, | |
| 1408 "$target_out_dir/$_xctest_output", | |
| 1409 ] | |
| 1410 code_signing_outputs = [ "$bundle_root_dir/$_xctest_output" ] | |
| 1411 if (ios_enable_code_signing) { | |
| 1412 code_signing_outputs += | |
| 1413 [ "$bundle_root_dir/_CodeSignature/CodeResources" ] | |
| 1414 } | |
| 1415 if (ios_code_signing_identity != "") { | |
| 1416 code_signing_outputs += [ "$bundle_root_dir/embedded.mobileprovision" ] | |
| 1417 } | |
| 1418 code_signing_args = [ | |
| 1419 "code-sign-bundle", | |
| 1420 "-t=" + ios_sdk_name, | |
| 1421 "-i=" + ios_code_signing_identity, | |
| 1422 "-e=" + rebase_path(_entitlements_path, root_build_dir), | |
| 1423 "-b=" + rebase_path("$target_out_dir/$_xctest_output", root_build_dir), | |
| 1424 rebase_path(bundle_root_dir, root_build_dir), | |
| 1425 ] | |
| 1426 if (!ios_enable_code_signing) { | |
| 1427 code_signing_args += [ "--disable-code-signature" ] | |
| 1428 } | |
| 1429 } | 1294 } |
| 1430 | 1295 |
| 1431 bundle_data(_xctest_bundle) { | 1296 bundle_data(_xctest_bundle) { |
| 1432 visibility = [ ":$_host_target" ] | 1297 visibility = [ ":$_host_target" ] |
| 1433 public_deps = [ | 1298 public_deps = [ |
| 1434 ":$_xctest_target", | 1299 ":$_xctest_target", |
| 1435 ] | 1300 ] |
| 1436 sources = [ | 1301 sources = [ |
| 1437 "$root_out_dir/$_xctest_output.xctest", | 1302 "$root_out_dir/$_xctest_output.xctest", |
| 1438 ] | 1303 ] |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1454 } | 1319 } |
| 1455 | 1320 |
| 1456 # Xcode needs those two framework installed in the application (and signed) | 1321 # Xcode needs those two framework installed in the application (and signed) |
| 1457 # for the XCTest to run, so install them using extra_system_frameworks. | 1322 # for the XCTest to run, so install them using extra_system_frameworks. |
| 1458 _ios_platform_library = "$ios_sdk_platform_path/Developer/Library" | 1323 _ios_platform_library = "$ios_sdk_platform_path/Developer/Library" |
| 1459 extra_system_frameworks = [ | 1324 extra_system_frameworks = [ |
| 1460 "$_ios_platform_library/Frameworks/XCTest.framework", | 1325 "$_ios_platform_library/Frameworks/XCTest.framework", |
| 1461 "$_ios_platform_library/PrivateFrameworks/IDEBundleInjection.framework", | 1326 "$_ios_platform_library/PrivateFrameworks/IDEBundleInjection.framework", |
| 1462 ] | 1327 ] |
| 1463 | 1328 |
| 1464 if (!_is_secondary_build) { | 1329 if (current_toolchain == default_toolchain) { |
| 1465 if (!defined(bundle_deps)) { | 1330 if (!defined(bundle_deps)) { |
| 1466 bundle_deps = [] | 1331 bundle_deps = [] |
| 1467 } | 1332 } |
| 1468 bundle_deps += [ ":$_xctest_bundle" ] | 1333 bundle_deps += [ ":$_xctest_bundle" ] |
| 1469 } | 1334 } |
| 1470 | 1335 |
| 1471 if (!defined(ldflags)) { | 1336 if (!defined(ldflags)) { |
| 1472 ldflags = [] | 1337 ldflags = [] |
| 1473 } | 1338 } |
| 1474 ldflags += [ | 1339 ldflags += [ |
| 1475 "-Xlinker", | 1340 "-Xlinker", |
| 1476 "-rpath", | 1341 "-rpath", |
| 1477 "-Xlinker", | 1342 "-Xlinker", |
| 1478 "@executable_path/Frameworks", | 1343 "@executable_path/Frameworks", |
| 1479 "-Xlinker", | 1344 "-Xlinker", |
| 1480 "-rpath", | 1345 "-rpath", |
| 1481 "-Xlinker", | 1346 "-Xlinker", |
| 1482 "@loader_path/Frameworks", | 1347 "@loader_path/Frameworks", |
| 1483 ] | 1348 ] |
| 1484 } | 1349 } |
| 1485 } | 1350 } |
| 1486 | 1351 |
| 1487 set_defaults("ios_xctest_test") { | 1352 set_defaults("ios_xctest_test") { |
| 1488 configs = default_executable_configs | 1353 configs = default_executable_configs |
| 1489 } | 1354 } |
| OLD | NEW |