2016-04-26 23:32:57 +00:00
|
|
|
#!/bin/bash
|
|
|
|
CURDIR=$(pwd)
|
2018-01-12 12:11:22 +00:00
|
|
|
PB2DIR=$CURDIR/pb2
|
|
|
|
OUTDIR=../src/trezor/messages
|
|
|
|
INDEX=$OUTDIR/wire_types.py
|
2016-04-26 23:32:57 +00:00
|
|
|
|
2018-01-12 12:11:22 +00:00
|
|
|
rm -f $OUTDIR/[A-Z]*.py
|
|
|
|
mkdir -p $OUTDIR
|
|
|
|
mkdir -p $PB2DIR
|
|
|
|
touch $PB2DIR/__init__.py
|
2017-06-13 17:35:14 +00:00
|
|
|
|
2016-09-21 12:12:46 +00:00
|
|
|
rm -f $INDEX
|
2017-06-07 17:06:26 +00:00
|
|
|
echo '# Automatically generated by pb2py' >> $INDEX
|
|
|
|
echo 'from micropython import const' >> $INDEX
|
|
|
|
echo '' >> $INDEX
|
2016-09-21 12:12:46 +00:00
|
|
|
|
2018-01-12 12:11:22 +00:00
|
|
|
for i in types messages ; do
|
2016-04-26 23:32:57 +00:00
|
|
|
# Compile .proto files to python2 modules using google protobuf library
|
|
|
|
cd $CURDIR/../../trezor-common/protob
|
2018-01-12 12:11:22 +00:00
|
|
|
protoc --python_out=$PB2DIR -I/usr/include -I. $i.proto
|
2016-10-03 16:16:15 +00:00
|
|
|
done
|
2016-04-26 23:32:57 +00:00
|
|
|
|
2017-09-25 14:01:22 +00:00
|
|
|
# hack to make output python 3 compatible
|
|
|
|
sed -i 's/^import types_pb2/from . import types_pb2/g' $CURDIR/pb2/messages_pb2.py
|
|
|
|
|
2018-01-12 12:11:22 +00:00
|
|
|
for i in types messages ; do
|
2016-04-26 23:32:57 +00:00
|
|
|
# Convert google protobuf library to trezor's internal format
|
|
|
|
cd $CURDIR
|
2018-01-12 12:11:22 +00:00
|
|
|
./pb2py -m -p $CURDIR -i $INDEX $i $OUTDIR
|
2016-04-26 23:32:57 +00:00
|
|
|
done
|
2016-10-03 16:16:15 +00:00
|
|
|
|
2018-01-12 12:11:22 +00:00
|
|
|
rm -rf $PB2DIR
|