From 03fa841f482a41757842adea9a41ce1d5647601a Mon Sep 17 00:00:00 2001 From: Niklas Dusenlund Date: Thu, 11 Nov 2021 15:41:15 +0100 Subject: [PATCH] prost: Pre-compile the tool Compiling the tool at build time increases build time and complicates things when we want to support "cargo test" in the rust libraries. --- .ci/run-container-ci | 2 +- Dockerfile | 3 +++ messages/CMakeLists.txt | 5 +++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.ci/run-container-ci b/.ci/run-container-ci index e3b6126f8..5b1aca482 100755 --- a/.ci/run-container-ci +++ b/.ci/run-container-ci @@ -25,7 +25,7 @@ set -e set -x -CONTAINER=shiftcrypto/firmware_v2:21 +CONTAINER=shiftcrypto/firmware_v2:22 if [ "$1" == "pull" ] ; then docker pull "$CONTAINER" diff --git a/Dockerfile b/Dockerfile index 9faa74369..34fa1ca45 100644 --- a/Dockerfile +++ b/Dockerfile @@ -129,5 +129,8 @@ RUN rustup component add clippy RUN CARGO_HOME=/opt/cargo cargo install cbindgen --version 0.20.0 RUN CARGO_HOME=/opt/cargo cargo install bindgen --version 0.59.1 +COPY tools/prost-build prost-build +RUN CARGO_HOME=/opt/cargo cargo install --path prost-build --locked + # Clean temporary files to reduce image size RUN rm -rf /var/lib/apt/lists/* diff --git a/messages/CMakeLists.txt b/messages/CMakeLists.txt index 949306fb7..15f86b656 100644 --- a/messages/CMakeLists.txt +++ b/messages/CMakeLists.txt @@ -42,6 +42,8 @@ foreach(i ${PROTO_FILES}) endif() endforeach() +find_program(PROST_BUILD prost-build) + add_custom_command( OUTPUT ${OUTPUT_SOURCES} ${OUTPUT_HEADERS} DEPENDS ${PROTO_FILES} ${PROTO_OPTION_FILES} @@ -56,8 +58,7 @@ add_custom_command( # Using prost-build the normal way as part of build.rs does not work due to a cargo bug: # https://github.com/danburkert/prost/issues/344#issuecomment-650721245 COMMAND - ${CMAKE_COMMAND} -E env - cargo run --manifest-path=${CMAKE_SOURCE_DIR}/tools/prost-build/Cargo.toml -- --messages-dir=${CMAKE_CURRENT_SOURCE_DIR} --out-dir=${CMAKE_SOURCE_DIR}/src/rust/bitbox02-rust/src/ + ${PROST_BUILD} --messages-dir=${CMAKE_CURRENT_SOURCE_DIR} --out-dir=${CMAKE_SOURCE_DIR}/src/rust/bitbox02-rust/src/ ) add_custom_target(