22000be9dbbb1eed238c9c6e9a0fc10c15c196c9
[platform/framework/web/crosswalk.git] / src / build / android / gyp / proguard.py
1 #!/usr/bin/env python
2 #
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.
6
7 import optparse
8 import os
9 import sys
10
11 from util import build_utils
12
13 def DoProguard(options):
14   injars = options.input_path
15   outjars = options.output_path
16   classpath = build_utils.ParseGypList(options.classpath)
17   classpath = list(set(classpath))
18   libraryjars = ':'.join(classpath)
19   # proguard does its own dependency checking, which can be avoided by deleting
20   # the output.
21   if os.path.exists(options.output_path):
22     os.remove(options.output_path)
23   proguard_cmd = [options.proguard_path,
24                   '-injars', injars,
25                   '-outjars', outjars,
26                   '-libraryjars', libraryjars,
27                   '@' + options.proguard_config]
28   build_utils.CheckOutput(proguard_cmd, print_stdout=True)
29
30
31 def main():
32   parser = optparse.OptionParser()
33   parser.add_option('--proguard-path',
34                     help='Path to the proguard executable.')
35   parser.add_option('--input-path',
36                     help='Path to the .jar file proguard should run on.')
37   parser.add_option('--output-path', help='Path to the generated .jar file.')
38   parser.add_option('--proguard-config',
39                     help='Path to the proguard configuration file.')
40   parser.add_option('--classpath', help="Classpath for proguard.")
41   parser.add_option('--stamp', help='Path to touch on success.')
42
43   options, _ = parser.parse_args()
44
45   DoProguard(options)
46
47   if options.stamp:
48     build_utils.Touch(options.stamp)
49
50
51 if __name__ == '__main__':
52   sys.exit(main())