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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 #
3 # Copyright 2015 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file.
6
7 import argparse
8 import os
9 import sys
10 import tempfile
11
12 from util import build_utils
13
14 sys.path.append(os.path.abspath(os.path.join(
15 os.path.dirname(__file__), os.pardir)))
16 from pylib import constants
17
18
19 def main():
20 parser = argparse.ArgumentParser()
21 parser.add_argument('--android-sdk-tools', required=True,
22 help='Android sdk build tools directory.')
23 parser.add_argument('--main-dex-rules-path', action='append', default=[],
24 dest='main_dex_rules_paths',
25 help='A file containing a list of proguard rules to use '
26 'in determining the class to include in the '
27 'main dex.')
28 parser.add_argument('--main-dex-list-path', required=True,
29 help='The main dex list file to generate.')
30 parser.add_argument('paths', nargs='+',
31 help='JARs for which a main dex list should be '
32 'generated.')
33
34 args = parser.parse_args()
35
36 with open(args.main_dex_list_path, 'w') as main_dex_list_file:
37
38 shrinked_android_jar = os.path.abspath(
39 os.path.join(args.android_sdk_tools, 'lib', 'shrinkedAndroid.jar'))
40 dx_jar = os.path.abspath(
41 os.path.join(args.android_sdk_tools, 'lib', 'dx.jar'))
42 paths_arg = ':'.join(args.paths)
43 rules_file = os.path.abspath(
44 os.path.join(args.android_sdk_tools, 'mainDexClasses.rules'))
45
46 with tempfile.NamedTemporaryFile(suffix='.jar') as temp_jar:
47 proguard_cmd = [
48 constants.PROGUARD_SCRIPT_PATH,
49 '-forceprocessing',
50 '-dontwarn', '-dontoptimize', '-dontobfuscate', '-dontpreverify',
51 '-injars', paths_arg,
52 '-outjars', temp_jar.name,
53 '-libraryjars', shrinked_android_jar,
54 '-include', rules_file,
55 ]
56 for m in args.main_dex_rules_paths:
57 proguard_cmd.extend(['-include', m])
58
59 main_dex_list = ''
60 try:
61 build_utils.CheckOutput(proguard_cmd)
62
63 java_cmd = [
64 'java', '-cp', dx_jar,
65 'com.android.multidex.MainDexListBuilder',
66 temp_jar.name, paths_arg
67 ]
68 main_dex_list = build_utils.CheckOutput(java_cmd)
69 except build_utils.CalledProcessError as e:
70 if 'output jar is empty' in e.output:
71 pass
72 elif "input doesn't contain any classes" in e.output:
73 pass
74 else:
75 raise
76
77 main_dex_list_file.write(main_dex_list)
78
79 return 0
80
81
82 if __name__ == '__main__':
83 sys.exit(main())
84
OLDNEW
« 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