You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
trezor-firmware/tools/build_protobuf

30 lines
896 B

#!/bin/bash
CURDIR=$(pwd)
mkdir -p $CURDIR/pb2/
touch $CURDIR/pb2/__init__.py
mkdir -p ../trezorlib/messages
INDEX=../trezorlib/messages/__init__.py
rm -f $INDEX
echo '# Automatically generated by pb2py' >> $INDEX
echo '' >> $INDEX
for i in types messages storage ; do
# Compile .proto files to python2 modules using google protobuf library
cd $CURDIR/../../trezor-common/protob
protoc --python_out=$CURDIR/pb2/ -I/usr/include -I. $i.proto
done
# hack to make output python 3 compatible
sed -i 's/^import types_pb2/from . import types_pb2/g' $CURDIR/pb2/messages_pb2.py
sed -i 's/^import types_pb2/from . import types_pb2/g' $CURDIR/pb2/storage_pb2.py
for i in types messages storage ; do
# Convert google protobuf library to trezor's internal format
cd $CURDIR
7 years ago
./pb2py -P "trezorlib.protobuf" -p $CURDIR -l $INDEX $i ../trezorlib/messages/
done
rm -rf $CURDIR/pb2/