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.
11 from util
import build_utils
13 def DoProguard(options
):
14 injars
= options
.input_path
15 outjars
= options
.output_path
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
23 if os
.path
.exists(options
.output_path
):
24 os
.remove(options
.output_path
)
25 proguard_cmd
= ['java', '-jar',
26 options
.proguard_path
,
29 '-libraryjars', libraryjars
,
30 '@' + options
.proguard_config
]
31 build_utils
.CheckOutput(proguard_cmd
, print_stdout
=True)
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
)
54 build_utils
.WriteDepfile(
56 build_utils
.GetPythonDependencies())
59 build_utils
.Touch(options
.stamp
)
62 if __name__
== '__main__':
63 sys
.exit(main(sys
.argv
[1:]))