mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-24 23:38:09 +00:00
28 lines
655 B
Plaintext
28 lines
655 B
Plaintext
|
#!/usr/bin/env bash
|
||
|
|
||
|
# Generates src/protos/generated and src/messages/generated.rs
|
||
|
|
||
|
crate_root="$(dirname "$(dirname "$(realpath "$0")")")"
|
||
|
|
||
|
protos="$crate_root/src/protos/generated"
|
||
|
messages="$crate_root/src/messages/generated.rs"
|
||
|
|
||
|
if [ "$1" = "--check" ]; then
|
||
|
protos_out=$(mktemp -d)
|
||
|
messages_out=$(mktemp)
|
||
|
else
|
||
|
protos_out=$protos
|
||
|
messages_out=$messages
|
||
|
fi
|
||
|
|
||
|
cargo run --manifest-path "$crate_root/build/Cargo.toml" -- "$protos_out"
|
||
|
|
||
|
"$crate_root/scripts/build_messages" > "$messages_out"
|
||
|
rustfmt "$messages_out"
|
||
|
|
||
|
if [ "$1" = "--check" ]; then
|
||
|
set -e
|
||
|
diff -ur "$protos_out" "$protos"
|
||
|
diff -ur "$messages_out" "$messages"
|
||
|
fi
|