1#!/usr/bin/env python3 2 3# This script expects your out/Debug directory to be compiling for linux on 4# a linux machine. If this is not your case just compile protoc and run the 5# command on the last line of the script (from within 6# //third_party/protobuf/src). 7 8import argparse 9import os 10 11PROTO_DIR = os.path.dirname(__file__) 12DIR_SOURCE_ROOT = os.path.join(PROTO_DIR, '..','..') 13 14 15def main(): 16 parser = argparse.ArgumentParser() 17 parser.add_argument('--output-directory', 18 '-C', 19 help='Path to build directory', 20 required=True) 21 22 args = parser.parse_args() 23 24 out_build_dir = args.output_directory 25 26 def r(c): 27 print('Running:', c) 28 os.system(c) 29 30 r('autoninja -C {} protoc'.format(out_build_dir)) 31 32 protoc = os.path.join(out_build_dir, 'protoc') 33 print('Creating //third_party/protobuf/python/google/protobuf/' 34 'descriptor_pb2.py') 35 r('{0} --proto_path={1}/src --python_out={1}/python ' 36 '{1}/src/google/protobuf/descriptor.proto'.format(protoc, PROTO_DIR)) 37 38 print('Creating //third_party/protobuf/python/google/protobuf/compiler/' 39 'plugin_pb2.py') 40 r('{0} --proto_path={1}/src --python_out={1}/python ' 41 '{1}/src/google/protobuf/compiler/plugin.proto'.format(protoc, PROTO_DIR)) 42 43if __name__ == '__main__': 44 main() 45