Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3362)

Unified Diff: build/android/gyp/write_build_config.py

Issue 1433873004: GN: Enable proguard for apks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: build/android/gyp/write_build_config.py
diff --git a/build/android/gyp/write_build_config.py b/build/android/gyp/write_build_config.py
index 3b85cf5deb3bbded88bb24ba67f34106c906c61e..495c69938bee9934cc45a1b85cc07b9b182c81f3 100755
--- a/build/android/gyp/write_build_config.py
+++ b/build/android/gyp/write_build_config.py
@@ -192,6 +192,10 @@ def main(argv):
parser.add_option('--tested-apk-config',
help='Path to the build config of the tested apk (for an instrumentation '
'test apk).')
+ parser.add_option('--proguard-enabled', action='store_true',
+ help='Whether proguard is enabled for this apk.')
+ parser.add_option('--proguard-info',
+ help='Path to the proguard .info output for this apk.')
options, args = parser.parse_args(argv)
@@ -351,6 +355,17 @@ def main(argv):
if options.type in ['android_apk', 'deps_dex']:
deps_dex_files = [c['dex_path'] for c in all_library_deps]
+ proguard_enabled = options.proguard_enabled
+ if options.type == 'android_apk':
+ deps_info['proguard_enabled'] = proguard_enabled
+ if proguard_enabled:
+ deps_info['proguard_info'] = options.proguard_info
+ config['proguard'] = {}
+ proguard_config = config['proguard']
+ proguard_config['input_paths'] = [options.jar_path] + java_full_classpath
+ proguard_config['tested_apk_info'] = ''
+
+
# An instrumentation test apk should exclude the dex files that are in the apk
# under test.
if options.type == 'android_apk' and options.tested_apk_config:
@@ -364,12 +379,21 @@ def main(argv):
expected_tested_package = tested_apk_config['package_name']
AndroidManifest(options.android_manifest).CheckInstrumentation(
expected_tested_package)
+ if tested_apk_config['proguard_enabled']:
+ proguard_config['tested_apk_info'] = tested_apk_config['proguard_info']
+ assert proguard_enabled, ('proguard must be enabled for instrumentation'
+ ' apks if it\'s enabled for the tested apk')
+
newt (away) 2015/11/11 18:21:33 too many newlines
agrieve 2015/11/11 18:53:45 Done.
+
# Dependencies for the final dex file of an apk or a 'deps_dex'.
if options.type in ['android_apk', 'deps_dex']:
config['final_dex'] = {}
dex_config = config['final_dex']
- # TODO(cjhopman): proguard version
+ if proguard_enabled:
+ # When proguard is enabled, the proguarded jar contains the code for all
+ # of the dependencies.
+ deps_dex_files = []
dex_config['dependency_dex_files'] = deps_dex_files
if options.type == 'android_apk':

Powered by Google App Engine
This is Rietveld 408576698