- Add Docker-based build system for cross-compiling on Apple Silicon - Create Dockerfiles for Linux x86_64 and ARM64, Windows x86_64 - Add build-all.sh script for automated multi-platform builds - Configure cargo-deb and cargo-generate-rpm for Linux packaging - Update README with cross-compilation instructions Supported outputs: - Linux x86_64: .deb, .rpm, .tar.gz - Windows x86_64: .zip Note: Linux ARM64 disabled due to upstream zune-jpeg NEON bug
91 lines
2.9 KiB
Bash
Executable File
91 lines
2.9 KiB
Bash
Executable File
#!/bin/bash
|
|
set -e
|
|
|
|
# Cross-compilation build script for AVIF Maker
|
|
# Uses Docker directly (not cross tool) for Apple Silicon compatibility
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
|
|
cd "$PROJECT_DIR"
|
|
|
|
VERSION=${1:-$(grep '^version' Cargo.toml | head -1 | sed 's/.*"\(.*\)".*/\1/')}
|
|
DIST_DIR="dist/$VERSION"
|
|
|
|
# Handle --setup-docker flag
|
|
if [[ "$1" == "--setup-docker" ]]; then
|
|
echo "Building Docker images for cross-compilation..."
|
|
echo ""
|
|
echo "Building Linux x86_64 image..."
|
|
docker build --platform linux/amd64 -t avif-maker-linux-x86_64 -f docker/Dockerfile.linux-x86_64 .
|
|
echo ""
|
|
echo "Building Linux ARM64 image..."
|
|
docker build --platform linux/amd64 -t avif-maker-linux-arm64 -f docker/Dockerfile.linux-arm64 .
|
|
echo ""
|
|
echo "Building Windows x86_64 image..."
|
|
docker build --platform linux/amd64 -t avif-maker-windows-x86_64 -f docker/Dockerfile.windows-x86_64 .
|
|
echo ""
|
|
echo "Docker images built successfully!"
|
|
echo "You can now run: ./scripts/build-all.sh"
|
|
exit 0
|
|
fi
|
|
|
|
mkdir -p "$DIST_DIR"
|
|
|
|
echo "Building AVIF Maker v$VERSION"
|
|
echo "================================"
|
|
|
|
# Check if Docker images exist
|
|
if ! docker image inspect avif-maker-linux-x86_64 >/dev/null 2>&1; then
|
|
echo "Docker images not found. Run './scripts/build-all.sh --setup-docker' first."
|
|
exit 1
|
|
fi
|
|
|
|
# Linux x86_64
|
|
echo ""
|
|
echo "Building and packaging Linux x86_64..."
|
|
docker run --rm --platform linux/amd64 \
|
|
-v "$PROJECT_DIR:/build" \
|
|
-w /build \
|
|
avif-maker-linux-x86_64 \
|
|
bash -c "
|
|
set -e
|
|
echo 'Compiling...'
|
|
cargo build --release --target x86_64-unknown-linux-gnu
|
|
echo 'Stripping binary...'
|
|
strip target/x86_64-unknown-linux-gnu/release/avif-maker
|
|
echo 'Creating .deb package...'
|
|
cargo deb --target x86_64-unknown-linux-gnu --no-build -o dist/$VERSION/
|
|
echo 'Creating .rpm package...'
|
|
cargo generate-rpm --target x86_64-unknown-linux-gnu -o dist/$VERSION/
|
|
"
|
|
|
|
# Create tarball (can run on host)
|
|
echo "Creating tarball..."
|
|
tar -czvf "$DIST_DIR/avif-maker-$VERSION-linux-x86_64.tar.gz" \
|
|
-C target/x86_64-unknown-linux-gnu/release avif-maker
|
|
|
|
# Linux ARM64
|
|
# NOTE: ARM64 cross-compilation is currently disabled due to upstream zune-jpeg NEON bug.
|
|
# Build ARM64 natively on a Linux ARM64 system instead.
|
|
echo ""
|
|
echo "Skipping Linux ARM64 (upstream zune-jpeg bug with NEON cross-compilation)"
|
|
echo "To build ARM64, run natively on a Linux ARM64 system."
|
|
|
|
# Windows x86_64
|
|
echo ""
|
|
echo "Building Windows x86_64..."
|
|
docker run --rm --platform linux/amd64 \
|
|
-v "$PROJECT_DIR:/build" \
|
|
-w /build \
|
|
avif-maker-windows-x86_64 \
|
|
cargo build --release --target x86_64-pc-windows-gnu
|
|
|
|
zip -j "$DIST_DIR/avif-maker-$VERSION-windows-x86_64.zip" \
|
|
target/x86_64-pc-windows-gnu/release/avif-maker.exe
|
|
|
|
echo ""
|
|
echo "================================"
|
|
echo "Build complete! Artifacts in $DIST_DIR/"
|
|
echo ""
|
|
ls -la "$DIST_DIR/"
|