mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-29 19:08:12 +00:00
33 lines
722 B
Bash
Executable File
33 lines
722 B
Bash
Executable File
#!/bin/bash
|
|
set -e
|
|
|
|
cd "$(dirname "$0")"
|
|
|
|
GENPATH="../trezorlib/messages"
|
|
INDEX="$GENPATH/__init__.py"
|
|
PROTO_PATH="../../trezor-common/protob"
|
|
PROTO_FILES="types messages"
|
|
PB2_OUT="pb2"
|
|
|
|
rm -f "$GENPATH/[A-Z]*.py"
|
|
mkdir -p "$GENPATH"
|
|
|
|
cat > "$INDEX" << EOF
|
|
# Automatically generated by pb2py
|
|
|
|
EOF
|
|
|
|
mkdir -p "$PB2_OUT"
|
|
|
|
for file in $PROTO_FILES; do
|
|
# Compile .proto files to python2 modules using google protobuf library
|
|
protoc --python_out="$PB2_OUT" -I/usr/include -I"$PROTO_PATH" "$PROTO_PATH/$file.proto"
|
|
done
|
|
|
|
for file in $PROTO_FILES; do
|
|
# Convert google protobuf library to trezor's internal format
|
|
./pb2py -P "trezorlib.protobuf" -p "$PB2_OUT" -l "$INDEX" "$file" "$GENPATH"
|
|
done
|
|
|
|
rm -rf "$PB2_OUT"
|