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

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

Issue 2295363002: 🔔 Allow android_* targets to specify proguard flags for apks (Closed)
Patch Set: Created 4 years, 3 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 # 2 #
3 # Copyright 2013 The Chromium Authors. All rights reserved. 3 # Copyright 2013 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 import optparse 7 import optparse
8 import os 8 import os
9 import sys 9 import sys
10 10
(...skipping 11 matching lines...) Expand all
22 ] 22 ]
23 23
24 def _ParseOptions(args): 24 def _ParseOptions(args):
25 parser = optparse.OptionParser() 25 parser = optparse.OptionParser()
26 build_utils.AddDepfileOption(parser) 26 build_utils.AddDepfileOption(parser)
27 parser.add_option('--proguard-path', 27 parser.add_option('--proguard-path',
28 help='Path to the proguard executable.') 28 help='Path to the proguard executable.')
29 parser.add_option('--input-paths', 29 parser.add_option('--input-paths',
30 help='Paths to the .jar files proguard should run on.') 30 help='Paths to the .jar files proguard should run on.')
31 parser.add_option('--output-path', help='Path to the generated .jar file.') 31 parser.add_option('--output-path', help='Path to the generated .jar file.')
32 parser.add_option('--proguard-configs', 32 parser.add_option('--proguard-configs', action='append',
33 help='Paths to proguard configuration files.') 33 help='Paths to proguard configuration files.')
34 parser.add_option('--mapping', help='Path to proguard mapping to apply.') 34 parser.add_option('--mapping', help='Path to proguard mapping to apply.')
35 parser.add_option('--is-test', action='store_true', 35 parser.add_option('--is-test', action='store_true',
36 help='If true, extra proguard options for instrumentation tests will be ' 36 help='If true, extra proguard options for instrumentation tests will be '
37 'added.') 37 'added.')
38 parser.add_option('--tested-apk-info', help='Path to the proguard .info file ' 38 parser.add_option('--tested-apk-info', help='Path to the proguard .info file '
39 'for the tested apk') 39 'for the tested apk')
40 parser.add_option('--classpath', action='append', 40 parser.add_option('--classpath', action='append',
41 help='Classpath for proguard.') 41 help='Classpath for proguard.')
42 parser.add_option('--stamp', help='Path to touch on success.') 42 parser.add_option('--stamp', help='Path to touch on success.')
43 parser.add_option('--enable-dangerous-optimizations', action='store_true', 43 parser.add_option('--enable-dangerous-optimizations', action='store_true',
44 help='Enable optimizations which are known to have issues.') 44 help='Enable optimizations which are known to have issues.')
45 parser.add_option('--verbose', '-v', action='store_true', 45 parser.add_option('--verbose', '-v', action='store_true',
46 help='Print all proguard output') 46 help='Print all proguard output')
47 47
48 options, _ = parser.parse_args(args) 48 options, _ = parser.parse_args(args)
49 49
50 classpath = [] 50 classpath = []
51 for arg in options.classpath: 51 for arg in options.classpath:
52 classpath += build_utils.ParseGnList(arg) 52 classpath += build_utils.ParseGnList(arg)
53 options.classpath = classpath 53 options.classpath = classpath
54 54
55 configs = []
56 for arg in options.proguard_configs:
57 configs += build_utils.ParseGnList(arg)
58 options.proguard_configs = configs
59
60 options.input_paths = build_utils.ParseGnList(options.input_paths)
61
55 return options 62 return options
56 63
57 64
58 def main(args): 65 def main(args):
59 args = build_utils.ExpandFileArgs(args) 66 args = build_utils.ExpandFileArgs(args)
60 options = _ParseOptions(args) 67 options = _ParseOptions(args)
61 68
62 proguard = proguard_util.ProguardCmdBuilder(options.proguard_path) 69 proguard = proguard_util.ProguardCmdBuilder(options.proguard_path)
63 proguard.injars(build_utils.ParseGnList(options.input_paths)) 70 proguard.injars(options.input_paths)
64 proguard.configs(build_utils.ParseGnList(options.proguard_configs)) 71 proguard.configs(options.proguard_configs)
65 proguard.outjar(options.output_path) 72 proguard.outjar(options.output_path)
73 print options.proguard_configs
66 74
67 if options.mapping: 75 if options.mapping:
68 proguard.mapping(options.mapping) 76 proguard.mapping(options.mapping)
69 77
70 if options.tested_apk_info: 78 if options.tested_apk_info:
71 proguard.tested_apk_info(options.tested_apk_info) 79 proguard.tested_apk_info(options.tested_apk_info)
72 80
73 classpath = list(set(options.classpath)) 81 classpath = list(set(options.classpath))
74 proguard.libraryjars(classpath) 82 proguard.libraryjars(classpath)
75 proguard.verbose(options.verbose) 83 proguard.verbose(options.verbose)
76 if not options.enable_dangerous_optimizations: 84 if not options.enable_dangerous_optimizations:
77 proguard.disable_optimizations(_DANGEROUS_OPTIMIZATIONS) 85 proguard.disable_optimizations(_DANGEROUS_OPTIMIZATIONS)
78 86
79 input_paths = proguard.GetInputs() 87 input_paths = proguard.GetInputs()
80 88
81 build_utils.CallAndWriteDepfileIfStale( 89 build_utils.CallAndWriteDepfileIfStale(
82 proguard.CheckOutput, 90 proguard.CheckOutput,
83 options, 91 options,
84 input_paths=input_paths, 92 input_paths=input_paths,
85 input_strings=proguard.build(), 93 input_strings=proguard.build(),
86 output_paths=[options.output_path]) 94 output_paths=[options.output_path])
87 95
88 96
89 if __name__ == '__main__': 97 if __name__ == '__main__':
90 sys.exit(main(sys.argv[1:])) 98 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « no previous file | build/android/gyp/write_build_config.py » ('j') | build/android/gyp/write_build_config.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698