1#!/usr/bin/env python3
2# Copyright 2020 The Chromium Authors. All rights reserved.
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5"""Wrapper script around ByteCodeRewriter subclass scripts."""
6
7import argparse
8import sys
9
10from util import build_utils
11
12
13def main(argv):
14  argv = build_utils.ExpandFileArgs(argv[1:])
15  parser = argparse.ArgumentParser()
16  build_utils.AddDepfileOption(parser)
17  parser.add_argument('--script',
18                      required=True,
19                      help='Path to the java binary wrapper script.')
20  parser.add_argument('--classpath', action='append', nargs='+')
21  parser.add_argument('--input-jar', required=True)
22  parser.add_argument('--output-jar', required=True)
23  args = parser.parse_args(argv)
24
25  classpath = build_utils.ParseGnList(args.classpath)
26  build_utils.WriteDepfile(args.depfile, args.output_jar, inputs=classpath)
27
28  classpath.append(args.input_jar)
29  cmd = [
30      args.script, '--classpath', ':'.join(classpath), args.input_jar,
31      args.output_jar
32  ]
33  build_utils.CheckOutput(cmd, print_stdout=True)
34
35
36if __name__ == '__main__':
37  sys.exit(main(sys.argv))
38