mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-15 20:19:23 +00:00
35 lines
849 B
Bash
35 lines
849 B
Bash
#!/bin/bash
|
|
CURDIR=$(pwd)
|
|
PB2DIR=$CURDIR/pb2
|
|
OUTDIR=../src/trezor/messages
|
|
INDEX=$OUTDIR/wire_types.py
|
|
|
|
set -x
|
|
|
|
rm -f $OUTDIR/[A-Z]*.py
|
|
mkdir -p $OUTDIR
|
|
mkdir -p $PB2DIR
|
|
touch $PB2DIR/__init__.py
|
|
|
|
rm -f $INDEX
|
|
echo '# Automatically generated by pb2py' >> $INDEX
|
|
echo 'from micropython import const' >> $INDEX
|
|
echo '' >> $INDEX
|
|
|
|
for i in types messages ; do
|
|
# Compile .proto files to python2 modules using google protobuf library
|
|
cd $CURDIR/../vendor/trezor-common/protob
|
|
protoc --python_out=$PB2DIR -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
|
|
|
|
for i in types messages ; do
|
|
# Convert google protobuf library to trezor's internal format
|
|
cd $CURDIR
|
|
./pb2py -m -p $CURDIR -i $INDEX $i $OUTDIR
|
|
done
|
|
|
|
rm -rf $PB2DIR
|