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

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

Issue 1318513003: [Android] Add gyp support for multidex. (RELAND) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add @VisibleForTesting to ChromiumMultiDex.install Created 5 years, 4 months 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
« no previous file with comments | « build/android/gyp/dex.py ('k') | build/android/main_dex_action.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/gyp/main_dex_list.py
diff --git a/build/android/gyp/main_dex_list.py b/build/android/gyp/main_dex_list.py
new file mode 100755
index 0000000000000000000000000000000000000000..64420019eb905f6e5318837e32ad95ca908ddd83
--- /dev/null
+++ b/build/android/gyp/main_dex_list.py
@@ -0,0 +1,84 @@
+#!/usr/bin/env python
+#
+# Copyright 2015 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 argparse
+import os
+import sys
+import tempfile
+
+from util import build_utils
+
+sys.path.append(os.path.abspath(os.path.join(
+ os.path.dirname(__file__), os.pardir)))
+from pylib import constants
+
+
+def main():
+ parser = argparse.ArgumentParser()
+ parser.add_argument('--android-sdk-tools', required=True,
+ help='Android sdk build tools directory.')
+ parser.add_argument('--main-dex-rules-path', action='append', default=[],
+ dest='main_dex_rules_paths',
+ help='A file containing a list of proguard rules to use '
+ 'in determining the class to include in the '
+ 'main dex.')
+ parser.add_argument('--main-dex-list-path', required=True,
+ help='The main dex list file to generate.')
+ parser.add_argument('paths', nargs='+',
+ help='JARs for which a main dex list should be '
+ 'generated.')
+
+ args = parser.parse_args()
+
+ with open(args.main_dex_list_path, 'w') as main_dex_list_file:
+
+ shrinked_android_jar = os.path.abspath(
+ os.path.join(args.android_sdk_tools, 'lib', 'shrinkedAndroid.jar'))
+ dx_jar = os.path.abspath(
+ os.path.join(args.android_sdk_tools, 'lib', 'dx.jar'))
+ paths_arg = ':'.join(args.paths)
+ rules_file = os.path.abspath(
+ os.path.join(args.android_sdk_tools, 'mainDexClasses.rules'))
+
+ with tempfile.NamedTemporaryFile(suffix='.jar') as temp_jar:
+ proguard_cmd = [
+ constants.PROGUARD_SCRIPT_PATH,
+ '-forceprocessing',
+ '-dontwarn', '-dontoptimize', '-dontobfuscate', '-dontpreverify',
+ '-injars', paths_arg,
+ '-outjars', temp_jar.name,
+ '-libraryjars', shrinked_android_jar,
+ '-include', rules_file,
+ ]
+ for m in args.main_dex_rules_paths:
+ proguard_cmd.extend(['-include', m])
+
+ main_dex_list = ''
+ try:
+ build_utils.CheckOutput(proguard_cmd)
+
+ java_cmd = [
+ 'java', '-cp', dx_jar,
+ 'com.android.multidex.MainDexListBuilder',
+ temp_jar.name, paths_arg
+ ]
+ main_dex_list = build_utils.CheckOutput(java_cmd)
+ except build_utils.CalledProcessError as e:
+ if 'output jar is empty' in e.output:
+ pass
+ elif "input doesn't contain any classes" in e.output:
+ pass
+ else:
+ raise
+
+ main_dex_list_file.write(main_dex_list)
+
+ return 0
+
+
+if __name__ == '__main__':
+ sys.exit(main())
+
« no previous file with comments | « build/android/gyp/dex.py ('k') | build/android/main_dex_action.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698