diff options
author | cjhopman@chromium.org <cjhopman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-14 19:51:58 +0000 |
---|---|---|
committer | cjhopman@chromium.org <cjhopman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-14 19:51:58 +0000 |
commit | 9d20d7d94e5e3ee442be84c3ed7290e57bcba75e (patch) | |
tree | 39859f66f4d8f10a929e2cd100ae69cd60839bcf /build/java_apk.gypi | |
parent | 80d1a1a649c151aa924ea7efb4738cb193791a71 (diff) | |
download | chromium_src-9d20d7d94e5e3ee442be84c3ed7290e57bcba75e.zip chromium_src-9d20d7d94e5e3ee442be84c3ed7290e57bcba75e.tar.gz chromium_src-9d20d7d94e5e3ee442be84c3ed7290e57bcba75e.tar.bz2 |
Make test apks only dex files not in tested apk (proguard version)
At runtime, the classloader will look for classes in both apk's dex
files. In the standard Android build system, an instrumentation test
apk's dex file does not include the classes included in the tested apk's
dex file.
To do this, when doing obfuscation for an apk, write the list of
libraries included in the obfuscated jar and the list of proguard config
files. Then, when proguarding the test apk's code, exclude those
libraries included in the tested apk, use the configs from the tested
apk, and apply the proguard mapping (the renames from obfuscation). Also
add some extra test-specific proguard options.
Now that the test apk does not bundle its own copy of all the tested
apk's classes, some things may need to be kept in the main apk just for
tests. However, we already keep everything in org.chromium.** and
com.google.android.apps.** because of the fact that the test apk was
using its own copy of all the classes and so we couldn't depend on the
tests to actually catch us from over-optimizing with proguard.
BUG=272790
Review URL: https://codereview.chromium.org/321883002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@277257 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'build/java_apk.gypi')
-rw-r--r-- | build/java_apk.gypi | 39 |
1 files changed, 31 insertions, 8 deletions
diff --git a/build/java_apk.gypi b/build/java_apk.gypi index 348ce81..92c8cfa 100644 --- a/build/java_apk.gypi +++ b/build/java_apk.gypi @@ -52,6 +52,7 @@ # never_lint - Set to 1 to not run lint on this target. { 'variables': { + 'tested_apk_obfuscated_jar_path%': '/', 'tested_apk_dex_path%': '/', 'additional_input_paths': [], 'input_jars_paths': [], @@ -158,8 +159,16 @@ # direct_dependent_settings, but a variable set by a direct_dependent_settings # cannot be lifted in a dependent to all_dependent_settings. 'all_dependent_settings': { + 'conditions': [ + ['proguard_enabled == "true"', { + 'variables': { + 'proguard_enabled': 'true', + } + }], + ], 'variables': { 'apk_output_jar_path': '<(jar_path)', + 'tested_apk_obfuscated_jar_path': '<(obfuscated_jar_path)', 'tested_apk_dex_path': '<(dex_path)', }, }, @@ -604,23 +613,36 @@ 'message': 'Obfuscating <(_target_name)', 'variables': { 'additional_obfuscate_options': [], + 'additional_obfuscate_input_paths': [], 'proguard_out_dir': '<(intermediate_dir)/proguard', 'proguard_input_jar_paths': [ '>@(input_jars_paths)', '<(jar_path)', ], - 'conditions': [ + 'target_conditions': [ ['is_test_apk == 1', { 'additional_obfuscate_options': [ '--testapp', ], }], + ['is_test_apk == 1 and tested_apk_obfuscated_jar_path != "/"', { + 'additional_obfuscate_options': [ + '--tested-apk-obfuscated-jar-path', '>(tested_apk_obfuscated_jar_path)', + ], + 'additional_obfuscate_input_paths': [ + '>(tested_apk_obfuscated_jar_path).info', + ], + }], ['proguard_enabled == "true"', { 'additional_obfuscate_options': [ '--proguard-enabled', ], }], ], + 'obfuscate_input_jars_paths': [ + '>@(input_jars_paths)', + '<(jar_path)', + ], }, 'conditions': [ ['is_test_apk == 1', { @@ -633,15 +655,16 @@ '<(DEPTH)/build/android/gyp/apk_obfuscate.py', '<(DEPTH)/build/android/gyp/util/build_utils.py', '>@(proguard_flags_paths)', - '>@(proguard_input_jar_paths)', + '>@(obfuscate_input_jars_paths)', + '>@(additional_obfuscate_input_paths)', + '<(instr_stamp)', ], 'outputs': [ - # This lists obfuscate_stamp instead of obfuscated_jar_path because - # ant only writes the latter if the md5 of the inputs changes. '<(obfuscate_stamp)', # In non-Release builds, these paths will all be empty files. '<(obfuscated_jar_path)', + '<(obfuscated_jar_path).info', '<(obfuscated_jar_path).dump', '<(obfuscated_jar_path).seeds', '<(obfuscated_jar_path).mapping', @@ -657,15 +680,17 @@ '--android-sdk-jar', '<(android_sdk_jar)', '--input-jars-paths=>(proguard_input_jar_paths)', + '--proguard-configs=>(proguard_flags_paths)', + + '--test-jar-path', '<(test_jar_path)', '--obfuscated-jar-path', '<(obfuscated_jar_path)', '--proguard-jar-path', '<(android_sdk_root)/tools/proguard/lib/proguard.jar', - '--proguard-config-files=<(proguard_flags_paths)', '--stamp', '<(obfuscate_stamp)', - '<@(additional_obfuscate_options)', + '>@(additional_obfuscate_options)', ], }, { @@ -695,8 +720,6 @@ '>(tested_apk_dex_path).inputs', ], }], - ], - 'conditions': [ ['proguard_enabled == "true"', { 'inputs': [ '<(obfuscate_stamp)' ] }, { |