1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-18 05:28:40 +00:00
trezor-firmware/tools/build_protobuf
2017-09-25 16:18:31 +02:00

31 lines
927 B
Bash
Executable File

#!/bin/bash
CURDIR=$(pwd)
mkdir -p $CURDIR/pb2/
touch $CURDIR/pb2/__init__.py
mkdir -p ../src/trezor/messages
INDEX=../src/trezor/messages/wire_types.py
rm -f $INDEX
echo '# Automatically generated by pb2py' >> $INDEX
echo 'from micropython import const' >> $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
./pb2py -m -p $CURDIR -i $INDEX $i ../src/trezor/messages/
done
rm -rf $CURDIR/pb2/