From 5cc299facdae4d6884776f0ddacaebff134da9a5 Mon Sep 17 00:00:00 2001 From: Jason Zavaglia Date: Thu, 28 Sep 2017 21:10:32 +1000 Subject: [PATCH] Generate the protobuf files at build time (#219) Improve the build reliability by ensuring protobuf files are generated at build time. --- .gitmodules | 3 +++ Dockerfile | 3 ++- build-firmware.sh | 2 ++ firmware/protob/Makefile | 2 +- vendor/nanopb | 1 + 5 files changed, 9 insertions(+), 2 deletions(-) create mode 160000 vendor/nanopb diff --git a/.gitmodules b/.gitmodules index 4fe0f75..920894a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -10,3 +10,6 @@ [submodule "libopencm3"] path = vendor/libopencm3 url = https://github.com/libopencm3/libopencm3.git +[submodule "vendor/nanopb"] + path = vendor/nanopb + url = https://github.com/nanopb/nanopb.git diff --git a/Dockerfile b/Dockerfile index ad05037..00cd4a0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,4 +8,5 @@ RUN apt-get update # install build tools and dependencies -RUN apt-get install -y build-essential git python python-ecdsa gcc-arm-none-eabi +RUN apt-get install -y build-essential git python python-ecdsa gcc-arm-none-eabi protobuf-compiler \ + libprotobuf-dev python-protobuf python3-protobuf diff --git a/build-firmware.sh b/build-firmware.sh index a045e7c..6543b7f 100755 --- a/build-firmware.sh +++ b/build-firmware.sh @@ -13,6 +13,8 @@ docker run -t -v $(pwd)/build:/build:z $IMAGE /bin/sh -c "\ git checkout $TAG && \ git submodule update --init && \ make -C vendor/libopencm3 && \ + make -C vendor/nanopb/generator/proto && \ + make -C firmware/protob && \ make && \ make -C firmware sign && \ cp firmware/trezor.bin /$BINFILE && \ diff --git a/firmware/protob/Makefile b/firmware/protob/Makefile index 3848652..6897deb 100644 --- a/firmware/protob/Makefile +++ b/firmware/protob/Makefile @@ -1,7 +1,7 @@ all: messages.pb.c storage.pb.c types.pb.c messages_map.h %.pb.c: %.pb %.options - nanopb_generator.py $< -L '#include "%s"' -T + ../../vendor/nanopb/generator/nanopb_generator.py $< -L '#include "%s"' -T %.pb: %.proto protoc -I/usr/include -I. $< -o $@ diff --git a/vendor/nanopb b/vendor/nanopb new file mode 160000 index 0000000..54c34a9 --- /dev/null +++ b/vendor/nanopb @@ -0,0 +1 @@ +Subproject commit 54c34a9fda152937d4cd0c7fd85c067fca23af75