mirror of
https://github.com/storytold/filmcraft.git
synced 2026-11-11 16:34:30 -06:00
Honor CARGO_BUILD_TARGET in FreeBSD packaging for aarch64 release builds (#3534)
* Honor CARGO_BUILD_TARGET in FreeBSD packaging for aarch64 release builds The release workflow cross-compiles FreeBSD aarch64 in an x86_64 VM and sets CARGO_BUILD_TARGET. package.sh took the arch from uname -m, so it built the aarch64 binaries into target/release and named the archive for the host (x86_64), and it ran the aarch64 binary to print --version, which the x86_64 host cannot run. When CARGO_BUILD_TARGET is set, build with --target, read binaries from target/<triple>/release, name the archive by the target's arch, and skip the --version check when the binary is not native. Unset behavior is unchanged. * Reject unsupported CARGO_BUILD_TARGET in FreeBSD packaging Any target other than aarch64-unknown-freebsd was labelled x86_64, so an i686 build would produce an x86_64-named archive of i686 binaries. Only x86_64 and aarch64 targets are accepted now; others exit 2 before the build.
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
# Build and package FilmCraft for FreeBSD:
|
||||
#
|
||||
# $DIST/filmcraft-<version>-freebsd-x86_64.tar.gz a /usr/local-style tree:
|
||||
# filmcraft-<version>-freebsd-x86_64/{bin, share/applications, share/icons, share/mime,
|
||||
# $DIST/filmcraft-<version>-freebsd-<arch>.tar.gz (arch: x86_64 or aarch64) a /usr/local-style tree:
|
||||
# filmcraft-<version>-freebsd-<arch>/{bin, share/applications, share/icons, share/mime,
|
||||
# share/metainfo, share/doc/filmcraft}
|
||||
#
|
||||
# Install by copying the tree's contents into /usr/local:
|
||||
@@ -36,6 +36,15 @@ case "$MACHINE" in
|
||||
arm64 | aarch64) ARCH=aarch64 ;;
|
||||
*) echo "unsupported architecture $MACHINE" >&2; exit 2 ;;
|
||||
esac
|
||||
NATIVE_ARCH="$ARCH"
|
||||
# A cross build (the release workflow sets CARGO_BUILD_TARGET) takes its arch from the target.
|
||||
if [[ -n "${CARGO_BUILD_TARGET:-}" ]]; then
|
||||
case "$CARGO_BUILD_TARGET" in
|
||||
aarch64-unknown-freebsd) ARCH=aarch64 ;;
|
||||
x86_64-unknown-freebsd) ARCH=x86_64 ;;
|
||||
*) echo "error: unsupported CARGO_BUILD_TARGET $CARGO_BUILD_TARGET" >&2; exit 2 ;;
|
||||
esac
|
||||
fi
|
||||
if [[ "$DRY_RUN" = 0 ]] && [[ "$(uname -s)" != FreeBSD ]]; then
|
||||
echo "error: build on FreeBSD (or pass --dry-run to check the tree layout)" >&2
|
||||
exit 2
|
||||
@@ -47,14 +56,14 @@ echo "==> FilmCraft $VERSION for FreeBSD $ARCH"
|
||||
# The release VM has 12 GB; full parallelism on the biggest crates runs it out of memory.
|
||||
export CARGO_BUILD_JOBS="${CARGO_BUILD_JOBS:-4}"
|
||||
if [[ "$SKIP_BUILD" = 0 ]]; then
|
||||
(cd "$ROOT" && cargo build --release --locked -p filmcraft -p filmcraft-cli)
|
||||
(cd "$ROOT" && cargo build --release --locked ${CARGO_BUILD_TARGET:+--target "$CARGO_BUILD_TARGET"} -p filmcraft -p filmcraft-cli)
|
||||
fi
|
||||
WORK="$CARGO_TARGET_DIR/freebsd-package"
|
||||
STAGE="$WORK/$BASENAME"
|
||||
rm -rf "$WORK"
|
||||
mkdir -p "$WORK"
|
||||
|
||||
BIN="$CARGO_TARGET_DIR/release"
|
||||
BIN="$CARGO_TARGET_DIR${CARGO_BUILD_TARGET:+/$CARGO_BUILD_TARGET}/release"
|
||||
OUT_DIR="$DIST"
|
||||
if [[ "$DRY_RUN" = 1 ]]; then
|
||||
# Stub binaries, and the tarball stays in the work dir so dist/ only ever holds real builds.
|
||||
@@ -95,7 +104,8 @@ mkdir -p "$OUT_DIR"
|
||||
tar -C "$WORK" -czf "$OUT_DIR/$BASENAME.tar.gz" "$BASENAME"
|
||||
echo "wrote $OUT_DIR/$BASENAME.tar.gz"
|
||||
|
||||
"$STAGE/bin/filmcraft-cli" --version
|
||||
# A cross-built binary can't run on this host.
|
||||
if [[ "$ARCH" = "$NATIVE_ARCH" ]]; then "$STAGE/bin/filmcraft-cli" --version; fi
|
||||
if [[ "$DRY_RUN" = 1 ]]; then
|
||||
echo "==> dry run: tarball contents"
|
||||
tar -tzvf "$OUT_DIR/$BASENAME.tar.gz"
|
||||
|
||||
Reference in New Issue
Block a user