Index: build/config/ios/rules.gni |
diff --git a/build/config/ios/rules.gni b/build/config/ios/rules.gni |
index 6edec87e9401f6b9c68b4d573cfc1d60eaff36a0..e77430ae9d809520ba01e0c7637a69eb51c483e6 100644 |
--- a/build/config/ios/rules.gni |
+++ b/build/config/ios/rules.gni |
@@ -641,91 +641,115 @@ template("ios_framework_bundle") { |
} |
_framework_target = _target_name |
- if (defined(invoker.public_headers) && invoker.public_headers != []) { |
- _public_headers = invoker.public_headers |
- _framework_name = _output_name + ".framework" |
- _framework_root = "$root_out_dir/$_framework_name" |
- _framework_target = target_name + "_internal" |
+ _has_public_headers = |
+ defined(invoker.public_headers) && invoker.public_headers != [] |
+ |
+ _is_fat_build = additional_toolchains != [] |
+ if (_is_fat_build) { |
+ _is_fat_build_main_target = current_toolchain == default_toolchain |
+ } |
+ |
+ # This template has a different expansion depending on whether public headers |
+ # are defined or not. If no public headers are speficied, then is forwards to |
+ # the generic "framework_bundle" target, otherwise if expands to targets that |
+ # create header map mapping and corresponding config and configure them as |
+ # dependencies of the generic "framework_bundle" target. |
+ # |
+ # The expansion is a bit different for multi-architecture builds (aka fat |
+ # binary builds). Then the targets build for the non-default toolchain uses |
+ # the same header map (if available) as the one used by the default toolchain. |
+ |
+ _toolchain_suffix = "" |
+ if (_is_fat_build && !_is_fat_build_main_target) { |
+ _toolchain_suffix = "($default_toolchain)" |
+ } |
- _header_map_filename = "$target_gen_dir/$_output_name.headers.hmap" |
+ if (_has_public_headers) { |
_framework_headers_target = _target_name + "_framework_headers" |
+ _framework_public_config = _target_name + "_ios_public_config" |
+ _framework_target = target_name + "_internal" |
+ _headers_map_config = _target_name + "_headers_map" |
- _compile_headers_map_target = _target_name + "_compile_headers_map" |
- action(_compile_headers_map_target) { |
- visibility = [ ":$_framework_headers_target" ] |
- script = "//build/config/ios/write_framework_hmap.py" |
- outputs = [ |
- _header_map_filename, |
- ] |
+ if (!_is_fat_build || _is_fat_build_main_target) { |
+ _public_headers = invoker.public_headers |
+ _framework_name = _output_name + ".framework" |
+ _framework_root = "$root_out_dir/$_framework_name" |
- # The header map generation only wants the list of headers, not all of |
- # sources, so filter any non-header source files from "sources". It is |
- # less error prone that having the developer duplicate the list of all |
- # headers in addition to "sources". |
- set_sources_assignment_filter([ |
- "*.c", |
- "*.cc", |
- "*.cpp", |
- "*.m", |
- "*.mm", |
- ]) |
- sources = invoker.sources |
- set_sources_assignment_filter([]) |
- |
- args = [ |
- rebase_path(_header_map_filename), |
- rebase_path(_framework_root, root_build_dir), |
- ] + rebase_path(sources, root_build_dir) |
- } |
+ _header_map_filename = "$target_gen_dir/$_output_name.headers.hmap" |
- _create_module_map_target = _target_name + "_module_map" |
- action(_create_module_map_target) { |
- visibility = [ ":$_framework_headers_target" ] |
- script = "//build/config/ios/write_framework_modulemap.py" |
- outputs = [ |
- "$_framework_root/Modules/module.modulemap", |
- ] |
- args = [ rebase_path("$_framework_root", root_build_dir) ] |
- } |
+ _compile_headers_map_target = _target_name + "_compile_headers_map" |
+ action(_compile_headers_map_target) { |
+ visibility = [ ":$_framework_headers_target" ] |
+ script = "//build/config/ios/write_framework_hmap.py" |
+ outputs = [ |
+ _header_map_filename, |
+ ] |
- _copy_public_headers_target = _target_name + "_copy_public_headers" |
- copy(_copy_public_headers_target) { |
- visibility = [ ":$_framework_headers_target" ] |
- sources = _public_headers |
- outputs = [ |
- "$_framework_root/Headers/{{source_file_part}}", |
- ] |
- } |
+ # The header map generation only wants the list of headers, not all of |
+ # sources, so filter any non-header source files from "sources". It is |
+ # less error prone that having the developer duplicate the list of all |
+ # headers in addition to "sources". |
+ set_sources_assignment_filter([ |
+ "*.c", |
+ "*.cc", |
+ "*.cpp", |
+ "*.m", |
+ "*.mm", |
+ ]) |
+ sources = invoker.sources |
+ set_sources_assignment_filter([]) |
- _headers_map_config = _target_name + "_headers_map" |
- config(_headers_map_config) { |
- visibility = [ ":$_target_name" ] |
- include_dirs = [ _header_map_filename ] |
- ldflags = [ |
- "-install_name", |
- "@rpath/$_framework_name/$_output_name", |
- ] |
- } |
+ args = [ |
+ rebase_path(_header_map_filename), |
+ rebase_path(_framework_root, root_build_dir), |
+ ] + rebase_path(sources, root_build_dir) |
+ } |
- group(_framework_headers_target) { |
- deps = [ |
- ":$_compile_headers_map_target", |
- ":$_copy_public_headers_target", |
- ":$_create_module_map_target", |
- ] |
- } |
- } |
+ _create_module_map_target = _target_name + "_module_map" |
+ action(_create_module_map_target) { |
+ visibility = [ ":$_framework_headers_target" ] |
+ script = "//build/config/ios/write_framework_modulemap.py" |
+ outputs = [ |
+ "$_framework_root/Modules/module.modulemap", |
+ ] |
+ args = [ rebase_path("$_framework_root", root_build_dir) ] |
+ } |
- _framework_public_config = _target_name + "_ios_public_config" |
- config(_framework_public_config) { |
- visibility = [ ":$_framework_public_config" ] |
- if (defined(_public_headers)) { |
- common_flags = [ "-F" + rebase_path("$root_out_dir/.", root_build_dir) ] |
- cflags_objc = common_flags |
- cflags_objcc = common_flags |
- } |
+ _copy_public_headers_target = _target_name + "_copy_public_headers" |
+ copy(_copy_public_headers_target) { |
+ visibility = [ ":$_framework_headers_target" ] |
+ sources = _public_headers |
+ outputs = [ |
+ "$_framework_root/Headers/{{source_file_part}}", |
+ ] |
+ } |
- # The link settings are inherited from the framework_bundle config. |
+ config(_headers_map_config) { |
+ visibility = [ ":$_target_name" ] |
+ include_dirs = [ _header_map_filename ] |
+ ldflags = [ |
+ "-install_name", |
+ "@rpath/$_framework_name/$_output_name", |
+ ] |
+ } |
+ |
+ group(_framework_headers_target) { |
+ deps = [ |
+ ":$_compile_headers_map_target", |
+ ":$_copy_public_headers_target", |
+ ":$_create_module_map_target", |
+ ] |
+ } |
+ |
+ config(_framework_public_config) { |
+ visibility = [ ":$_framework_public_config" ] |
+ common_flags = [ "-F" + rebase_path("$root_out_dir/.", root_build_dir) ] |
+ cflags_objc = common_flags |
+ cflags_objcc = common_flags |
+ |
+ # The link settings are inherited from the framework_bundle config. |
+ } |
+ } |
} |
framework_bundle(_framework_target) { |
@@ -738,31 +762,33 @@ template("ios_framework_bundle") { |
]) |
output_name = _output_name |
- if (!defined(public_configs)) { |
- public_configs = [] |
+ if (_has_public_headers) { |
+ if (!defined(public_configs)) { |
+ public_configs = [] |
+ } |
+ public_configs += [ ":$_framework_public_config$_toolchain_suffix" ] |
} |
- public_configs += [ ":$_framework_public_config" ] |
- if (defined(_public_headers)) { |
+ if (_has_public_headers) { |
visibility = [ |
- ":$_target_name", |
- ":$_target_name+link", |
+ ":$_target_name$_toolchain_suffix", |
+ ":$_target_name+link$_toolchain_suffix", |
] |
- configs += [ ":$_headers_map_config" ] |
+ configs += [ ":$_headers_map_config$_toolchain_suffix" ] |
if (!defined(deps)) { |
deps = [] |
} |
- deps += [ ":$_framework_headers_target" ] |
+ deps += [ ":$_framework_headers_target$_toolchain_suffix" ] |
} else { |
if (defined(invoker.visibility)) { |
visibility = invoker.visibility |
- visibility += [ ":$_target_name+link" ] |
+ visibility += [ ":$_target_name+link$_toolchain_suffix" ] |
} |
} |
} |
- if (defined(_public_headers)) { |
+ if (_has_public_headers) { |
group(_target_name) { |
forward_variables_from(invoker, |
[ |
@@ -776,7 +802,7 @@ template("ios_framework_bundle") { |
} |
public_deps = [ |
- ":$_framework_target", |
+ ":$_framework_target$_toolchain_suffix", |
] |
} |
@@ -787,7 +813,7 @@ template("ios_framework_bundle") { |
"visibility", |
]) |
public_deps = [ |
- ":$_framework_target+link", |
+ ":$_framework_target+link$_toolchain_suffix", |
] |
} |
} |