2017-12-12 15:40:11 +00:00
|
|
|
#!/bin/bash
|
2017-12-24 12:14:29 +00:00
|
|
|
set -e
|
2017-12-12 15:40:11 +00:00
|
|
|
|
2017-12-24 12:14:29 +00:00
|
|
|
cd "$(dirname "$0")"
|
2017-12-12 15:40:11 +00:00
|
|
|
|
2017-12-24 12:14:29 +00:00
|
|
|
GENPATH="../trezorlib/messages"
|
|
|
|
INDEX="$GENPATH/__init__.py"
|
|
|
|
PROTO_PATH="../../trezor-common/protob"
|
2018-03-15 18:28:34 +00:00
|
|
|
PROTO_FILES="types messages"
|
2017-12-24 12:14:29 +00:00
|
|
|
PB2_OUT="pb2"
|
2017-12-12 15:40:11 +00:00
|
|
|
|
2018-03-15 18:28:34 +00:00
|
|
|
rm -f "$GENPATH/[A-Z]*.py"
|
2017-12-24 12:14:29 +00:00
|
|
|
mkdir -p "$GENPATH"
|
|
|
|
|
|
|
|
cat > "$INDEX" << EOF
|
|
|
|
# Automatically generated by pb2py
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
mkdir -p "$PB2_OUT"
|
|
|
|
|
2018-03-15 18:28:34 +00:00
|
|
|
for file in $PROTO_FILES; do
|
2017-12-12 15:40:11 +00:00
|
|
|
# Compile .proto files to python2 modules using google protobuf library
|
2018-03-15 18:55:06 +00:00
|
|
|
protoc --python_out="$PB2_OUT" -I/usr/include -I"$PROTO_PATH" "$PROTO_PATH/$file.proto"
|
2017-12-12 15:40:11 +00:00
|
|
|
done
|
|
|
|
|
2018-03-15 18:28:34 +00:00
|
|
|
for file in $PROTO_FILES; do
|
2017-12-12 15:40:11 +00:00
|
|
|
# Convert google protobuf library to trezor's internal format
|
2017-12-24 12:14:29 +00:00
|
|
|
./pb2py -P "trezorlib.protobuf" -p "$PB2_OUT" -l "$INDEX" "$file" "$GENPATH"
|
2017-12-12 15:40:11 +00:00
|
|
|
done
|
|
|
|
|
2017-12-24 12:14:29 +00:00
|
|
|
rm -rf "$PB2_OUT"
|