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.
10 from util
import build_utils
11 from util
import proguard_util
13 def DoProguard(options
):
14 proguard
= proguard_util
.ProguardCmdBuilder(options
.proguard_path
)
15 proguard
.injars(build_utils
.ParseGypList(options
.input_paths
))
16 proguard
.configs(build_utils
.ParseGypList(options
.proguard_configs
))
17 proguard
.outjar(options
.output_path
)
20 proguard
.mapping(options
.mapping
)
23 proguard
.is_test(True)
26 for arg
in options
.classpath
:
27 classpath
+= build_utils
.ParseGypList(arg
)
28 classpath
= list(set(classpath
))
29 proguard
.libraryjars(classpath
)
31 proguard
.CheckOutput()
33 return proguard
.GetInputs()
37 args
= build_utils
.ExpandFileArgs(args
)
38 parser
= optparse
.OptionParser()
39 build_utils
.AddDepfileOption(parser
)
40 parser
.add_option('--proguard-path',
41 help='Path to the proguard executable.')
42 parser
.add_option('--input-paths',
43 help='Paths to the .jar files proguard should run on.')
44 parser
.add_option('--output-path', help='Path to the generated .jar file.')
45 parser
.add_option('--proguard-configs',
46 help='Paths to proguard configuration files.')
47 parser
.add_option('--mapping', help='Path to proguard mapping to apply.')
48 parser
.add_option('--is-test', action
='store_true',
49 help='If true, extra proguard options for instrumentation tests will be '
51 parser
.add_option('--classpath', action
='append',
52 help='Classpath for proguard.')
53 parser
.add_option('--stamp', help='Path to touch on success.')
55 options
, _
= parser
.parse_args(args
)
57 inputs
= DoProguard(options
)
60 build_utils
.WriteDepfile(
62 inputs
+ build_utils
.GetPythonDependencies())
65 build_utils
.Touch(options
.stamp
)
68 if __name__
== '__main__':
69 sys
.exit(main(sys
.argv
[1:]))