gitbutler/crates/gitbutler-tauri/inject-git-binaries.sh
Sebastian Thiel f59268fb25
Allow local overrides for the target triple of production windows builds.
The use-case is somewhat specific as it allows developers to do:

```
export TRIPLE_OVERRIDE=x86_64-pc-windows-msvc
```

and build the binary as x86 even on an ARM VM.
The reason ARM builds don't work natively is the `win32` crate,
which simply doesn't work there.

It could be another step to replace it with something that does
to get ARM builds, but probably that will only happen once
there is demand for native ARM windows builds.
2024-05-25 15:05:43 +02:00

26 lines
1.1 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
THIS="$0"
function log {
printf "[%s] %s\n\n" "$THIS" "$*"
}
ROOT="$(dirname "$THIS")/../.."
TRIPLE=${TRIPLE_OVERRIDE:-$(rustc -vV | sed -n 's|host: ||p')}
TARGET_ROOT="$ROOT/target/${TRIPLE_OVERRIDE:-}/release"
CRATE_ROOT="$ROOT/crates/gitbutler-tauri"
if [ -f "$TARGET_ROOT/gitbutler-git-askpass" ] && [ -f "$TARGET_ROOT/gitbutler-git-setsid" ]; then
log injecting gitbutler-git binaries into crates/gitbutler-tauri "(TRIPLE=${TRIPLE})"
cp -v "$TARGET_ROOT/gitbutler-git-askpass" "$CRATE_ROOT/gitbutler-git-askpass-${TRIPLE}"
cp -v "$TARGET_ROOT/gitbutler-git-setsid" "$CRATE_ROOT/gitbutler-git-setsid-${TRIPLE}"
elif [ -f "$TARGET_ROOT/gitbutler-git-askpass.exe" ] && [ -f "$TARGET_ROOT/gitbutler-git-setsid.exe" ]; then
log injecting gitbutler-git binaries into crates/gitbutler-tauri "(TRIPLE=${TRIPLE})"
cp -v "$TARGET_ROOT/gitbutler-git-askpass.exe" "$CRATE_ROOT/gitbutler-git-askpass-${TRIPLE}.exe"
cp -v "$TARGET_ROOT/gitbutler-git-setsid.exe" "$CRATE_ROOT/gitbutler-git-setsid-${TRIPLE}.exe"
else
log gitbutler-git binaries are not built
exit 1
fi