Index: components/cronet/ios/BUILD.gn |
diff --git a/components/cronet/ios/BUILD.gn b/components/cronet/ios/BUILD.gn |
index 716fa0b47ef7212d96362b7236a846d969a6b4b2..9bafa01229275db47cb48df55d538b422d2d726d 100644 |
--- a/components/cronet/ios/BUILD.gn |
+++ b/components/cronet/ios/BUILD.gn |
@@ -32,34 +32,61 @@ process_version("cronet_version_header") { |
] |
} |
-source_set("cronet_sources") { |
- deps = [ |
- ":cronet_version_header", |
- ":generate_accept_languages", |
- "//base:base", |
- "//components/grpc_support", |
- "//components/metrics:metrics", |
- "//components/metrics/proto:proto", |
- "//components/prefs:prefs", |
- "//ios/net:net", |
- "//ios/web:user_agent", |
- "//net", |
- "//url", |
- ] |
+config("cronet_include_config") { |
+ include_dirs = [ "//components/grpc_support/include" ] |
+} |
- sources = [ |
- "../histogram_manager.cc", |
- "../histogram_manager.h", |
- "../stale_host_resolver.cc", |
- "../stale_host_resolver.h", |
- "../url_request_context_config.cc", |
- "../url_request_context_config.h", |
- "Cronet.h", |
- "Cronet.mm", |
- "cronet_c_for_grpc.h", |
- "cronet_environment.h", |
- "cronet_environment.mm", |
+config("cronet_static_config") { |
+ libs = [ |
+ "CronetStatic.framework", |
+ "UIKit.Framework", |
+ "CFNetwork.framework", |
+ "MobileCoreServices.framework", |
+ "Security.framework", |
+ "SystemConfiguration.framework", |
+ "resolv", |
] |
+ configs = [ ":cronet_include_config" ] |
+} |
+ |
+_cronet_deps = [ |
+ ":cronet_version_header", |
+ ":generate_accept_languages", |
+ "//base:base", |
+ "//components/grpc_support", |
+ "//components/metrics:metrics", |
+ "//components/metrics/proto:proto", |
+ "//components/prefs:prefs", |
+ "//ios/net:net", |
+ "//ios/web:user_agent", |
+ "//net", |
+ "//url", |
+] |
+ |
+_cronet_sources = [ |
+ "../histogram_manager.cc", |
+ "../histogram_manager.h", |
+ "../stale_host_resolver.cc", |
+ "../stale_host_resolver.h", |
+ "../url_request_context_config.cc", |
+ "../url_request_context_config.h", |
+ "Cronet.h", |
+ "Cronet.mm", |
+ "cronet_c_for_grpc.h", |
+ "cronet_environment.h", |
+ "cronet_environment.mm", |
+] |
+ |
+_cronet_public_headers = [ |
+ "Cronet.h", |
+ "cronet_c_for_grpc.h", |
+] |
+_cronet_public_headers += grpc_public_headers |
+ |
+source_set("cronet_sources") { |
+ deps = _cronet_deps |
+ |
+ sources = _cronet_sources |
include_dirs = [ "//components/grpc_support/include" ] |
@@ -85,17 +112,11 @@ ios_framework_bundle("cronet_framework") { |
libs = [ "UIKit.Framework" ] |
- include_dirs = [ "//components/grpc_support/include" ] |
- |
public_deps = [ |
"//components/grpc_support", |
] |
- public_headers = [ |
- "Cronet.h", |
- "cronet_c_for_grpc.h", |
- ] |
- public_headers += grpc_public_headers |
+ public_headers = _cronet_public_headers |
sources = [ |
"Cronet.h", |
@@ -103,6 +124,8 @@ ios_framework_bundle("cronet_framework") { |
configs -= [ "//build/config/compiler:default_symbols" ] |
configs += [ "//build/config/compiler:symbols" ] |
+ |
+ public_configs = [ ":cronet_include_config" ] |
} |
test("cronet_unittests") { |
@@ -137,6 +160,132 @@ action("generate_accept_languages") { |
] |
} |
+# A static library which contains just _cronet_sources. |
+static_library("cronet_static") { |
+ deps = _cronet_deps |
+ |
+ sources = _cronet_sources |
+ |
+ visibility = [ ":*" ] |
+ |
+ public_configs = [ ":cronet_include_config" ] |
+ |
+ public_deps = [ |
+ "//components/grpc_support", |
+ ] |
+} |
+ |
+# A static library which contains all dependencies of :cronet_static. |
+static_library("cronet_deps_complete") { |
+ visibility = [ ":*" ] |
+ complete_static_lib = true |
+ deps = [ |
+ ":cronet_static", |
+ ] |
+} |
+ |
+# A static library which contains cronet and all dependendencies hidden inside. |
+action("cronet_static_complete") { |
+ script = "//components/cronet/tools/hide_symbols.py" |
+ deps = [ |
+ ":cronet_deps_complete", |
+ ":cronet_static", |
+ ] |
+ outputs = [ |
+ "$target_out_dir/$current_cpu/cronet_static_complete.a", |
+ ] |
+ args = [ |
+ "--input_libs", |
+ rebase_path("$target_out_dir/libcronet_static.a", root_build_dir), |
+ "--deps_lib", |
+ rebase_path("$target_out_dir/libcronet_deps_complete.a", root_build_dir), |
+ "--output_obj", |
+ rebase_path("$target_out_dir/$current_cpu/cronet_static_complete.o", |
+ root_build_dir), |
+ "--output_lib", |
+ rebase_path("$target_out_dir/$current_cpu/cronet_static_complete.a", |
+ root_build_dir), |
+ "--current_cpu", |
+ current_cpu, |
+ ] |
+ |
+ public_configs = [ ":cronet_static_config" ] |
+} |
+ |
+# A fat static library which exports cronet public symbols and hides all dependendencies. |
+lipo_binary("libcronet") { |
+ arch_binary_target = ":cronet_static_complete" |
+ arch_binary_output = "cronet_static_complete.a" |
+ output_name = "libcronet.a" |
+ enable_stripping = false |
+ enable_dsyms = false |
+} |
+ |
+bundle_data("cronet_static_headers") { |
+ sources = _cronet_public_headers |
+ outputs = [ |
+ "{{bundle_root_dir}}/Headers/{{source_file_part}}", |
+ ] |
+} |
+ |
+bundle_data("cronet_static_binary") { |
+ sources = get_target_outputs(":libcronet") |
+ outputs = [ |
+ "{{bundle_root_dir}}/Cronet", |
kapishnikov
2017/05/23 21:37:46
Can we somehow parameterize the binary name? Targe
mef
2017/05/24 21:36:59
Done.
|
+ ] |
+ public_deps = [ |
+ ":libcronet", |
+ ] |
+} |
+ |
+template("ios_static_framework") { |
+ _target_name = target_name |
+ _output_name = target_name |
+ if (defined(invoker.output_name)) { |
+ _output_name = invoker.output_name |
+ } |
+ _has_public_headers = |
+ defined(invoker.public_headers) && invoker.public_headers != [] |
+ _has_public_headers = defined(public_headers) && public_headers != [] |
+ |
+ #_default_toolchain_root_out_dir = |
+ # get_label_info("$_target_name($default_toolchain)", "root_out_dir") |
kapishnikov
2017/05/23 21:37:46
Should remove it before submitting if it is not ne
mef
2017/05/24 21:36:59
Done.
|
+ |
+ if (_has_public_headers) { |
+ _framework_headers_target = _target_name + "_framework_headers" |
+ _framework_headers_config = _target_name + "_framework_headers_config" |
+ config(_framework_headers_config) { |
+ # The link settings are inherited from the framework_bundle config. |
+ cflags = [ |
+ "-F", |
+ rebase_path("$_default_toolchain_root_out_dir/.", root_build_dir), |
+ ] |
+ } |
+ |
+ _headers_map_config = _target_name + "_headers_map" |
+ _header_map_filename = |
+ "$_default_toolchain_target_gen_dir/$_output_name.headers.hmap" |
+ config(_headers_map_config) { |
+ visibility = [ ":$_target_name" ] |
+ include_dirs = [ _header_map_filename ] |
+ } |
+ } |
+ |
+ create_bundle(_target_name) { |
+ bundle_root_dir = "$root_out_dir/$_output_name" |
+ deps = invoker.deps |
+ } |
+} |
+ |
+ios_static_framework("cronet_static_framework") { |
+ # bundle_root_dir = "$root_out_dir/CronetStatic.framework" |
kapishnikov
2017/05/23 21:37:46
Remove it if it is not needed.
mef
2017/05/24 21:36:59
Done.
|
+ output_name = "CronetStatic.framework" |
+ deps = [ |
+ ":cronet_static_binary", |
+ ":cronet_static_headers", |
+ ] |
+} |
+ |
if (additional_toolchains == [] || current_toolchain == default_toolchain) { |
_package_dir = "$root_out_dir/cronet" |
@@ -163,6 +312,8 @@ if (additional_toolchains == [] || current_toolchain == default_toolchain) { |
copy("cronet_package_copy") { |
sources = [ |
"$root_out_dir/Cronet.framework", |
+ "$root_out_dir/CronetStatic.framework", |
+ "$target_out_dir/libcronet.a", |
"//AUTHORS", |
"//chrome/VERSION", |
] |
@@ -172,6 +323,8 @@ if (additional_toolchains == [] || current_toolchain == default_toolchain) { |
deps = [ |
":cronet_framework", |
+ ":cronet_static_framework", |
+ ":libcronet", |
] |
} |