OLD | NEW |
---|---|
(Empty) | |
1 #!/usr/bin/env python | |
2 # | |
3 # Copyright 2017 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 argparse | |
8 import os | |
9 import shutil | |
10 import sys | |
11 import tempfile | |
12 | |
13 from util import build_utils | |
14 | |
15 | |
16 _SRC_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), | |
17 '..', '..', '..')) | |
18 _DESUGAR_JAR_PATH = os.path.normpath(os.path.join( | |
agrieve
2017/07/20 18:24:09
list this either in depfile_deps or in GN's input
F
2017/07/20 19:40:55
Done.
| |
19 _SRC_ROOT, 'third_party', 'bazel', 'desugar', 'Desugar.jar')) | |
20 | |
21 | |
22 def _OnStaleMd5(input_jar, output_jar, classpath, bootclasspath_entry): | |
23 cmd = [ | |
24 'java', | |
25 '-jar', | |
26 _DESUGAR_JAR_PATH, | |
27 '--input', | |
28 input_jar, | |
29 '--bootclasspath_entry', | |
30 bootclasspath_entry, | |
31 '--output', | |
32 output_jar, | |
33 # Disable try-with-resources due to proguard duplicate zip entry error | |
34 # TODO(zpeng): Enable try-with-resources with | |
35 # desugar_try_with_resources_omit_runtime_classes | |
36 '--desugar_try_with_resources_if_needed=false', | |
37 ] | |
38 for path in classpath: | |
39 cmd += ['--classpath_entry', path] | |
40 build_utils.CheckOutput(cmd, print_stdout=False) | |
41 | |
42 | |
43 def main(): | |
44 args = build_utils.ExpandFileArgs(sys.argv[1:]) | |
45 parser = argparse.ArgumentParser() | |
46 build_utils.AddDepfileOption(parser) | |
47 parser.add_argument('--input-jar', required=True, | |
48 help='Jar input path to include .class files from.') | |
49 parser.add_argument('--output-jar', required=True, | |
50 help='Jar output path.') | |
51 parser.add_argument('--classpath', required=True, | |
52 help='Classpath.') | |
53 parser.add_argument('--bootclasspath-entry', required=True, | |
54 help='Path to javac bootclasspath interface jar.') | |
55 options = parser.parse_args(args) | |
56 | |
57 options.classpath = build_utils.ParseGnList(options.classpath) | |
58 input_paths = options.classpath + [options.input_jar, | |
59 options.bootclasspath_entry] | |
60 output_paths = [options.output_jar] | |
61 | |
62 build_utils.CallAndWriteDepfileIfStale( | |
63 lambda: _OnStaleMd5(options.input_jar, options.output_jar, | |
64 options.classpath, options.bootclasspath_entry), | |
65 options, | |
66 input_paths=input_paths, | |
67 input_strings=[], | |
68 output_paths=output_paths, | |
69 depfile_deps=input_paths) | |
agrieve
2017/07/20 18:24:09
nit: don't pass input_jar and bootclasspath_entry
F
2017/07/20 19:40:55
Done.
| |
70 | |
71 | |
72 if __name__ == '__main__': | |
73 sys.exit(main()) | |
OLD | NEW |