forked from LedgerHQ/app-sui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update-generated-bindings.sh
executable file
·30 lines (25 loc) · 1.13 KB
/
update-generated-bindings.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env bash
# Use this script when updating the ledger_device_sdk, to regenerate bindings.rs and C SDK thunk
set -eu
nix-thunk unpack ./dep/ledger_secure_sdk_sys-bindings
for device in nanos nanosplus nanox
do
export DEVICE=$device
nix-shell -A $DEVICE.rustShell --run ' \
set -x
cd rust-app; \
cargo clean; \
cargo build --target=$TARGET_JSON; \
C_SDK_PATH=`find ./target/$DEVICE -type d -name 'ledger-secure-sdk'`; \
C_SDK_HASH=`git -C $C_SDK_PATH describe --always --exclude \* --abbrev=40`; \
C_SDK_URL=`git -C $C_SDK_PATH config --get remote.origin.url`; \
BINDINGS_PATH=`find ./target/$DEVICE -type f -name 'bindings.rs'`; \
mkdir -p ../dep/ledger_secure_sdk_sys-bindings/$DEVICE; \
cp "$BINDINGS_PATH" "../dep/ledger_secure_sdk_sys-bindings/$DEVICE/"; \
rm -r ../dep/ledger-secure-sdk-$DEVICE; \
nix-thunk create "$C_SDK_URL" ../dep/ledger-secure-sdk-$DEVICE --rev $C_SDK_HASH;
'
done
# This should fail in case of update to the bindings
# Review the changes with the nix-build; then commit, push and pack
nix-thunk pack ./dep/ledger_secure_sdk_sys-bindings