Revert of [Cronet] Build static libcronet.a for iOS with complete dependencies. (patchset #20 id:380001 of https://codereview.chromium.org/2807283002/ )
Reason for revert:
Broke official Cronet builders.
Original issue's description:
> [Cronet] Build static libcronet.a for iOS with complete dependencies.
>
> - Hide dependencies inside of the library to avoid symbol conflicts.
> - Add cronet_consumer_static target that builds consumer app with static library.
>
> BUG=721922
> CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.android:android_cronet_tester
>
> Review-Url: https://codereview.chromium.org/2807283002
> Cr-Commit-Position: refs/heads/master@{#475158}
> Committed: https://chromium.googlesource.com/chromium/src/+/3412c3c60b69798430b3a3cc9d2834f5d44e6042
TBR=ichikawa@chromium.org,kapishnikov@chromium.org,lilyhoughton@chromium.org,rsesek@chromium.org,jzw@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=721922
Review-Url: https://codereview.chromium.org/2907023002
Cr-Commit-Position: refs/heads/master@{#475247}
diff --git a/components/cronet/ios/BUILD.gn b/components/cronet/ios/BUILD.gn
index 8b8f4b1..716fa0b 100644
--- a/components/cronet/ios/BUILD.gn
+++ b/components/cronet/ios/BUILD.gn
@@ -32,61 +32,34 @@
]
}
-config("cronet_include_config") {
- include_dirs = [ "//components/grpc_support/include" ]
-}
-
-config("cronet_static_config") {
- libs = [
- "Cronet.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
+ 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",
+ ]
- sources = _cronet_sources
+ 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",
+ ]
include_dirs = [ "//components/grpc_support/include" ]
@@ -112,11 +85,17 @@
libs = [ "UIKit.Framework" ]
+ include_dirs = [ "//components/grpc_support/include" ]
+
public_deps = [
"//components/grpc_support",
]
- public_headers = _cronet_public_headers
+ public_headers = [
+ "Cronet.h",
+ "cronet_c_for_grpc.h",
+ ]
+ public_headers += grpc_public_headers
sources = [
"Cronet.h",
@@ -124,8 +103,6 @@
configs -= [ "//build/config/compiler:default_symbols" ]
configs += [ "//build/config/compiler:symbols" ]
-
- public_configs = [ ":cronet_include_config" ]
}
test("cronet_unittests") {
@@ -160,131 +137,6 @@
]
}
-# A static library which contains just _cronet_sources.
-static_library("cronet_static") {
- visibility = [ ":*" ]
- deps = _cronet_deps
- sources = _cronet_sources
- 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") {
- visibility = [ ":*" ]
- 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
-}
-
-template("ios_static_framework") {
- _target_name = target_name
- _output_name = target_name
- if (defined(invoker.output_name)) {
- _output_name = invoker.output_name
- }
- _framework_name = target_name
- if (defined(invoker.framework_name)) {
- _framework_name = invoker.framework_name
- }
-
- _bundle_target_name = _target_name + "_bundle"
- _framework_headers_target = _target_name + "_framework_headers"
- bundle_data(_framework_headers_target) {
- visibility = [ ":$_bundle_target_name" ]
- sources = invoker.public_headers
- outputs = [
- "{{bundle_root_dir}}/Headers/{{source_file_part}}",
- ]
- }
-
- _framework_binary_target = _target_name + "_framework_binary"
- _static_library_target = invoker.static_library_target
-
- bundle_data(_framework_binary_target) {
- visibility = [ ":$_bundle_target_name" ]
- sources = get_target_outputs(_static_library_target)
- outputs = [
- "{{bundle_root_dir}}/$_framework_name",
- ]
- public_deps = [
- _static_library_target,
- ]
- }
-
- create_bundle(_bundle_target_name) {
- product_type = "com.apple.product-type.framework"
- bundle_root_dir = "$root_out_dir/Static/$_output_name"
- bundle_executable_dir = bundle_root_dir
- bundle_resources_dir = bundle_root_dir
- bundle_plugins_dir = bundle_root_dir
- deps = [
- ":$_framework_binary_target",
- ":$_framework_headers_target",
- ]
- }
-
- action(_target_name) {
- script = "//components/cronet/tools/dummy.py"
- outputs = [
- "$root_out_dir/Static/$_output_name",
- ]
- deps = [
- ":$_bundle_target_name",
- ]
- public_configs = invoker.public_configs
- }
-}
-
-ios_static_framework("cronet_static_framework") {
- output_name = "Cronet.framework"
- framework_name = "Cronet"
- public_headers = _cronet_public_headers
- static_library_target = ":libcronet"
- public_configs = [ ":cronet_static_config" ]
-}
-
if (additional_toolchains == [] || current_toolchain == default_toolchain) {
_package_dir = "$root_out_dir/cronet"
@@ -308,19 +160,6 @@
]
}
- copy("cronet_static_copy") {
- sources = [
- "$root_out_dir/Static/Cronet.framework",
- ]
- outputs = [
- "$_package_dir/Static/Cronet.framework",
- ]
-
- deps = [
- ":cronet_static_framework",
- ]
- }
-
copy("cronet_package_copy") {
sources = [
"$root_out_dir/Cronet.framework",
@@ -333,7 +172,6 @@
deps = [
":cronet_framework",
- ":cronet_static_copy",
]
}
diff --git a/components/cronet/ios/cronet_consumer/BUILD.gn b/components/cronet/ios/cronet_consumer/BUILD.gn
index 219318c..966057c 100644
--- a/components/cronet/ios/cronet_consumer/BUILD.gn
+++ b/components/cronet/ios/cronet_consumer/BUILD.gn
@@ -3,61 +3,28 @@
# found in the LICENSE file.
import("//build/config/ios/rules.gni")
-import("//ios/features.gni")
-template("cronet_consumer_template") {
- _target_name = target_name
+ios_app_bundle("cronet_consumer") {
+ info_plist = "cronet-consumer-Info.plist"
- ios_app_bundle(_target_name) {
- info_plist = "cronet-consumer-Info.plist"
-
- deps = [
- "//base:base",
- ]
-
- deps += invoker.deps
-
- sources = [
- "cronet_consumer_app_delegate.h",
- "cronet_consumer_app_delegate.mm",
- "cronet_consumer_view_controller.h",
- "cronet_consumer_view_controller.m",
- "main.mm",
- ]
-
- forward_variables_from(invoker,
- [
- "bundle_deps",
- "cflags",
- "ldflags",
- ])
-
- configs += [ "//build/config/compiler:enable_arc" ]
- }
-}
-
-cronet_consumer_template("cronet_consumer") {
deps = [
+ "//base:base",
"//components/cronet/ios:cronet_framework+link",
+
+ # All shared libraries must have the sanitizer deps to properly link in
+ # asan mode (this target will be empty in other cases).
+ "//build/config:exe_and_shlib_deps",
]
+
+ sources = [
+ "cronet_consumer_app_delegate.h",
+ "cronet_consumer_app_delegate.mm",
+ "cronet_consumer_view_controller.h",
+ "cronet_consumer_view_controller.m",
+ "main.mm",
+ ]
+
bundle_deps = [ "//components/cronet/ios:cronet_framework+bundle" ]
-}
-# TODO(mef): Figure out why CronetConsumerStatic breaks build on non-Cronet builders.
-if (is_cronet_build) {
- cronet_consumer_template("cronet_consumer_static") {
- deps = [
- "//components/cronet/ios:cronet_static_framework",
- ]
-
- cflags = [
- "-F",
- "Static",
- ]
-
- ldflags = [
- "-F",
- "Static",
- ]
- }
+ configs += [ "//build/config/compiler:enable_arc" ]
}
diff --git a/components/cronet/tools/dummy.py b/components/cronet/tools/dummy.py
deleted file mode 100755
index a216b12..0000000
--- a/components/cronet/tools/dummy.py
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/usr/bin/python
-# Copyright 2017 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-"""Provides empty action to expose static framwork output from subdirectory.
-"""
diff --git a/components/cronet/tools/hide_symbols.py b/components/cronet/tools/hide_symbols.py
deleted file mode 100755
index 55e7fb8..0000000
--- a/components/cronet/tools/hide_symbols.py
+++ /dev/null
@@ -1,101 +0,0 @@
-#!/usr/bin/env python
-
-# Copyright 2017 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-# Create a static library which exposes only symbols which are explicitly marked
-# as visible e.g., by __attribute__((visibility("default"))).
-#
-# See BUILD.gn in this directory for usage example.
-#
-# This way, we can reduce risk of symbol conflict when linking it into apps
-# by exposing internal symbols, especially in third-party libraries.
-
-import optparse
-import os
-import subprocess
-
-
-# Mapping from GN's target_cpu attribute to ld's -arch parameter.
-# Taken from the definition of config("compiler") in:
-# //build/config/mac/BUILD.gn
-GN_CPU_TO_LD_ARCH = {
- 'x64': 'x86_64',
- 'x86': 'i386',
- 'armv7': 'armv7',
- 'arm': 'armv7',
- 'arm64': 'arm64',
-}
-
-
-def main():
- parser = optparse.OptionParser()
- parser.add_option(
- '--input_libs',
- help='Comma-separated paths to input .a files which contain symbols '
- 'which must be always linked.')
- parser.add_option(
- '--deps_lib',
- help='The path to a complete static library (.a file) which contains all '
- 'dependencies of --input_libs. .o files in this library are also '
- 'added to the output library, but only if they are referred from '
- '--input_libs.')
- parser.add_option(
- '--output_obj',
- help='Outputs the generated .o file here. This is an intermediate file.')
- parser.add_option(
- '--output_lib',
- help='Outputs the generated .a file here.')
- parser.add_option(
- '--current_cpu',
- help='The current processor architecture in the format of the target_cpu '
- 'attribute in GN.')
- (options, args) = parser.parse_args()
- assert not args
-
- # ld -r concatenates multiple .o files and .a files into a single .o file,
- # while "hiding" symbols not marked as visible.
- command = [
- 'xcrun', 'ld',
- '-arch', GN_CPU_TO_LD_ARCH[options.current_cpu],
- '-r',
- ]
- for input_lib in options.input_libs.split(','):
- # By default, ld only pulls .o files out of a static library if needed to
- # resolve some symbol reference. We apply -force_load option to input_lib
- # (but not to deps_lib) to force pulling all .o files.
- command += ['-force_load', input_lib]
- command += [
- options.deps_lib,
- '-o', options.output_obj
- ]
- try:
- subprocess.check_call(command)
- except subprocess.CalledProcessError:
- # Work around LD failure for x86 Debug buiilds when it fails with error:
- # ld: scattered reloc r_address too large for architecture i386
- if options.current_cpu == "x86":
- # Combmine input lib with dependencies into output lib.
- command = [
- 'xcrun', 'libtool', '-static', '-no_warning_for_no_symbols',
- '-o', options.output_lib,
- options.input_libs, options.deps_lib,
- ]
- subprocess.check_call(command)
- return
-
- if os.path.exists(options.output_lib):
- os.remove(options.output_lib)
-
- # Creates a .a file which contains a single .o file.
- command = [
- 'xcrun', 'ar', '-r',
- options.output_lib,
- options.output_obj,
- ]
- subprocess.check_call(command)
-
-
-if __name__ == "__main__":
- main()
diff --git a/components/cronet/tools/package_ios.py b/components/cronet/tools/package_ios.py
index 6fd3220..956d545 100755
--- a/components/cronet/tools/package_ios.py
+++ b/components/cronet/tools/package_ios.py
@@ -117,13 +117,10 @@
# Copy framework.
shutil.copytree(os.path.join(build_dir, 'Cronet.framework'),
- os.path.join(out_dir, 'Dynamic', target_dir, 'Cronet.framework'))
+ os.path.join(out_dir, target_dir, 'Cronet.framework'))
# Copy symbols.
shutil.copytree(os.path.join(build_dir, 'Cronet.dSYM'),
- os.path.join(out_dir, 'Dynamic', target_dir, 'Cronet.framework.dSYM'))
- # Copy static framework.
- shutil.copytree(os.path.join(build_dir, 'Static', 'Cronet.framework'),
- os.path.join(out_dir, 'Static', target_dir, 'Cronet.framework'))
+ os.path.join(out_dir, target_dir, 'Cronet.framework.dSYM'))
# Copy common files from last built package.
package_dir = os.path.join(build_dir, 'cronet')
@@ -134,7 +131,7 @@
shutil.copytree(os.path.join(build_dir,
'Cronet.framework', 'Headers'),
os.path.join(out_dir, 'Headers'))
- print 'Cronet framework is packaged into %s' % out_dir
+ print 'Cronet dynamic framework is packaged into %s' % out_dir
def main():