mirror of
https://github.com/storytold/deckcraft.git
synced 2026-10-29 04:56:58 -06:00
Resolve host-tuple and reject unsupported targets in FreeBSD packaging
Resolve CARGO_BUILD_TARGET=host-tuple to the real host triple before it is used in the target directory path. Accept only x86_64-unknown-freebsd and aarch64-unknown-freebsd when it is set, and fail with an error for anything else instead of mapping unknown targets to x86_64.
This commit is contained in:
@@ -16,19 +16,19 @@ APP_ID=ai.storyteller.deckcraft
|
||||
|
||||
TARGET_ARGS=()
|
||||
BIN="$CARGO_TARGET_DIR/release"
|
||||
# Cross builds (CARGO_BUILD_TARGET from the release workflow) land under target/<triple>/release.
|
||||
if [[ -n "${CARGO_BUILD_TARGET:-}" ]]; then
|
||||
# host-tuple means the build host; resolve it so the target dir path is a real triple.
|
||||
if [[ "$CARGO_BUILD_TARGET" == host-tuple ]]; then
|
||||
CARGO_BUILD_TARGET="$(rustc -vV | sed -n 's/^host: //p')"
|
||||
fi
|
||||
# The target triple, not the build host's uname, names the arch of a cross build.
|
||||
case "$CARGO_BUILD_TARGET" in
|
||||
x86_64-unknown-freebsd) ARCH=x86_64 ;;
|
||||
aarch64-unknown-freebsd) ARCH=aarch64 ;;
|
||||
*) echo "error: unsupported CARGO_BUILD_TARGET '$CARGO_BUILD_TARGET' (expected x86_64-unknown-freebsd or aarch64-unknown-freebsd)" >&2; exit 1 ;;
|
||||
esac
|
||||
TARGET_ARGS=(--target "$CARGO_BUILD_TARGET")
|
||||
BIN="$CARGO_TARGET_DIR/$CARGO_BUILD_TARGET/release"
|
||||
fi
|
||||
|
||||
if [[ "${1:-}" != "--skip-build" ]]; then
|
||||
(cd "$ROOT" && cargo build --release --locked "${TARGET_ARGS[@]}" -p deckcraft -p deckcraft-cli)
|
||||
fi
|
||||
|
||||
if [[ -n "${CARGO_BUILD_TARGET:-}" ]]; then
|
||||
# The target triple, not the build host's uname, names the arch of a cross build.
|
||||
if [[ "$CARGO_BUILD_TARGET" == aarch64-unknown-freebsd ]]; then ARCH=aarch64; else ARCH=x86_64; fi
|
||||
else
|
||||
ARCH="$(uname -m)"
|
||||
case "$ARCH" in
|
||||
@@ -37,6 +37,10 @@ else
|
||||
*) ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
if [[ "${1:-}" != "--skip-build" ]]; then
|
||||
(cd "$ROOT" && cargo build --release --locked "${TARGET_ARGS[@]}" -p deckcraft -p deckcraft-cli)
|
||||
fi
|
||||
NAME="deckcraft-$VERSION-freebsd-$ARCH"
|
||||
WORK="$CARGO_TARGET_DIR/freebsd-package"
|
||||
STAGE="$WORK/$NAME"
|
||||
@@ -53,6 +57,6 @@ cp -R "$ROOT/assets/app-icon/hicolor" "$STAGE/share/icons/"
|
||||
copy_docs "$STAGE/share/doc/deckcraft"
|
||||
|
||||
tar -C "$WORK" -czf "$DIST/$NAME.tar.gz" "$NAME"
|
||||
if [[ -z "${CARGO_BUILD_TARGET:-}" ]]; then "$STAGE/bin/deckcraft-cli" --version; fi # a cross-built binary cannot run on the build host
|
||||
if [[ -z "${CARGO_BUILD_TARGET:-}" || "$CARGO_BUILD_TARGET" == "$(rustc -vV | sed -n 's/^host: //p')" ]]; then "$STAGE/bin/deckcraft-cli" --version; fi # a cross-built binary cannot run on the build host
|
||||
echo "wrote $DIST/$NAME.tar.gz"
|
||||
ls -lh "$DIST/$NAME.tar.gz"
|
||||
|
||||
Reference in New Issue
Block a user