Add support for prebuilt jars
[chromium-blink-merge.git] / build / android / gyp / proguard.py
blobca5877051be72630c44cda7eeb54920db6722bbf
1 #!/usr/bin/env python
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
5 # found in the LICENSE file.
7 import optparse
8 import os
9 import sys
11 from util import build_utils
13 def DoProguard(options):
14 injars = options.input_path
15 outjars = options.output_path
16 classpath = []
17 for arg in options.classpath:
18 classpath += build_utils.ParseGypList(arg)
19 classpath = list(set(classpath))
20 libraryjars = ':'.join(classpath)
21 # proguard does its own dependency checking, which can be avoided by deleting
22 # the output.
23 if os.path.exists(options.output_path):
24 os.remove(options.output_path)
25 proguard_cmd = ['java', '-jar',
26 options.proguard_path,
27 '-injars', injars,
28 '-outjars', outjars,
29 '-libraryjars', libraryjars,
30 '@' + options.proguard_config]
31 build_utils.CheckOutput(proguard_cmd, print_stdout=True)
34 def main(args):
35 args = build_utils.ExpandFileArgs(args)
36 parser = optparse.OptionParser()
37 build_utils.AddDepfileOption(parser)
38 parser.add_option('--proguard-path',
39 help='Path to the proguard executable.')
40 parser.add_option('--input-path',
41 help='Path to the .jar file proguard should run on.')
42 parser.add_option('--output-path', help='Path to the generated .jar file.')
43 parser.add_option('--proguard-config',
44 help='Path to the proguard configuration file.')
45 parser.add_option('--classpath', action='append',
46 help="Classpath for proguard.")
47 parser.add_option('--stamp', help='Path to touch on success.')
49 options, _ = parser.parse_args(args)
51 DoProguard(options)
53 if options.depfile:
54 build_utils.WriteDepfile(
55 options.depfile,
56 build_utils.GetPythonDependencies())
58 if options.stamp:
59 build_utils.Touch(options.stamp)
62 if __name__ == '__main__':
63 sys.exit(main(sys.argv[1:]))