Skip to content

Commit 5aa240e

Browse files
committed
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.
1 parent cb0ed06 commit 5aa240e

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,5 +129,8 @@ RUN rustup component add clippy
129129
RUN CARGO_HOME=/opt/cargo cargo install cbindgen --version 0.20.0
130130
RUN CARGO_HOME=/opt/cargo cargo install bindgen --version 0.59.1
131131

132+
COPY tools/prost-build prost-build
133+
RUN CARGO_HOME=/opt/cargo cargo install --path prost-build --locked
134+
132135
# Clean temporary files to reduce image size
133136
RUN rm -rf /var/lib/apt/lists/*

messages/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ foreach(i ${PROTO_FILES})
4242
endif()
4343
endforeach()
4444

45+
find_program(PROST_BUILD prost-build)
46+
4547
add_custom_command(
4648
OUTPUT ${OUTPUT_SOURCES} ${OUTPUT_HEADERS}
4749
DEPENDS ${PROTO_FILES} ${PROTO_OPTION_FILES}
@@ -56,8 +58,7 @@ add_custom_command(
5658
# Using prost-build the normal way as part of build.rs does not work due to a cargo bug:
5759
# https://github.com/danburkert/prost/issues/344#issuecomment-650721245
5860
COMMAND
59-
${CMAKE_COMMAND} -E env
60-
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/
61+
${PROST_BUILD} --messages-dir=${CMAKE_CURRENT_SOURCE_DIR} --out-dir=${CMAKE_SOURCE_DIR}/src/rust/bitbox02-rust/src/
6162
)
6263

6364
add_custom_target(

0 commit comments

Comments
 (0)