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

Side by Side Diff: build/android/gyp/configure_multidex.py

Issue 1581563003: [Android] Rework multidex and enable multidex for unit_tests_apk. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix junit tests Created 4 years, 11 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
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2015 The Chromium Authors. All rights reserved. 2 # Copyright 2015 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 6
7 import argparse 7 import argparse
8 import json 8 import json
9 import os
9 import sys 10 import sys
10 11
11 from util import build_utils 12 from util import build_utils
12 13
13 14
15 _GCC_PREPROCESS_PATH = os.path.join(
16 os.path.dirname(__file__), 'gcc_preprocess.py')
17
18
14 def ParseArgs(): 19 def ParseArgs():
15 parser = argparse.ArgumentParser() 20 parser = argparse.ArgumentParser()
16 parser.add_argument('--configuration-name', required=True, 21 parser.add_argument('--configuration-name', required=True,
17 help='The build CONFIGURATION_NAME.') 22 help='The build CONFIGURATION_NAME.')
23 parser.add_argument('--enable-multidex', action='store_true', default=False,
24 help='If passed, multidex may be enabled.')
18 parser.add_argument('--enabled-configurations', default=[], 25 parser.add_argument('--enabled-configurations', default=[],
19 help='The configuration(s) for which multidex should be ' 26 help='The configuration(s) for which multidex should be '
20 'enabled. If not specified and --enable-multidex is ' 27 'enabled. If not specified and --enable-multidex is '
21 'passed, multidex will be enabled for all ' 28 'passed, multidex will be enabled for all '
22 'configurations.') 29 'configurations.')
23 parser.add_argument('--multidex-configuration-path', required=True, 30 parser.add_argument('--multidex-configuration-path', required=True,
24 help='The path to which the multidex configuration JSON ' 31 help='The path to which the multidex configuration JSON '
25 'should be saved.') 32 'should be saved.')
33 parser.add_argument('--multidex-config-java-file', required=True)
34 parser.add_argument('--multidex-config-java-stamp', required=True)
35 parser.add_argument('--multidex-config-java-template', required=True)
26 36
27 args = parser.parse_args() 37 args = parser.parse_args()
28 38
29 if args.enabled_configurations: 39 if args.enabled_configurations:
30 args.enabled_configurations = build_utils.ParseGypList( 40 args.enabled_configurations = build_utils.ParseGypList(
31 args.enabled_configurations) 41 args.enabled_configurations)
32 42
33 return args 43 return args
34 44
35 45
46 def _WriteConfigJson(multidex_enabled, multidex_configuration_path):
47 config = {
48 'enabled': multidex_enabled,
49 }
50
51 with open(multidex_configuration_path, 'w') as f:
52 f.write(json.dumps(config))
53
54
55 def _GenerateMultidexConfigJava(multidex_enabled, args):
56 gcc_preprocess_cmd = [
57 sys.executable, _GCC_PREPROCESS_PATH,
58 '--include-path=',
59 '--template', args.multidex_config_java_template,
60 '--stamp', args.multidex_config_java_stamp,
61 '--output', args.multidex_config_java_file,
62 ]
63 if multidex_enabled:
64 gcc_preprocess_cmd += [
65 '--defines', 'ENABLE_MULTIDEX',
66 ]
67
68 build_utils.CheckOutput(gcc_preprocess_cmd)
69
70
36 def main(): 71 def main():
37 args = ParseArgs() 72 args = ParseArgs()
38 73
39 multidex_enabled = ( 74 multidex_enabled = (
40 (not args.enabled_configurations 75 args.enable_multidex
41 or args.configuration_name in args.enabled_configurations)) 76 and (not args.enabled_configurations
77 or args.configuration_name in args.enabled_configurations))
42 78
43 config = { 79 _WriteConfigJson(multidex_enabled, args.multidex_configuration_path)
44 'enabled': multidex_enabled, 80 _GenerateMultidexConfigJava(multidex_enabled, args)
45 }
46
47 with open(args.multidex_configuration_path, 'w') as f:
48 f.write(json.dumps(config))
49 81
50 return 0 82 return 0
51 83
52 84
53 if __name__ == '__main__': 85 if __name__ == '__main__':
54 sys.exit(main()) 86 sys.exit(main())
55 87
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698