Skip to content

Commit d5bb345

Browse files
Fix CI: sidecar placeholder per target triple, Windows ICO format, Windows .exe
handling
1 parent e5e741e commit d5bb345

1 file changed

Lines changed: 31 additions & 12 deletions

File tree

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,50 @@
11
#!/usr/bin/env bash
2-
# Builds the tsr binary and copies it to binaries/tsr-{triple}.
3-
# Run once before `pnpm tauri dev`, and automatically via beforeBundleCommand.
2+
# Builds the tsr binary and copies it to binaries/tsr-{triple}[.exe].
3+
#
4+
# When called by Tauri's beforeBundleCommand, TAURI_ENV_TARGET_TRIPLE is set
5+
# automatically for cross-compilation targets. Falls back to host triple otherwise.
46
#
57
# Usage:
68
# bash scripts/prepare-sidecar.sh # debug (default)
79
# bash scripts/prepare-sidecar.sh release # release
810

911
set -e
1012

11-
TRIPLE=$(rustc -vV | sed -n 's/host: //p')
13+
HOST_TRIPLE=$(rustc -vV | sed -n 's/host: //p')
14+
TRIPLE="${TAURI_ENV_TARGET_TRIPLE:-$HOST_TRIPLE}"
1215
PROFILE="${1:-debug}"
1316

17+
# Windows binaries have .exe extension
18+
if [[ "$TRIPLE" == *"windows"* ]]; then
19+
EXT=".exe"
20+
else
21+
EXT=""
22+
fi
23+
1424
mkdir -p binaries
1525

16-
# Tauri's build.rs validates that the sidecar file exists before compiling.
17-
# Touch a placeholder so the check passes, then overwrite with the real binary.
18-
touch "binaries/tsr-$TRIPLE"
26+
# Touch placeholder so Tauri's build.rs validation passes before compilation
27+
touch "binaries/tsr-$TRIPLE$EXT"
1928

2029
echo "Building tsr ($PROFILE) for $TRIPLE..."
2130

31+
# Use --target flag when cross-compiling
32+
if [ "$TRIPLE" != "$HOST_TRIPLE" ]; then
33+
TARGET_FLAG="--target $TRIPLE"
34+
else
35+
TARGET_FLAG=""
36+
fi
37+
2238
if [ "$PROFILE" = "release" ]; then
23-
cargo build --release --bin tsr
24-
cp "target/release/tsr" "binaries/tsr-$TRIPLE"
39+
cargo build --release --bin tsr $TARGET_FLAG
40+
SRC="target/${TRIPLE}/release/tsr${EXT}"
41+
[ -f "$SRC" ] || SRC="target/release/tsr${EXT}"
2542
else
26-
cargo build --bin tsr
27-
cp "target/debug/tsr" "binaries/tsr-$TRIPLE"
43+
cargo build --bin tsr $TARGET_FLAG
44+
SRC="target/${TRIPLE}/debug/tsr${EXT}"
45+
[ -f "$SRC" ] || SRC="target/debug/tsr${EXT}"
2846
fi
2947

30-
chmod +x "binaries/tsr-$TRIPLE"
31-
echo "✓ binaries/tsr-$TRIPLE ready"
48+
cp "$SRC" "binaries/tsr-$TRIPLE$EXT"
49+
chmod +x "binaries/tsr-$TRIPLE$EXT" 2>/dev/null || true
50+
echo "✓ binaries/tsr-$TRIPLE$EXT ready"

0 commit comments

Comments
 (0)