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

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

Issue 1587253003: Revert of [Android] Rework multidex and enable multidex for unit_tests_apk. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
10 import sys 9 import sys
11 10
12 from util import build_utils 11 from util import build_utils
13 12
14 13
15 _GCC_PREPROCESS_PATH = os.path.join(
16 os.path.dirname(__file__), 'gcc_preprocess.py')
17
18
19 def ParseArgs(): 14 def ParseArgs():
20 parser = argparse.ArgumentParser() 15 parser = argparse.ArgumentParser()
21 parser.add_argument('--configuration-name', required=True, 16 parser.add_argument('--configuration-name', required=True,
22 help='The build CONFIGURATION_NAME.') 17 help='The build CONFIGURATION_NAME.')
23 parser.add_argument('--enable-multidex', action='store_true', default=False,
24 help='If passed, multidex may be enabled.')
25 parser.add_argument('--enabled-configurations', default=[], 18 parser.add_argument('--enabled-configurations', default=[],
26 help='The configuration(s) for which multidex should be ' 19 help='The configuration(s) for which multidex should be '
27 'enabled. If not specified and --enable-multidex is ' 20 'enabled. If not specified and --enable-multidex is '
28 'passed, multidex will be enabled for all ' 21 'passed, multidex will be enabled for all '
29 'configurations.') 22 'configurations.')
30 parser.add_argument('--multidex-configuration-path', required=True, 23 parser.add_argument('--multidex-configuration-path', required=True,
31 help='The path to which the multidex configuration JSON ' 24 help='The path to which the multidex configuration JSON '
32 'should be saved.') 25 '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)
36 26
37 args = parser.parse_args() 27 args = parser.parse_args()
38 28
39 if args.enabled_configurations: 29 if args.enabled_configurations:
40 args.enabled_configurations = build_utils.ParseGypList( 30 args.enabled_configurations = build_utils.ParseGypList(
41 args.enabled_configurations) 31 args.enabled_configurations)
42 32
43 return args 33 return args
44 34
45 35
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
71 def main(): 36 def main():
72 args = ParseArgs() 37 args = ParseArgs()
73 38
74 multidex_enabled = ( 39 multidex_enabled = (
75 args.enable_multidex 40 (not args.enabled_configurations
76 and (not args.enabled_configurations 41 or args.configuration_name in args.enabled_configurations))
77 or args.configuration_name in args.enabled_configurations))
78 42
79 _WriteConfigJson(multidex_enabled, args.multidex_configuration_path) 43 config = {
80 _GenerateMultidexConfigJava(multidex_enabled, args) 44 'enabled': multidex_enabled,
45 }
46
47 with open(args.multidex_configuration_path, 'w') as f:
48 f.write(json.dumps(config))
81 49
82 return 0 50 return 0
83 51
84 52
85 if __name__ == '__main__': 53 if __name__ == '__main__':
86 sys.exit(main()) 54 sys.exit(main())
87 55
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698