1# Invoke this script with an argument pointing to where the Android emulator .proto files are 2# (for example, ~/Library/Android/sdk/emulator/lib on a mac, or 3# $AOSP/external/qemu/android/android-grpc/python/aemu-grpc/src/aemu/proto from the AOSP sources) 4PROTOC_OUT=bumble/transport/grpc_protobuf 5 6proto_files=(emulated_bluetooth.proto emulated_bluetooth_vhci.proto emulated_bluetooth_packets.proto emulated_bluetooth_device.proto grpc_endpoint_description.proto) 7for proto_file in "${proto_files[@]}" 8do 9 python -m grpc_tools.protoc -I$1 --proto_path=bumble/transport --python_out=$PROTOC_OUT --pyi_out=$PROTOC_OUT --grpc_python_out=$PROTOC_OUT $1/$proto_file 10done 11 12python_files=(emulated_bluetooth_pb2_grpc.py emulated_bluetooth_pb2.py emulated_bluetooth_packets_pb2.py emulated_bluetooth_vhci_pb2_grpc.py emulated_bluetooth_vhci_pb2.py emulated_bluetooth_device_pb2.py grpc_endpoint_description_pb2.py) 13for python_file in "${python_files[@]}" 14do 15 sed -i 's/^import .*_pb2 as/from . \0/' $PROTOC_OUT/$python_file 16done