1 # Copyright 2019 The Chromium Authors
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
5 """Helper script for use by GN to encode/decode proto files. The protoc tool
6 requires using stdin/stdout for the --encode/--decode options, but that form
7 of processing is not supported by GN.
14 parser = argparse.ArgumentParser()
15 parser.add_argument('--protoc', help='Path to protoc compiler.')
16 parser.add_argument('--infile', required=True,
17 help='Path to input file that will be used as stdin.')
18 parser.add_argument('--outfile', required=True,
19 help='Path to output file that will be used as stdout.')
20 args, passthrough_args = parser.parse_known_args()
22 stdin = open(args.infile, 'r')
23 stdout = open(args.outfile, 'w')
25 subprocess.check_call([args.protoc] + passthrough_args, stdin=stdin,
29 if __name__ == '__main__':