mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-02-16 17:42:02 +00:00
cleanup pb2py, add debug to emu.sh
This commit is contained in:
parent
0a8870f110
commit
ee3614ae6a
5
Makefile
5
Makefile
@ -41,5 +41,8 @@ gdb: ## start remote gdb session which connects to the openocd
|
||||
|
||||
load: ## load contents of src into mass storage of trezor
|
||||
rm -rf /run/media/${USER}/PYBFLASH/*
|
||||
cp -a src/* /run/media/${USER}/PYBFLASH/
|
||||
cp -a src/lib /run/media/${USER}/PYBFLASH/
|
||||
cp -a src/playground /run/media/${USER}/PYBFLASH/
|
||||
cp -a src/trezor /run/media/${USER}/PYBFLASH/
|
||||
cp -a src/*.py /run/media/${USER}/PYBFLASH/
|
||||
sync
|
||||
|
5
emu.sh
5
emu.sh
@ -1,5 +1,10 @@
|
||||
#!/bin/bash
|
||||
cd `dirname $0`/src
|
||||
rm -f ../pipe.*
|
||||
if [ "$1" == -d ]; then
|
||||
shift
|
||||
gdb --args ../vendor/micropython/unix/micropython $* -O0 -X heapsize=100000 main.py
|
||||
else
|
||||
../vendor/micropython/unix/micropython $* -O0 -X heapsize=100000 main.py
|
||||
fi
|
||||
rm -f ../pipe.*
|
||||
|
1
src/trezor/messages/.gitignore
vendored
Normal file
1
src/trezor/messages/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
[ABCDEFGHIJKLMNOPQRSTUVWXYZ]*.py
|
@ -28,6 +28,6 @@ BLUE_GRAY = rgbcolor(0x60, 0x7D, 0x8B)
|
||||
BLACK = rgbcolor(0x00, 0x00, 0x00)
|
||||
WHITE = rgbcolor(0xFF, 0xFF, 0xFF)
|
||||
|
||||
MONO = 0
|
||||
NORMAL = 1
|
||||
BOLD = 2
|
||||
MONO = const(0)
|
||||
NORMAL = const(1)
|
||||
BOLD = const(2)
|
||||
|
@ -1,9 +1,7 @@
|
||||
#!/bin/bash
|
||||
CURDIR=$(pwd)
|
||||
|
||||
|
||||
for i in messages types storage ; do
|
||||
|
||||
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
|
||||
@ -12,4 +10,3 @@ for i in messages types storage ; do
|
||||
cd $CURDIR
|
||||
./pb2py $i ../src/trezor/messages/
|
||||
done
|
||||
|
||||
|
2
tools/pb2/.gitignore
vendored
Normal file
2
tools/pb2/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
*_pb2.py
|
||||
*.pyc
|
17
tools/pb2py
17
tools/pb2py
@ -10,19 +10,16 @@ def process_type(t, cls):
|
||||
|
||||
out = ["t = p.MessageType()", ]
|
||||
|
||||
print("Processing type %s" % t)
|
||||
print(" * type %s" % t)
|
||||
|
||||
TYPE_STRING = 9
|
||||
TYPE_BYTES = 12
|
||||
|
||||
TYPE_MESSAGE = 11
|
||||
|
||||
for k, v in cls.DESCRIPTOR.fields_by_name.items():
|
||||
|
||||
#print k
|
||||
|
||||
for v in sorted(cls.DESCRIPTOR.fields_by_name.values(), key=lambda x: x.number):
|
||||
number = v.number
|
||||
fieldname = k
|
||||
fieldname = v.name
|
||||
type = None
|
||||
repeated = v.label == 3
|
||||
required = v.label == 2
|
||||
@ -85,7 +82,7 @@ def process_type(t, cls):
|
||||
def process_enum(t, cls):
|
||||
out = []
|
||||
|
||||
print("Processing enum %s" % t)
|
||||
print(" * enum %s" % t)
|
||||
|
||||
for k, v in cls.items():
|
||||
# Remove type name from the beginning of the constant
|
||||
@ -98,11 +95,13 @@ def process_enum(t, cls):
|
||||
if t.endswith("Type") and k.startswith("%s_" % t.replace("Type", '')):
|
||||
k = k.replace("%s_" % t.replace("Type", ''), '')
|
||||
|
||||
out.append("%s = %s" % (k, v))
|
||||
out.append("%s = const(%s)" % (k, v))
|
||||
|
||||
return out
|
||||
|
||||
def process_module(mod, genpath):
|
||||
|
||||
print("Processing module %s" % mod.__name__)
|
||||
types = dict([(name, cls) for name, cls in mod.__dict__.items() if isinstance(cls, type)])
|
||||
|
||||
for t, cls in types.iteritems():
|
||||
@ -118,7 +117,7 @@ def process_module(mod, genpath):
|
||||
def write_to_file(genpath, t, out):
|
||||
# Write generated sourcecode to given file
|
||||
f = open(os.path.join(genpath, "%s.py" % t), 'w')
|
||||
out = ["# Automatically generated by ./pb2py"] + out
|
||||
out = ["# Automatically generated by pb2py"] + out
|
||||
|
||||
data = "\n".join(out)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user