Commit eff98118 authored by xunjieli's avatar xunjieli Committed by Commit bot

[Cronet] add base proguard flags

This CL pulls in base's proguard flags when compiling
cronet_sample_apk and cronet_package.

Cronet will not need to duplicate proguard flags and can
benefit from base proguard file changes.

This saves about 1882 - 1471 = 411 methods from our dex
count for CronetSample.apk and 10kB(4.35%).

BUG=634998

Review-Url: https://codereview.chromium.org/2214013002
Cr-Commit-Position: refs/heads/master@{#417060}
parent 3c948f7a
......@@ -402,6 +402,7 @@ android_apk("cronet_sample_apk") {
proguard_configs = [
"proguard.cfg",
"sample/javatests/proguard.cfg",
"//base/android/base_proguard_config.flags",
]
}
}
......@@ -717,6 +718,7 @@ android_apk("cronet_perf_test_apk") {
proguard_configs = [
"proguard.cfg",
"test/javaperftests/proguard.cfg",
"//base/android/base_proguard_config.flags",
]
}
......@@ -901,7 +903,6 @@ copy("cronet_package_copy") {
"$root_out_dir/lib.java/components/cronet/android/cronet_api.jar",
"//AUTHORS",
"//chrome/VERSION",
"//components/cronet/android/proguard.cfg",
]
outputs = [
"$_package_dir/{{source_file_part}}",
......@@ -912,6 +913,20 @@ copy("cronet_package_copy") {
]
}
action("cronet_combine_proguard_flags") {
script = "//components/cronet/tools/generate_proguard_file.py"
outputs = [
"$_package_dir/proguard.cfg",
]
args = [
"--output-file",
rebase_path("$_package_dir/proguard.cfg", root_build_dir),
rebase_path("//base/android/base_proguard_config.flags", root_build_dir),
rebase_path("//components/cronet/android/proguard.cfg", root_build_dir),
]
}
copy("cronet_package_copy_native_lib") {
sources = [
"$root_out_dir/libcronet.so",
......@@ -963,6 +978,7 @@ group("cronet_package") {
# not including any deps in cronet_package target otherwise.
if (!(target_cpu == "arm" && arm_version == 7) || !arm_use_neon) {
deps = [
":cronet_combine_proguard_flags",
":cronet_package_copy",
":cronet_package_copy_native_lib",
":cronet_package_copy_native_lib_unstripped",
......
# Keep annotations used by chromium to keep members referenced by native code
-keep class org.chromium.base.annotations.*Native*
-keep class org.chromium.base.annotations.JNINamespace
-keepclasseswithmembers class org.chromium.** {
@org.chromium.base.annotations.AccessedByNative <fields>;
}
-keepclasseswithmembers class org.chromium.** {
@org.chromium.base.annotations.*Native* <methods>;
}
# TODO(mef) remove unnecessary classes from base, so we don't have to preserve
# their methods
-keepclasseswithmembers class org.chromium.** {
native <methods>;
}
# TODO(xunjieli): Find an alternative to explictly preserving public classes.
-keep public class org.chromium.net.*
-keep class org.chromium.net.impl.CronetUrlRequest$HeadersList
-keep class org.chromium.net.impl.ChromiumUrlRequest$ResponseHeadersMap
# Needed so that multiple optimization passes will detect annotations
-keepattributes *Annotation*
# Keep methods used by reflection
-keep class org.chromium.base.annotations.UsedByReflection
-keep @org.chromium.base.annotations.UsedByReflection class *
-keepclassmembers class * {
@org.chromium.base.annotations.UsedByReflection *;
}
# Suppress unnecessary warnings.
-dontnote org.chromium.net.ProxyChangeListener$ProxyReceiver
-dontnote org.chromium.net.AndroidKeyStore
......
......@@ -3,10 +3,5 @@
*;
}
# Test package uses classes from org.chromium.base.
-keep class org.chromium.base.** {
@**.VisibleForTesting *;
}
# TODO(jbudorick): Remove when crbug.com/488192 is fixed.
-dontwarn org.apache.http.**
#!/usr/bin/env python
#
# Copyright 2016 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.
import optparse
import sys
# Combines files in |input_files| as one proguard file and write that to
# |output_file|
def GenerateProguardFile(output_file, input_files):
try:
with open(output_file, "wb") as target:
for input_file in input_files:
f = open(input_file, "rb")
for line in f:
target.write(line)
except IOError:
raise Exception("Proguard file generation failed")
def main():
parser = optparse.OptionParser()
parser.add_option('--output-file',
help='Output file for the generated proguard file')
options, input_files = parser.parse_args()
GenerateProguardFile(options.output_file, input_files)
if __name__ == '__main__':
sys.exit(main())
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment