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
12 from util
import md5_check
13 from util
import proguard_util
16 def _ParseOptions(args
):
17 parser
= optparse
.OptionParser()
18 build_utils
.AddDepfileOption(parser
)
19 parser
.add_option('--proguard-path',
20 help='Path to the proguard executable.')
21 parser
.add_option('--input-paths',
22 help='Paths to the .jar files proguard should run on.')
23 parser
.add_option('--output-path', help='Path to the generated .jar file.')
24 parser
.add_option('--proguard-configs',
25 help='Paths to proguard configuration files.')
26 parser
.add_option('--mapping', help='Path to proguard mapping to apply.')
27 parser
.add_option('--is-test', action
='store_true',
28 help='If true, extra proguard options for instrumentation tests will be '
30 parser
.add_option('--classpath', action
='append',
31 help='Classpath for proguard.')
32 parser
.add_option('--stamp', help='Path to touch on success.')
34 options
, _
= parser
.parse_args(args
)
37 for arg
in options
.classpath
:
38 classpath
+= build_utils
.ParseGypList(arg
)
39 options
.classpath
= classpath
45 args
= build_utils
.ExpandFileArgs(args
)
46 options
= _ParseOptions(args
)
48 proguard
= proguard_util
.ProguardCmdBuilder(options
.proguard_path
)
49 proguard
.injars(build_utils
.ParseGypList(options
.input_paths
))
50 proguard
.configs(build_utils
.ParseGypList(options
.proguard_configs
))
51 proguard
.outjar(options
.output_path
)
54 proguard
.mapping(options
.mapping
)
57 proguard
.is_test(True)
59 classpath
= list(set(options
.classpath
))
60 proguard
.libraryjars(classpath
)
62 input_paths
= proguard
.GetInputs()
63 python_deps
= build_utils
.GetPythonDependencies()
66 proguard
.CheckOutput()
69 build_utils
.WriteDepfile(options
.depfile
, python_deps
+ input_paths
)
71 build_utils
.Touch(options
.stamp
)
73 md5_check
.CallAndRecordIfStale(
75 record_path
=options
.output_path
+ '.proguard.md5.stamp',
76 input_paths
=input_paths
,
77 input_strings
=proguard
.build() + python_deps
,
78 force
=not os
.path
.exists(options
.output_path
))
81 if __name__
== '__main__':
82 sys
.exit(main(sys
.argv
[1:]))