OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # Copyright 2014 The Chromium Authors. All rights reserved. | 3 # Copyright 2014 The Chromium Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 """Merges a list of jars into a single jar.""" | 7 """Merges a list of jars into a single jar.""" |
8 | 8 |
9 import optparse | 9 import optparse |
10 import re | |
11 import sys | 10 import sys |
12 | 11 |
13 from util import build_utils | 12 from util import build_utils |
14 | 13 |
15 def main(args): | 14 def main(args): |
16 args = build_utils.ExpandFileArgs(args) | 15 args = build_utils.ExpandFileArgs(args) |
17 parser = optparse.OptionParser() | 16 parser = optparse.OptionParser() |
18 build_utils.AddDepfileOption(parser) | 17 build_utils.AddDepfileOption(parser) |
19 parser.add_option('--output', help='Path to output jar.') | 18 parser.add_option('--output', help='Path to output jar.') |
20 parser.add_option('--use-ijars', action='store_true', | |
21 help='Use .interface.jar rather than the given jars.') | |
22 parser.add_option('--inputs', action='append', help='List of jar inputs.') | 19 parser.add_option('--inputs', action='append', help='List of jar inputs.') |
23 options, _ = parser.parse_args(args) | 20 options, _ = parser.parse_args(args) |
24 build_utils.CheckOptions(options, parser, ['output', 'inputs']) | 21 build_utils.CheckOptions(options, parser, ['output', 'inputs']) |
25 | 22 |
26 input_jars = [] | 23 input_jars = [] |
27 for inputs_arg in options.inputs: | 24 for inputs_arg in options.inputs: |
28 input_jars.extend(build_utils.ParseGypList(inputs_arg)) | 25 input_jars.extend(build_utils.ParseGypList(inputs_arg)) |
29 | 26 |
30 if options.use_ijars: | |
31 ijar_re = re.compile(r'\.jar$') | |
32 input_jars = [ijar_re.sub('.interface.jar', p) for p in input_jars] | |
33 | |
34 build_utils.MergeZips(options.output, input_jars) | 27 build_utils.MergeZips(options.output, input_jars) |
35 | 28 |
36 if options.depfile: | 29 if options.depfile: |
37 build_utils.WriteDepfile( | 30 build_utils.WriteDepfile( |
38 options.depfile, | 31 options.depfile, |
39 input_jars + build_utils.GetPythonDependencies()) | 32 input_jars + build_utils.GetPythonDependencies()) |
40 | 33 |
41 | 34 |
42 if __name__ == '__main__': | 35 if __name__ == '__main__': |
43 sys.exit(main(sys.argv[1:])) | 36 sys.exit(main(sys.argv[1:])) |
OLD | NEW |