2017-12-12 15:40:11 +00:00
|
|
|
#!/bin/bash
|
|
|
|
CURDIR=$(pwd)
|
2018-01-12 11:54:06 +00:00
|
|
|
PB2DIR=$CURDIR/pb2
|
2018-01-12 11:58:39 +00:00
|
|
|
OUTDIR=../trezorlib/messages
|
|
|
|
INDEX=$OUTDIR/__init__.py
|
|
|
|
|
2018-01-12 12:10:36 +00:00
|
|
|
rm -f $OUTDIR/[A-Z]*.py
|
2018-01-12 11:58:39 +00:00
|
|
|
mkdir -p $OUTDIR
|
2018-01-12 11:54:06 +00:00
|
|
|
mkdir -p $PB2DIR
|
|
|
|
touch $PB2DIR/__init__.py
|
2017-12-12 15:40:11 +00:00
|
|
|
|
|
|
|
rm -f $INDEX
|
|
|
|
echo '# Automatically generated by pb2py' >> $INDEX
|
|
|
|
echo 'from __future__ import absolute_import' >> $INDEX
|
|
|
|
echo '' >> $INDEX
|
|
|
|
|
2018-01-12 12:06:43 +00:00
|
|
|
for i in types messages ; do
|
2017-12-12 15:40:11 +00:00
|
|
|
# Compile .proto files to python2 modules using google protobuf library
|
|
|
|
cd $CURDIR/../../trezor-common/protob
|
2018-01-12 11:54:06 +00:00
|
|
|
protoc --python_out=$PB2DIR -I/usr/include -I. $i.proto
|
2017-12-12 15:40:11 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
# 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:06:43 +00:00
|
|
|
for i in types messages ; do
|
2017-12-12 15:40:11 +00:00
|
|
|
# Convert google protobuf library to trezor's internal format
|
|
|
|
cd $CURDIR
|
2018-01-12 11:58:39 +00:00
|
|
|
./pb2py -p $CURDIR -l $INDEX $i $OUTDIR
|
2017-12-12 15:40:11 +00:00
|
|
|
done
|
|
|
|
|
2018-01-12 11:54:06 +00:00
|
|
|
rm -rf $PB2DIR
|