| 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/rules.gni") | 6 import("//build/config/mac/rules.gni") |
| 7 | 7 |
| 8 # TODO(crbug.com/297668): refactor this template to extract common behaviour | 8 # TODO(crbug.com/297668): refactor this template to extract common behaviour |
| 9 # between OS X and iOS bundle generation, then create a generic "app" template | 9 # between OS X and iOS bundle generation, then create a generic "app" template |
| 10 # that forward to "executable" on all platform except iOS/OS X. | 10 # that forward to "executable" on all platform except iOS/OS X. |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 # into the framework subdirectory. | 247 # into the framework subdirectory. |
| 248 # | 248 # |
| 249 # public_headers: | 249 # public_headers: |
| 250 # (optional) list of paths to header file that needs to be copied | 250 # (optional) list of paths to header file that needs to be copied |
| 251 # into the framework bundle Headers subdirectory. If omitted or | 251 # into the framework bundle Headers subdirectory. If omitted or |
| 252 # empty then the Headers subdirectory is not created. | 252 # empty then the Headers subdirectory is not created. |
| 253 # | 253 # |
| 254 # See "gn help shared_library" for more information on arguments supported | 254 # See "gn help shared_library" for more information on arguments supported |
| 255 # by shared library target. | 255 # by shared library target. |
| 256 template("ios_framework_bundle") { | 256 template("ios_framework_bundle") { |
| 257 _target_name = target_name |
| 258 _framework_target = _target_name |
| 259 |
| 257 if (defined(invoker.public_headers) && invoker.public_headers != []) { | 260 if (defined(invoker.public_headers) && invoker.public_headers != []) { |
| 258 _target_name = target_name | |
| 259 _output_name = target_name | 261 _output_name = target_name |
| 260 if (defined(invoker.output_name)) { | 262 if (defined(invoker.output_name)) { |
| 261 _output_name = invoker.output_name | 263 _output_name = invoker.output_name |
| 262 } | 264 } |
| 263 | 265 |
| 264 _public_headers = invoker.public_headers | 266 _public_headers = invoker.public_headers |
| 265 _framework_name = _output_name + ".framework" | 267 _framework_name = _output_name + ".framework" |
| 266 _framework_root = "$root_out_dir/$_framework_name" | 268 _framework_root = "$root_out_dir/$_framework_name" |
| 269 _framework_target = target_name + "_internal" |
| 267 | 270 |
| 268 _header_map_filename = "$target_gen_dir/$_output_name.headers.hmap" | 271 _header_map_filename = "$target_gen_dir/$_output_name.headers.hmap" |
| 269 _framework_headers_target = _target_name + "_framework_headers" | 272 _framework_headers_target = _target_name + "_framework_headers" |
| 270 | 273 |
| 271 _compile_headers_map_target = _target_name + "_compile_headers_map" | 274 _compile_headers_map_target = _target_name + "_compile_headers_map" |
| 272 action(_compile_headers_map_target) { | 275 action(_compile_headers_map_target) { |
| 273 visibility = [ ":$_framework_headers_target" ] | 276 visibility = [ ":$_framework_headers_target" ] |
| 274 script = "$root_out_dir/gyp-mac-tool" | 277 script = "$root_out_dir/gyp-mac-tool" |
| 275 outputs = [ | 278 outputs = [ |
| 276 _header_map_filename, | 279 _header_map_filename, |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 "$_framework_root/Headers/{{source_file_part}}", | 315 "$_framework_root/Headers/{{source_file_part}}", |
| 313 ] | 316 ] |
| 314 } | 317 } |
| 315 | 318 |
| 316 _headers_map_config = _target_name + "_headers_map" | 319 _headers_map_config = _target_name + "_headers_map" |
| 317 config(_headers_map_config) { | 320 config(_headers_map_config) { |
| 318 visibility = [ ":$_target_name" ] | 321 visibility = [ ":$_target_name" ] |
| 319 include_dirs = [ _header_map_filename ] | 322 include_dirs = [ _header_map_filename ] |
| 320 } | 323 } |
| 321 | 324 |
| 325 _framework_public_config = _target_name + "_public_config" |
| 326 config(_framework_public_config) { |
| 327 # TODO(sdefresne): should we have a framework_dirs similar to lib_dirs |
| 328 # and include_dirs to avoid duplicate values on the command-line. |
| 329 common_flags = [ "-F" + rebase_path("$root_out_dir/.", root_out_dir) ] |
| 330 cflags_objc = common_flags |
| 331 cflags_objcc = common_flags |
| 332 ldflags = common_flags |
| 333 lib_dirs = [ root_out_dir ] |
| 334 libs = [ _framework_name ] |
| 335 } |
| 336 |
| 322 group(_framework_headers_target) { | 337 group(_framework_headers_target) { |
| 323 deps = [ | 338 deps = [ |
| 324 ":$_compile_headers_map_target", | 339 ":$_compile_headers_map_target", |
| 325 ":$_copy_public_headers_target", | 340 ":$_copy_public_headers_target", |
| 326 ":$_create_module_map_target", | 341 ":$_create_module_map_target", |
| 327 ] | 342 ] |
| 328 } | 343 } |
| 329 } | 344 } |
| 330 | 345 |
| 331 framework_bundle(target_name) { | 346 framework_bundle(_framework_target) { |
| 332 forward_variables_from(invoker, "*", [ "public_headers" ]) | 347 forward_variables_from(invoker, |
| 348 "*", |
| 349 [ |
| 350 "public_headers", |
| 351 "visibility", |
| 352 ]) |
| 333 | 353 |
| 334 if (defined(_public_headers)) { | 354 if (defined(_public_headers)) { |
| 355 visibility = [ ":$_target_name" ] |
| 335 configs += [ ":$_headers_map_config" ] | 356 configs += [ ":$_headers_map_config" ] |
| 357 |
| 336 if (!defined(deps)) { | 358 if (!defined(deps)) { |
| 337 deps = [] | 359 deps = [] |
| 338 } | 360 } |
| 339 deps += [ ":$_framework_headers_target" ] | 361 deps += [ ":$_framework_headers_target" ] |
| 362 } else { |
| 363 forward_variables_from(invoker, [ "visibility" ]) |
| 364 } |
| 365 } |
| 366 |
| 367 if (defined(_public_headers)) { |
| 368 group(_target_name) { |
| 369 forward_variables_from(invoker, |
| 370 [ |
| 371 "testonly", |
| 372 "visibility", |
| 373 "public_configs", |
| 374 ]) |
| 375 |
| 376 deps = [ |
| 377 ":$_framework_target", |
| 378 ] |
| 379 if (!defined(public_configs)) { |
| 380 public_configs = [] |
| 381 } |
| 382 public_configs += [ ":$_framework_public_config" ] |
| 340 } | 383 } |
| 341 } | 384 } |
| 342 } | 385 } |
| OLD | NEW |