1#!/usr/bin/env python3 2# Copyright 2017 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 6"""Wraps bin/helper/bytecode_processor and expands @FileArgs.""" 7 8import argparse 9import sys 10 11from util import build_utils 12from util import server_utils 13 14 15def _AddSwitch(parser, val): 16 parser.add_argument( 17 val, action='store_const', default='--disabled', const=val) 18 19 20def main(argv): 21 argv = build_utils.ExpandFileArgs(argv[1:]) 22 parser = argparse.ArgumentParser() 23 parser.add_argument('--target-name', help='Fully qualified GN target name.') 24 parser.add_argument('--script', required=True, 25 help='Path to the java binary wrapper script.') 26 parser.add_argument('--gn-target', required=True) 27 parser.add_argument('--input-jar', required=True) 28 parser.add_argument('--direct-classpath-jars') 29 parser.add_argument('--sdk-classpath-jars') 30 parser.add_argument('--full-classpath-jars') 31 parser.add_argument('--full-classpath-gn-targets') 32 parser.add_argument('--stamp') 33 parser.add_argument('-v', '--verbose', action='store_true') 34 parser.add_argument('--missing-classes-allowlist') 35 parser.add_argument('--warnings-as-errors', 36 action='store_true', 37 help='Treat all warnings as errors.') 38 _AddSwitch(parser, '--is-prebuilt') 39 args = parser.parse_args(argv) 40 41 if server_utils.MaybeRunCommand(name=args.target_name, 42 argv=sys.argv, 43 stamp_file=args.stamp): 44 return 45 46 args.sdk_classpath_jars = build_utils.ParseGnList(args.sdk_classpath_jars) 47 args.direct_classpath_jars = build_utils.ParseGnList( 48 args.direct_classpath_jars) 49 args.full_classpath_jars = build_utils.ParseGnList(args.full_classpath_jars) 50 args.full_classpath_gn_targets = build_utils.ParseGnList( 51 args.full_classpath_gn_targets) 52 args.missing_classes_allowlist = build_utils.ParseGnList( 53 args.missing_classes_allowlist) 54 55 verbose = '--verbose' if args.verbose else '--not-verbose' 56 57 cmd = [args.script, args.gn_target, args.input_jar, verbose, args.is_prebuilt] 58 cmd += [str(len(args.missing_classes_allowlist))] 59 cmd += args.missing_classes_allowlist 60 cmd += [str(len(args.sdk_classpath_jars))] 61 cmd += args.sdk_classpath_jars 62 cmd += [str(len(args.direct_classpath_jars))] 63 cmd += args.direct_classpath_jars 64 cmd += [str(len(args.full_classpath_jars))] 65 cmd += args.full_classpath_jars 66 cmd += [str(len(args.full_classpath_gn_targets))] 67 cmd += args.full_classpath_gn_targets 68 build_utils.CheckOutput(cmd, 69 print_stdout=True, 70 fail_func=None, 71 fail_on_output=args.warnings_as_errors) 72 73 if args.stamp: 74 build_utils.Touch(args.stamp) 75 76 77if __name__ == '__main__': 78 sys.exit(main(sys.argv)) 79