Skip to content

prost: Pre-compile the tool #829

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .ci/run-container-ci
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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/*
5 changes: 3 additions & 2 deletions messages/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Repo moved, the comment is now here: tokio-rs/prost#344 (comment)

It seems the relevant bug has been fixed and stabilized in 1.51.

I think this means we can delete the prost-build altogether and use prost as it is documented, without using this custom tool as a workaround.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I made a new PR.

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(
Expand Down