| OLD | NEW |
| 1 # Copyright 2016 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. | 5 # This file contains rules that are shared between Mac and iOS. |
| 6 | 6 |
| 7 import("//build/toolchain/toolchain.gni") | 7 import("//build/toolchain/toolchain.gni") |
| 8 import("//build/config/mac/symbols.gni") | 8 import("//build/config/mac/symbols.gni") |
| 9 | 9 |
| 10 if (is_mac) { | 10 if (is_mac) { |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 # that defines the real framework bundle (it will support the current cpu | 238 # that defines the real framework bundle (it will support the current cpu |
| 239 # as it is a fat framework). | 239 # as it is a fat framework). |
| 240 | 240 |
| 241 if (_is_fat_build && !_is_fat_build_main_target) { | 241 if (_is_fat_build && !_is_fat_build_main_target) { |
| 242 shared_library(_target_name) { | 242 shared_library(_target_name) { |
| 243 forward_variables_from(invoker, | 243 forward_variables_from(invoker, |
| 244 "*", | 244 "*", |
| 245 [ | 245 [ |
| 246 "assert_no_deps", | 246 "assert_no_deps", |
| 247 "bundle_deps", | 247 "bundle_deps", |
| 248 "code_signing_enabled", |
| 248 "data_deps", | 249 "data_deps", |
| 249 "info_plist", | 250 "info_plist", |
| 250 "info_plist_target", | 251 "info_plist_target", |
| 251 "output_name", | 252 "output_name", |
| 252 ]) | 253 ]) |
| 253 if (defined(visibility)) { | 254 if (defined(visibility)) { |
| 254 visibility += [ ":${_target_name}_shared_library($default_toolchain)" ] | 255 visibility += [ ":${_target_name}_shared_library($default_toolchain)" ] |
| 255 } | 256 } |
| 256 output_name = _output_name | 257 output_name = _output_name |
| 257 output_prefix_override = true | 258 output_prefix_override = true |
| 258 output_extension = "" | 259 output_extension = "" |
| 259 output_dir = "$target_out_dir/$_target_name" | 260 output_dir = "$target_out_dir/$_target_name" |
| 260 } | 261 } |
| 261 | 262 |
| 262 group(_target_name + "+link") { | 263 group(_target_name + "+link") { |
| 263 forward_variables_from(invoker, | 264 forward_variables_from(invoker, |
| 264 [ | 265 [ |
| 265 "visibility", | 266 "visibility", |
| 266 "testonly", | 267 "testonly", |
| 267 ]) | 268 ]) |
| 268 public_deps = [ | 269 public_deps = [ |
| 269 ":$_target_name($default_toolchain)", | 270 ":$_target_name($default_toolchain)", |
| 270 ] | 271 ] |
| 271 } | 272 } |
| 272 | 273 |
| 273 if (defined(invoker.bundle_deps)) { | 274 if (defined(invoker.bundle_deps)) { |
| 274 assert(invoker.bundle_deps != [], "mark bundle_deps as used") | 275 assert(invoker.bundle_deps != [], "mark bundle_deps as used") |
| 275 } | 276 } |
| 276 } else { | 277 } else { |
| 278 _code_signing_enabled = is_ios && ios_enable_code_signing |
| 279 if (defined(invoker.code_signing_enabled)) { |
| 280 _code_signing_enabled = |
| 281 invoker.code_signing_enabled && _code_signing_enabled |
| 282 } |
| 283 |
| 277 # If the framework is unversioned, the final _target_name will be the | 284 # If the framework is unversioned, the final _target_name will be the |
| 278 # create_bundle(_framework_target), otherwise an action with the name | 285 # create_bundle(_framework_target), otherwise an action with the name |
| 279 # _target_name will depends on the the create_bundle() in order to prepare | 286 # _target_name will depends on the the create_bundle() in order to prepare |
| 280 # the versioned directory structure. | 287 # the versioned directory structure. |
| 281 _framework_target = _target_name | 288 _framework_target = _target_name |
| 282 _framework_name = _output_name + ".framework" | 289 _framework_name = _output_name + ".framework" |
| 283 _framework_root_dir = "$root_out_dir/$_framework_name" | 290 _framework_root_dir = "$root_out_dir/$_framework_name" |
| 284 if (defined(invoker.framework_version) && invoker.framework_version != "") { | 291 if (defined(invoker.framework_version) && invoker.framework_version != "") { |
| 285 _framework_version = invoker.framework_version | 292 _framework_version = invoker.framework_version |
| 286 _framework_root_dir += "/Versions/$_framework_version" | 293 _framework_root_dir += "/Versions/$_framework_version" |
| 287 _framework_target = _target_name + "_create_bundle" | 294 _framework_target = _target_name + "_create_bundle" |
| 288 } | 295 } |
| 289 | 296 |
| 290 _link_shared_library_target = target_name + "_shared_library" | 297 _link_shared_library_target = target_name + "_shared_library" |
| 291 _shared_library_bundle_data = target_name + "_shared_library_bundle_data" | 298 _shared_library_dir = "$target_out_dir/$_link_shared_library_target" |
| 292 _link_shared_library_visibility = [ ":$_shared_library_bundle_data" ] | 299 |
| 300 if (_code_signing_enabled) { |
| 301 _link_shared_library_visibility = [ ":$_framework_target" ] |
| 302 } else { |
| 303 _shared_library_bundle_data = target_name + "_shared_library_bundle_data" |
| 304 _link_shared_library_visibility = [ ":$_shared_library_bundle_data" ] |
| 305 } |
| 293 | 306 |
| 294 if (_is_fat_build) { | 307 if (_is_fat_build) { |
| 295 _lipo_shared_library_target = _link_shared_library_target | 308 _lipo_shared_library_target = _link_shared_library_target |
| 296 _lipo_shared_library_visibility = _link_shared_library_visibility | 309 _lipo_shared_library_visibility = _link_shared_library_visibility |
| 297 | 310 |
| 298 _link_shared_library_visibility = [] | 311 _link_shared_library_visibility = [] |
| 299 _link_shared_library_visibility = [ ":$_lipo_shared_library_target" ] | 312 _link_shared_library_visibility = [ ":$_lipo_shared_library_target" ] |
| 300 _link_shared_library_target = target_name + "_arch_shared_library" | 313 _link_shared_library_target = target_name + "_arch_shared_library" |
| 314 |
| 315 _arch_shared_library_dir = "$target_out_dir/$_link_shared_library_target" |
| 316 _shared_library_dir = "$target_out_dir/$_lipo_shared_library_target" |
| 301 } | 317 } |
| 302 | 318 |
| 303 shared_library(_link_shared_library_target) { | 319 shared_library(_link_shared_library_target) { |
| 304 forward_variables_from(invoker, | 320 forward_variables_from(invoker, |
| 305 "*", | 321 "*", |
| 306 [ | 322 [ |
| 307 "assert_no_deps", | 323 "assert_no_deps", |
| 308 "bundle_deps", | 324 "bundle_deps", |
| 325 "code_signing_enabled", |
| 309 "data_deps", | 326 "data_deps", |
| 310 "info_plist", | 327 "info_plist", |
| 311 "output_name", | 328 "output_name", |
| 312 "visibility", | 329 "visibility", |
| 313 ]) | 330 ]) |
| 314 visibility = _link_shared_library_visibility | 331 visibility = _link_shared_library_visibility |
| 315 output_name = _output_name | 332 output_name = _output_name |
| 316 output_prefix_override = true | 333 output_prefix_override = true |
| 317 output_extension = "" | 334 output_extension = "" |
| 318 output_dir = "$target_out_dir/$_link_shared_library_target" | 335 |
| 336 if (!_is_fat_build) { |
| 337 output_dir = _shared_library_dir |
| 338 } else { |
| 339 output_dir = _arch_shared_library_dir |
| 340 } |
| 319 } | 341 } |
| 320 | 342 |
| 321 if (_is_fat_build) { | 343 if (_is_fat_build) { |
| 322 action(_lipo_shared_library_target) { | 344 action(_lipo_shared_library_target) { |
| 323 forward_variables_from(invoker, [ "testonly" ]) | 345 forward_variables_from(invoker, [ "testonly" ]) |
| 324 visibility = _lipo_shared_library_visibility | 346 visibility = _lipo_shared_library_visibility |
| 325 script = "//build/toolchain/mac/linker_driver.py" | 347 script = "//build/toolchain/mac/linker_driver.py" |
| 326 outputs = [ | 348 outputs = [ |
| 327 "$target_out_dir/$_lipo_shared_library_target/$_output_name", | 349 "$_shared_library_dir/$_output_name", |
| 328 ] | 350 ] |
| 329 inputs = [ | 351 inputs = [ |
| 330 "$target_out_dir/$_link_shared_library_target/$_output_name", | 352 "$_arch_shared_library_dir/$_output_name", |
| 331 ] | 353 ] |
| 332 deps = [ | 354 deps = [ |
| 333 ":$_link_shared_library_target", | 355 ":$_link_shared_library_target", |
| 334 ] | 356 ] |
| 335 foreach(_additional_toolchain, additional_toolchains) { | 357 foreach(_additional_toolchain, additional_toolchains) { |
| 336 _additional_toolchain_target = "$_target_name($_additional_toolchain)" | 358 _additional_toolchain_target = "$_target_name($_additional_toolchain)" |
| 337 deps += [ ":$_additional_toolchain_target" ] | 359 deps += [ ":$_additional_toolchain_target" ] |
| 338 inputs += [ get_label_info(_additional_toolchain_target, | 360 inputs += [ get_label_info(_additional_toolchain_target, |
| 339 "target_out_dir") + "/$_output_name" ] | 361 "target_out_dir") + "/$_output_name" ] |
| 340 } | 362 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 outputs += [ outputs[0] + ".unstripped" ] | 394 outputs += [ outputs[0] + ".unstripped" ] |
| 373 args += [ "-Wcrl,unstripped," + | 395 args += [ "-Wcrl,unstripped," + |
| 374 rebase_path(get_path_info(outputs[0], "dir"), | 396 rebase_path(get_path_info(outputs[0], "dir"), |
| 375 root_build_dir) ] | 397 root_build_dir) ] |
| 376 } | 398 } |
| 377 } | 399 } |
| 378 } | 400 } |
| 379 } | 401 } |
| 380 } | 402 } |
| 381 | 403 |
| 382 bundle_data(_shared_library_bundle_data) { | 404 if (!_code_signing_enabled) { |
| 383 visibility = [ ":$_framework_target" ] | 405 bundle_data(_shared_library_bundle_data) { |
| 384 forward_variables_from(invoker, [ "testonly" ]) | 406 visibility = [ ":$_framework_target" ] |
| 385 outputs = [ | 407 forward_variables_from(invoker, [ "testonly" ]) |
| 386 "{{bundle_executable_dir}}/$_output_name", | |
| 387 ] | |
| 388 if (_is_fat_build) { | |
| 389 sources = [ | 408 sources = [ |
| 390 "$target_out_dir/$_lipo_shared_library_target/$_output_name", | 409 "$_shared_library_dir/$_output_name", |
| 391 ] | 410 ] |
| 392 public_deps = [ | 411 outputs = [ |
| 393 ":$_lipo_shared_library_target", | 412 "{{bundle_executable_dir}}/$_output_name", |
| 394 ] | 413 ] |
| 395 } else { | 414 if (_is_fat_build) { |
| 396 sources = [ | 415 public_deps = [ |
| 397 "$target_out_dir/$_link_shared_library_target/$_output_name", | 416 ":$_lipo_shared_library_target", |
| 398 ] | 417 ] |
| 399 public_deps = [ | 418 } else { |
| 400 ":$_link_shared_library_target", | 419 public_deps = [ |
| 401 ] | 420 ":$_link_shared_library_target", |
| 421 ] |
| 422 } |
| 402 } | 423 } |
| 403 } | 424 } |
| 404 | 425 |
| 405 _framework_public_config = _target_name + "_public_config" | 426 _framework_public_config = _target_name + "_public_config" |
| 406 config(_framework_public_config) { | 427 config(_framework_public_config) { |
| 407 # TODO(sdefresne): should we have a framework_dirs similar to lib_dirs | 428 # TODO(sdefresne): should we have a framework_dirs similar to lib_dirs |
| 408 # and include_dirs to avoid duplicate values on the command-line. | 429 # and include_dirs to avoid duplicate values on the command-line. |
| 409 visibility = [ ":$_framework_target" ] | 430 visibility = [ ":$_framework_target" ] |
| 410 ldflags = [ "-F" + rebase_path("$root_out_dir/.", root_build_dir) ] | 431 ldflags = [ |
| 432 "-F", |
| 433 rebase_path("$root_out_dir/.", root_build_dir), |
| 434 ] |
| 411 lib_dirs = [ root_out_dir ] | 435 lib_dirs = [ root_out_dir ] |
| 412 libs = [ _framework_name ] | 436 libs = [ _framework_name ] |
| 413 } | 437 } |
| 414 | 438 |
| 415 create_bundle(_framework_target) { | 439 create_bundle(_framework_target) { |
| 416 forward_variables_from(invoker, | 440 forward_variables_from(invoker, |
| 417 [ | 441 [ |
| 418 "data_deps", | 442 "data_deps", |
| 419 "deps", | 443 "deps", |
| 420 "public_deps", | 444 "public_deps", |
| 421 "testonly", | 445 "testonly", |
| 422 ]) | 446 ]) |
| 423 | 447 |
| 424 if (defined(_framework_version)) { | 448 if (defined(_framework_version)) { |
| 425 visibility = [ ":$_target_name" ] | 449 visibility = [ ":$_target_name" ] |
| 426 } else { | 450 } else { |
| 427 if (defined(invoker.visibility)) { | 451 if (defined(invoker.visibility)) { |
| 428 visibility = invoker.visibility | 452 visibility = invoker.visibility |
| 429 visibility += [ ":$_target_name+link" ] | 453 visibility += [ ":$_target_name+link" ] |
| 430 } | 454 } |
| 431 } | 455 } |
| 432 | 456 |
| 433 if (!defined(public_deps)) { | 457 if (!_code_signing_enabled) { |
| 434 public_deps = [] | 458 if (!defined(public_deps)) { |
| 435 } | 459 public_deps = [] |
| 436 public_deps += [ ":$_shared_library_bundle_data" ] | 460 } |
| 461 public_deps += [ ":$_shared_library_bundle_data" ] |
| 437 | 462 |
| 438 if (defined(invoker.bundle_deps)) { | 463 if (defined(invoker.bundle_deps)) { |
| 439 public_deps += invoker.bundle_deps | 464 if (!defined(deps)) { |
| 465 deps = [] |
| 466 } |
| 467 deps += invoker.bundle_deps |
| 468 } |
| 440 } | 469 } |
| 441 | 470 |
| 442 bundle_root_dir = _framework_root_dir | 471 bundle_root_dir = _framework_root_dir |
| 443 bundle_resources_dir = "$bundle_root_dir/Resources" | 472 bundle_resources_dir = "$bundle_root_dir/Resources" |
| 444 bundle_executable_dir = "$bundle_root_dir" | 473 bundle_executable_dir = "$bundle_root_dir" |
| 474 |
| 475 if (_code_signing_enabled) { |
| 476 if (!defined(deps)) { |
| 477 deps = [] |
| 478 } |
| 479 |
| 480 if (_is_fat_build) { |
| 481 deps += [ ":$_lipo_shared_library_target" ] |
| 482 } else { |
| 483 deps += [ ":$_link_shared_library_target" ] |
| 484 } |
| 485 |
| 486 _entitlements_path = "$ios_sdk_path/Entitlements.plist" |
| 487 if (defined(invoker.entitlements_path)) { |
| 488 _entitlements_path = invoker.entitlements_path |
| 489 } |
| 490 |
| 491 code_signing_script = "//build/config/ios/codesign.py" |
| 492 code_signing_sources = [ |
| 493 _entitlements_path, |
| 494 "$_shared_library_dir/$_output_name", |
| 495 ] |
| 496 code_signing_outputs = [ |
| 497 "$bundle_root_dir/$_output_name", |
| 498 "$bundle_root_dir/_CodeSignature/CodeResources", |
| 499 "$bundle_root_dir/embedded.mobileprovision", |
| 500 ] |
| 501 code_signing_args = [ |
| 502 "-i=" + ios_code_signing_identity, |
| 503 "-b=" + |
| 504 rebase_path("$_shared_library_dir/$_output_name", root_build_dir), |
| 505 "-e=" + rebase_path(_entitlements_path, root_build_dir), |
| 506 rebase_path(bundle_root_dir, root_build_dir), |
| 507 ] |
| 508 } |
| 445 } | 509 } |
| 446 | 510 |
| 447 if (defined(_framework_version)) { | 511 if (defined(_framework_version)) { |
| 448 action(_target_name) { | 512 action(_target_name) { |
| 449 forward_variables_from(invoker, [ "testonly" ]) | 513 forward_variables_from(invoker, [ "testonly" ]) |
| 450 | 514 |
| 451 if (defined(invoker.visibility)) { | 515 if (defined(invoker.visibility)) { |
| 452 visibility = invoker.visibility | 516 visibility = invoker.visibility |
| 453 visibility += [ ":$_target_name+link" ] | 517 visibility += [ ":$_target_name+link" ] |
| 454 } | 518 } |
| 455 | 519 |
| 456 script = "//build/config/mac/package_framework.py" | 520 script = "//build/config/mac/package_framework.py" |
| 457 outputs = [ | 521 outputs = [ |
| 458 "$root_out_dir/$_framework_name/Versions/Current", | 522 "$root_out_dir/$_framework_name/Versions/Current", |
| 459 ] | 523 ] |
| 460 args = [ | 524 args = [ |
| 461 "$_framework_name", | 525 "$_framework_name", |
| 462 "$_framework_version", | 526 "$_framework_version", |
| 463 ] | 527 ] |
| 464 public_deps = [ | 528 public_deps = [ |
| 465 ":$_framework_target", | 529 ":$_framework_target", |
| 466 ] | 530 ] |
| 467 } | 531 } |
| 468 } | 532 } |
| 469 | 533 |
| 470 group(_target_name + "+link") { | 534 group(_target_name + "+link") { |
| 471 forward_variables_from(invoker, | 535 forward_variables_from(invoker, |
| 472 [ | 536 [ |
| 537 "public_configs", |
| 538 "testonly", |
| 473 "visibility", | 539 "visibility", |
| 474 "testonly", | |
| 475 ]) | 540 ]) |
| 476 public_deps = [ | 541 public_deps = [ |
| 477 ":$_target_name", | 542 ":$_target_name", |
| 478 ] | 543 ] |
| 479 public_configs = [ ":$_framework_public_config" ] | 544 if (!defined(public_configs)) { |
| 545 public_configs = [] |
| 546 } |
| 547 public_configs += [ ":$_framework_public_config" ] |
| 480 } | 548 } |
| 481 } | 549 } |
| 482 } | 550 } |
| 483 | 551 |
| 484 # Template to combile .xib or .storyboard files. | 552 # Template to combile .xib or .storyboard files. |
| 485 # | 553 # |
| 486 # Arguments | 554 # Arguments |
| 487 # | 555 # |
| 488 # sources: | 556 # sources: |
| 489 # list of string, sources to compile | 557 # list of string, sources to compile |
| (...skipping 22 matching lines...) Expand all Loading... |
| 512 ] | 580 ] |
| 513 args = | 581 args = |
| 514 [ | 582 [ |
| 515 "--input", | 583 "--input", |
| 516 "{{source}}", | 584 "{{source}}", |
| 517 "--output", | 585 "--output", |
| 518 rebase_path("$target_gen_dir/$target_name/{{source_name_part}}.nib"), | 586 rebase_path("$target_gen_dir/$target_name/{{source_name_part}}.nib"), |
| 519 ] + ibtool_flags | 587 ] + ibtool_flags |
| 520 } | 588 } |
| 521 } | 589 } |
| OLD | NEW |