Chromium Code Reviews| 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 | 8 |
| 9 if (is_mac) { | 9 if (is_mac) { |
| 10 import("//build/config/mac/mac_sdk.gni") | 10 import("//build/config/mac/mac_sdk.gni") |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 211 # | 211 # |
| 212 # See "gn help shared_library" for more information on arguments supported | 212 # See "gn help shared_library" for more information on arguments supported |
| 213 # by shared library target. | 213 # by shared library target. |
| 214 template("framework_bundle") { | 214 template("framework_bundle") { |
| 215 _target_name = target_name | 215 _target_name = target_name |
| 216 _output_name = target_name | 216 _output_name = target_name |
| 217 if (defined(invoker.output_name)) { | 217 if (defined(invoker.output_name)) { |
| 218 _output_name = invoker.output_name | 218 _output_name = invoker.output_name |
| 219 } | 219 } |
| 220 | 220 |
| 221 # If the framework is unversioned, the final _target_name will be the | 221 _is_fat_build = is_ios && additional_toolchains != [] |
| 222 # create_bundle(_framework_target), otherwise an action with the name | 222 if (_is_fat_build) { |
| 223 # _target_name will depends on the the create_bundle() in order to prepare | 223 _is_fat_build_main_target = current_toolchain == default_toolchain |
| 224 # the versioned directory structure. | |
| 225 _framework_target = _target_name | |
| 226 _framework_name = _output_name + ".framework" | |
| 227 _framework_root_dir = "$root_out_dir/$_framework_name" | |
| 228 if (defined(invoker.framework_version) && invoker.framework_version != "") { | |
| 229 _framework_version = invoker.framework_version | |
| 230 _framework_root_dir += "/Versions/$_framework_version" | |
| 231 _framework_target = _target_name + "_create_bundle" | |
| 232 } | 224 } |
| 233 | 225 |
| 234 _shared_library_target = target_name + "_shared_library" | 226 # The expansion of the template is different for fat and thin builds. For |
| 235 _shared_library_bundle_data = _shared_library_target + "_bundle_data" | 227 # thin build (and default toolchain of a fat build), the template expands |
| 236 | 228 # to a "shared_library" target to create the bundle shared library and a |
| 237 shared_library(_shared_library_target) { | 229 # "create_bundle" target (the main target) to create the bundle structure. |
| 238 visibility = [ ":$_shared_library_bundle_data" ] | 230 # |
| 239 forward_variables_from(invoker, | 231 # For a fat build, the template just expands to the "shared_library" target |
| 240 "*", | 232 # for the non-default toolchain, while the final library is created using |
| 241 [ | 233 # "lipo" in the expansion of the template for the default toolchain. |
| 242 "assert_no_deps", | 234 # |
| 243 "data_deps", | 235 # The "$target_name+link" group for the non-default toolchain depends on the |
| 244 "info_plist", | 236 # target of the same name from the default toolchain as this is the target |
| 245 "output_name", | 237 # that defines the real framework bundle (it will support the current cpu |
| 246 "visibility", | 238 # as it is a fat framework). |
| 247 ]) | 239 |
| 248 output_name = _output_name | 240 if (_is_fat_build && !_is_fat_build_main_target) { |
| 249 output_prefix_override = true | 241 shared_library(_target_name) { |
| 250 output_extension = "" | 242 forward_variables_from(invoker, |
| 251 output_dir = "$target_out_dir/$_shared_library_target" | 243 "*", |
| 252 } | 244 [ |
| 253 | 245 "assert_no_deps", |
| 254 bundle_data(_shared_library_bundle_data) { | 246 "data_deps", |
| 255 visibility = [ ":$_framework_target" ] | 247 "info_plist", |
| 256 forward_variables_from(invoker, [ "testonly" ]) | 248 "output_name", |
| 257 sources = [ | 249 ]) |
| 258 "$target_out_dir/$_shared_library_target/$_output_name", | 250 if (defined(visibility)) { |
| 259 ] | 251 visibility += [ ":*($default_toolchain)" ] |
|
Robert Sesek
2016/07/12 23:57:16
Why :* here? Can't this be limited to the _lipo_sh
sdefresne
2016/07/13 10:57:50
I cannot ignore the invoker visibility because thi
| |
| 260 outputs = [ | 252 } |
| 261 "{{bundle_executable_dir}}/$_output_name", | 253 output_name = _output_name |
| 262 ] | 254 output_prefix_override = true |
| 263 public_deps = [ | 255 output_extension = "" |
| 264 ":$_shared_library_target", | 256 output_dir = "$target_out_dir/$_target_name" |
| 265 ] | 257 } |
| 266 } | 258 |
| 267 | 259 group(_target_name + "+link") { |
| 268 _framework_public_config = _target_name + "_public_config" | 260 forward_variables_from(invoker, |
| 269 config(_framework_public_config) { | 261 [ |
| 270 # TODO(sdefresne): should we have a framework_dirs similar to lib_dirs | 262 "visibility", |
| 271 # and include_dirs to avoid duplicate values on the command-line. | 263 "testonly", |
| 272 visibility = [ ":$_framework_target" ] | 264 ]) |
| 273 ldflags = [ "-F" + rebase_path("$root_out_dir/.", root_build_dir) ] | 265 public_deps = [ |
| 274 lib_dirs = [ root_out_dir ] | 266 ":$_target_name($default_toolchain)", |
| 275 libs = [ _framework_name ] | 267 ] |
| 276 } | 268 } |
| 277 | 269 } else { |
| 278 create_bundle(_framework_target) { | 270 # If the framework is unversioned, the final _target_name will be the |
| 279 forward_variables_from(invoker, | 271 # create_bundle(_framework_target), otherwise an action with the name |
| 280 [ | 272 # _target_name will depends on the the create_bundle() in order to prepare |
| 281 "data_deps", | 273 # the versioned directory structure. |
| 282 "deps", | 274 _framework_target = _target_name |
| 283 "public_deps", | 275 _framework_name = _output_name + ".framework" |
| 284 "testonly", | 276 _framework_root_dir = "$root_out_dir/$_framework_name" |
| 285 ]) | 277 if (defined(invoker.framework_version) && invoker.framework_version != "") { |
| 278 _framework_version = invoker.framework_version | |
| 279 _framework_root_dir += "/Versions/$_framework_version" | |
| 280 _framework_target = _target_name + "_create_bundle" | |
| 281 } | |
| 282 | |
| 283 _link_shared_library_target = target_name + "_link_shared_library" | |
| 284 _shared_library_bundle_data = target_name + "_shared_library_bundle_data" | |
| 285 _link_shared_library_visibility = [ ":$_shared_library_bundle_data" ] | |
| 286 | |
| 287 if (_is_fat_build) { | |
| 288 _lipo_shared_library_target = target_name + "_lipo_shared_library" | |
| 289 _lipo_shared_library_visibility = _link_shared_library_visibility | |
| 290 | |
| 291 _link_shared_library_visibility = [] | |
|
Robert Sesek
2016/07/12 23:57:16
Remove
sdefresne
2016/07/13 10:57:50
I can't as "gn" complain with the following error:
Robert Sesek
2016/07/13 20:27:54
Acknowledged.
| |
| 292 _link_shared_library_visibility = [ ":$_lipo_shared_library_target" ] | |
| 293 } | |
| 294 | |
| 295 shared_library(_link_shared_library_target) { | |
| 296 forward_variables_from(invoker, | |
| 297 "*", | |
| 298 [ | |
| 299 "assert_no_deps", | |
| 300 "data_deps", | |
| 301 "info_plist", | |
| 302 "output_name", | |
| 303 "visibility", | |
| 304 ]) | |
| 305 visibility = _link_shared_library_visibility | |
| 306 output_name = _output_name | |
| 307 output_prefix_override = true | |
| 308 output_extension = "" | |
| 309 output_dir = "$target_out_dir/$_link_shared_library_target" | |
| 310 } | |
| 311 | |
| 312 if (_is_fat_build) { | |
| 313 action(_lipo_shared_library_target) { | |
| 314 forward_variables_from(invoker, [ "testonly" ]) | |
| 315 visibility = _lipo_shared_library_visibility | |
| 316 script = "//build/config/mac/xcrun.py" | |
| 317 outputs = [ | |
| 318 "$target_out_dir/$_lipo_shared_library_target/$_output_name", | |
| 319 ] | |
| 320 inputs = [ | |
| 321 "$target_out_dir/$_link_shared_library_target/$_output_name", | |
| 322 ] | |
| 323 deps = [ | |
| 324 ":$_link_shared_library_target", | |
| 325 ] | |
| 326 foreach(_additional_toolchain, additional_toolchains) { | |
| 327 _additional_toolchain_target = "$_target_name($_additional_toolchain)" | |
| 328 deps += [ ":$_additional_toolchain_target" ] | |
| 329 inputs += [ get_label_info(_additional_toolchain_target, | |
| 330 "target_out_dir") + "/$_output_name" ] | |
| 331 } | |
| 332 args = [ | |
| 333 "lipo", | |
| 334 "-create", | |
| 335 "-output", | |
| 336 rebase_path(outputs[0], root_build_dir), | |
| 337 ] + rebase_path(inputs, root_build_dir) | |
| 338 } | |
| 339 } | |
| 340 | |
| 341 bundle_data(_shared_library_bundle_data) { | |
| 342 visibility = [ ":$_framework_target" ] | |
| 343 forward_variables_from(invoker, [ "testonly" ]) | |
| 344 outputs = [ | |
| 345 "{{bundle_executable_dir}}/$_output_name", | |
| 346 ] | |
| 347 if (_is_fat_build) { | |
| 348 sources = [ | |
| 349 "$target_out_dir/$_lipo_shared_library_target/$_output_name", | |
| 350 ] | |
| 351 public_deps = [ | |
| 352 ":$_lipo_shared_library_target", | |
| 353 ] | |
| 354 } else { | |
| 355 sources = [ | |
| 356 "$target_out_dir/$_link_shared_library_target/$_output_name", | |
| 357 ] | |
| 358 public_deps = [ | |
| 359 ":$_link_shared_library_target", | |
| 360 ] | |
| 361 } | |
| 362 } | |
| 363 | |
| 364 _framework_public_config = _target_name + "_public_config" | |
| 365 config(_framework_public_config) { | |
| 366 # TODO(sdefresne): should we have a framework_dirs similar to lib_dirs | |
| 367 # and include_dirs to avoid duplicate values on the command-line. | |
| 368 visibility = [ ":$_framework_target" ] | |
| 369 ldflags = [ "-F" + rebase_path("$root_out_dir/.", root_build_dir) ] | |
| 370 lib_dirs = [ root_out_dir ] | |
| 371 libs = [ _framework_name ] | |
| 372 } | |
| 373 | |
| 374 create_bundle(_framework_target) { | |
| 375 forward_variables_from(invoker, | |
| 376 [ | |
| 377 "data_deps", | |
| 378 "deps", | |
| 379 "public_deps", | |
| 380 "testonly", | |
| 381 ]) | |
| 382 | |
| 383 if (defined(_framework_version)) { | |
| 384 visibility = [ ":$_target_name" ] | |
| 385 } else { | |
| 386 if (defined(invoker.visibility)) { | |
| 387 visibility = invoker.visibility | |
| 388 visibility += [ ":$_target_name+link" ] | |
| 389 } | |
| 390 } | |
| 391 | |
| 392 if (!defined(public_deps)) { | |
| 393 public_deps = [] | |
| 394 } | |
| 395 public_deps += [ ":$_shared_library_bundle_data" ] | |
| 396 | |
| 397 bundle_root_dir = _framework_root_dir | |
| 398 bundle_resources_dir = "$bundle_root_dir/Resources" | |
| 399 bundle_executable_dir = "$bundle_root_dir" | |
| 400 } | |
| 286 | 401 |
| 287 if (defined(_framework_version)) { | 402 if (defined(_framework_version)) { |
| 288 visibility = [ ":$_target_name" ] | 403 action(_target_name) { |
| 289 } else { | 404 forward_variables_from(invoker, [ "testonly" ]) |
| 290 if (defined(invoker.visibility)) { | 405 |
| 291 visibility = invoker.visibility | 406 if (defined(invoker.visibility)) { |
| 292 visibility += [ ":$_target_name+link" ] | 407 visibility = invoker.visibility |
| 293 } | 408 visibility += [ ":$_target_name+link" ] |
| 294 } | 409 } |
| 295 | 410 |
| 296 if (!defined(public_deps)) { | 411 script = "//build/config/mac/package_framework.py" |
| 297 public_deps = [] | 412 outputs = [ |
| 298 } | 413 "$root_out_dir/$_framework_name/Versions/Current", |
| 299 public_deps += [ ":$_shared_library_bundle_data" ] | 414 ] |
| 300 | 415 args = [ |
| 301 bundle_root_dir = _framework_root_dir | 416 "$_framework_name", |
| 302 bundle_resources_dir = "$bundle_root_dir/Resources" | 417 "$_framework_version", |
| 303 bundle_executable_dir = "$bundle_root_dir" | 418 ] |
| 304 } | 419 public_deps = [ |
| 305 | 420 ":$_framework_target", |
| 306 if (defined(_framework_version)) { | 421 ] |
| 307 action(_target_name) { | 422 } |
| 308 forward_variables_from(invoker, [ "testonly" ]) | 423 } |
| 309 | 424 |
| 310 if (defined(invoker.visibility)) { | 425 group(_target_name + "+link") { |
| 311 visibility = invoker.visibility | 426 forward_variables_from(invoker, |
| 312 visibility += [ ":$_target_name+link" ] | 427 [ |
| 313 } | 428 "visibility", |
| 314 | 429 "testonly", |
| 315 script = "//build/config/mac/package_framework.py" | 430 ]) |
| 316 outputs = [ | 431 public_deps = [ |
| 317 "$root_out_dir/$_framework_name/Versions/Current", | 432 ":$_target_name", |
| 318 ] | 433 ] |
| 319 args = [ | 434 public_configs = [ ":$_framework_public_config" ] |
| 320 "$_framework_name", | 435 } |
| 321 "$_framework_version", | |
| 322 ] | |
| 323 public_deps = [ | |
| 324 ":$_framework_target", | |
| 325 ] | |
| 326 } | |
| 327 } | |
| 328 | |
| 329 group(_target_name + "+link") { | |
| 330 forward_variables_from(invoker, | |
| 331 [ | |
| 332 "visibility", | |
| 333 "testonly", | |
| 334 ]) | |
| 335 public_deps = [ | |
| 336 ":$_target_name", | |
| 337 ] | |
| 338 public_configs = [ ":$_framework_public_config" ] | |
| 339 } | 436 } |
| 340 } | 437 } |
| 341 | 438 |
| 342 # Template to combile .xib or .storyboard files. | 439 # Template to combile .xib or .storyboard files. |
| 343 # | 440 # |
| 344 # Arguments | 441 # Arguments |
| 345 # | 442 # |
| 346 # sources: | 443 # sources: |
| 347 # list of string, sources to compile | 444 # list of string, sources to compile |
| 348 # | 445 # |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 370 ] | 467 ] |
| 371 args = | 468 args = |
| 372 [ | 469 [ |
| 373 "--input", | 470 "--input", |
| 374 "{{source}}", | 471 "{{source}}", |
| 375 "--output", | 472 "--output", |
| 376 rebase_path("$target_gen_dir/$target_name/{{source_name_part}}.nib"), | 473 rebase_path("$target_gen_dir/$target_name/{{source_name_part}}.nib"), |
| 377 ] + ibtool_flags | 474 ] + ibtool_flags |
| 378 } | 475 } |
| 379 } | 476 } |
| OLD | NEW |