summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
Diffstat (limited to 'script')
-rw-r--r--script/Dockerfile.x8678
-rwxr-xr-xscript/build-release.sh56
-rwxr-xr-xscript/build.sh160
3 files changed, 238 insertions, 56 deletions
diff --git a/script/Dockerfile.x86 b/script/Dockerfile.x86
new file mode 100644
index 000000000..0d81c0d50
--- /dev/null
+++ b/script/Dockerfile.x86
@@ -0,0 +1,78 @@
+# Dockerfile for x86 (32-bit) builds
+# Uses native Debian i386 image (Ubuntu 22.04+ dropped i386 support)
+FROM --platform=linux/386 debian:bookworm
+
+ENV DEBIAN_FRONTEND=noninteractive
+ENV VCPKG_ROOT=/opt/vcpkg
+ENV PATH="${VCPKG_ROOT}:${PATH}"
+
+# Install base dependencies
+RUN apt-get update -y && apt-get -y upgrade && \
+ apt-get -y install \
+ build-essential \
+ gcc \
+ g++ \
+ git \
+ ninja-build \
+ curl \
+ zip \
+ unzip \
+ tar \
+ pkg-config \
+ wget \
+ file \
+ autoconf \
+ automake \
+ libtool \
+ python3 \
+ cmake \
+ libx11-dev \
+ libxrandr-dev \
+ libxi-dev \
+ libxinerama-dev \
+ libxcursor-dev \
+ libgl1-mesa-dev \
+ libopengl-dev \
+ libwayland-dev \
+ libxkbcommon-dev \
+ libasound2-dev \
+ libpulse-dev \
+ libudev-dev \
+ libdbus-1-dev \
+ libogg-dev \
+ libvorbis-dev \
+ libpng-dev \
+ zlib1g-dev \
+ libsdl2-dev \
+ nlohmann-json3-dev \
+ libspdlog-dev \
+ libboost-dev
+
+# Install tinyxml2 from source
+RUN wget https://github.com/leethomason/tinyxml2/archive/refs/tags/10.0.0.tar.gz && \
+ tar -xzf 10.0.0.tar.gz && \
+ cd tinyxml2-10.0.0 && \
+ mkdir -p build && cd build && \
+ cmake .. && \
+ make -j$(nproc) && \
+ make install && \
+ ldconfig && \
+ cd ../.. && \
+ rm -rf 10.0.0.tar.gz tinyxml2-10.0.0
+
+# Install libzip from source (system package has broken CMake config)
+RUN wget https://github.com/nih-at/libzip/releases/download/v1.10.1/libzip-1.10.1.tar.gz && \
+ tar -xzf libzip-1.10.1.tar.gz && \
+ cd libzip-1.10.1 && \
+ mkdir -p build && cd build && \
+ cmake .. -DENABLE_COMMONCRYPTO=OFF -DENABLE_GNUTLS=OFF -DENABLE_MBEDTLS=OFF -DENABLE_OPENSSL=OFF -DBUILD_TOOLS=OFF -DBUILD_DOC=OFF && \
+ make -j$(nproc) && \
+ make install && \
+ ldconfig && \
+ cd ../.. && \
+ rm -rf libzip-1.10.1.tar.gz libzip-1.10.1
+
+# Note: vcpkg is not available for i386 (no prebuilt binary, bootstrap fails)
+# Using system packages instead - static linking handled by CMake
+
+WORKDIR /project
diff --git a/script/build-release.sh b/script/build-release.sh
deleted file mode 100755
index 084b8c3c2..000000000
--- a/script/build-release.sh
+++ /dev/null
@@ -1,56 +0,0 @@
-#!/bin/bash
-set -e
-
-# Script to build SpaghettiKart using Docker
-# Usage: ./docker/build.sh [Release|Debug]
-
-SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
-PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
-
-BUILD_TYPE="${1:-Release}"
-BUILD_DIR="build-docker"
-IMAGE_NAME="spaghettikart-builder"
-USER_ID=$(id -u)
-GROUP_ID=$(id -g)
-
-cd "$PROJECT_DIR"
-
-# Build Docker image
-echo "Building Docker image..."
-docker build -t "${IMAGE_NAME}" -f script/Dockerfile .
-
-# Clean build directory if it contains incompatible cache
-if [[ -f "${BUILD_DIR}/CMakeCache.txt" ]] && grep -q "/home/coco" "${BUILD_DIR}/CMakeCache.txt" 2>/dev/null; then
- echo "Cleaning incompatible build cache..."
- rm -rf "${BUILD_DIR}"
-fi
-
-# Run build in Docker
-echo "Building in Docker container..."
-docker run --rm \
- -v "$(pwd):/project" \
- -e BUILD_TYPE="${BUILD_TYPE}" \
- -e USER_ID="${USER_ID}" \
- -e GROUP_ID="${GROUP_ID}" \
- "${IMAGE_NAME}" \
- bash -c "
- # Copy vcpkg.json and install dependencies
- cp vcpkg.json /tmp/vcpkg.json && \
- cd /tmp && \
- \${VCPKG_ROOT}/vcpkg install --triplet x64-linux && \
- cd /project && \
- cmake -B ${BUILD_DIR} -G Ninja \
- -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
- -DCMAKE_TOOLCHAIN_FILE=/opt/vcpkg/scripts/buildsystems/vcpkg.cmake \
- -DVCPKG_TARGET_TRIPLET=x64-linux && \
- cmake --build ${BUILD_DIR} --parallel && \
- cp -f spaghetti.o2r ${BUILD_DIR}/ 2>/dev/null || true && \
- cp -f mk64.o2r ${BUILD_DIR}/ 2>/dev/null || true && \
- cd ${BUILD_DIR} && cpack -G External && \
- chown -R ${USER_ID}:${GROUP_ID} /project/${BUILD_DIR} /project/logs 2>/dev/null || true
- "
-
-echo ""
-echo "Build complete!"
-echo "Executable: ${BUILD_DIR}/Spaghettify"
-ls -1 "${BUILD_DIR}"/*.appimage 2>/dev/null && echo "AppImage generated successfully!" || echo "Note: AppImage generation may have failed"
diff --git a/script/build.sh b/script/build.sh
new file mode 100755
index 000000000..4395f96f6
--- /dev/null
+++ b/script/build.sh
@@ -0,0 +1,160 @@
+#!/bin/bash
+set -e
+
+# Unified build script for SpaghettiKart
+#
+# Usage:
+# ./script/build.sh # Build x64 Release (default)
+# ./script/build.sh x64 # Build x64 Release
+# ./script/build.sh x86 # Build x86 32-bit Release
+# ./script/build.sh x64 Debug # Build x64 Debug
+# ./script/build.sh all # Build both architectures
+# ./script/build.sh x64 Release appimage # Build x64 with AppImage
+
+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
+
+ARCH="${1:-x64}"
+BUILD_TYPE="${2:-Release}"
+PACKAGE="${3:-}" # Optional: "appimage" to generate AppImage
+USER_ID=$(id -u)
+GROUP_ID=$(id -g)
+
+cd "$PROJECT_DIR"
+
+build_arch() {
+ local arch=$1
+ local build_type=$2
+ local package=$3
+ local build_dir="build-docker-${arch}"
+ local image_name="spaghettikart-${arch}"
+ local dockerfile=""
+ local platform=""
+ local triplet=""
+
+ echo "========================================"
+ echo "Building ${arch} ${build_type}"
+ echo "========================================"
+
+ # Set architecture-specific options
+ if [ "$arch" = "x86" ]; then
+ dockerfile="script/Dockerfile.x86"
+ platform="--platform linux/386"
+ triplet="x86-linux"
+ # Ensure QEMU is set up for i386 emulation
+ docker run --rm --privileged multiarch/qemu-user-static --reset -p yes 2>/dev/null || true
+ else
+ dockerfile="script/Dockerfile"
+ triplet="x64-linux"
+ fi
+
+ # Build Docker image
+ echo "Building Docker image for ${arch}..."
+ docker build \
+ ${platform} \
+ -t "${image_name}" \
+ -f "${dockerfile}" .
+
+ # Clean build directory if it contains incompatible cache
+ if [[ -f "${build_dir}/CMakeCache.txt" ]]; then
+ echo "Cleaning existing build cache..."
+ rm -rf "${build_dir}"
+ fi
+
+ # Build package command if requested
+ local package_cmd=""
+ if [ "$package" = "appimage" ]; then
+ package_cmd="&& cd ${build_dir} && cpack -G External"
+ fi
+
+ # Run build in Docker
+ echo "Building in Docker container..."
+
+ # Different build commands for x64 (with vcpkg) and x86 (without vcpkg)
+ if [ "$arch" = "x86" ]; then
+ # x86: No vcpkg available, use system packages
+ docker run --rm \
+ ${platform} \
+ -v "$(pwd):/project" \
+ -e BUILD_TYPE="${build_type}" \
+ -e USER_ID="${USER_ID}" \
+ -e GROUP_ID="${GROUP_ID}" \
+ "${image_name}" \
+ bash -c "
+ cmake -B ${build_dir} -G Ninja \
+ -DCMAKE_BUILD_TYPE=${build_type} && \
+ cmake --build ${build_dir} --parallel && \
+ cp -f spaghetti.o2r ${build_dir}/ 2>/dev/null || true && \
+ cp -f mk64.o2r ${build_dir}/ 2>/dev/null || true ${package_cmd} && \
+ chown -R ${USER_ID}:${GROUP_ID} /project/${build_dir} 2>/dev/null || true
+ "
+ else
+ # x64: Use vcpkg for static linking
+ docker run --rm \
+ ${platform} \
+ -v "$(pwd):/project" \
+ -e BUILD_TYPE="${build_type}" \
+ -e USER_ID="${USER_ID}" \
+ -e GROUP_ID="${GROUP_ID}" \
+ "${image_name}" \
+ bash -c "
+ # Install vcpkg dependencies
+ if [ -f vcpkg.json ]; then
+ cp vcpkg.json /tmp/vcpkg.json && \
+ cd /tmp && \
+ \${VCPKG_ROOT}/vcpkg install --triplet ${triplet} 2>/dev/null || true && \
+ cd /project
+ fi && \
+ cmake -B ${build_dir} -G Ninja \
+ -DCMAKE_BUILD_TYPE=${build_type} \
+ -DCMAKE_TOOLCHAIN_FILE=/opt/vcpkg/scripts/buildsystems/vcpkg.cmake \
+ -DVCPKG_TARGET_TRIPLET=${triplet} && \
+ cmake --build ${build_dir} --parallel && \
+ cp -f spaghetti.o2r ${build_dir}/ 2>/dev/null || true && \
+ cp -f mk64.o2r ${build_dir}/ 2>/dev/null || true ${package_cmd} && \
+ chown -R ${USER_ID}:${GROUP_ID} /project/${build_dir} 2>/dev/null || true
+ "
+ fi
+
+ echo ""
+ echo "${arch} build complete!"
+ echo "Executable: ${build_dir}/Spaghettify"
+ if [ -f "${build_dir}/Spaghettify" ]; then
+ file "${build_dir}/Spaghettify"
+ fi
+ if [ "$package" = "appimage" ]; then
+ ls -1 "${build_dir}"/*.appimage 2>/dev/null && echo "AppImage generated!" || echo "Note: AppImage may have failed"
+ fi
+ echo ""
+}
+
+case "$ARCH" in
+ x64|x86)
+ build_arch "$ARCH" "$BUILD_TYPE" "$PACKAGE"
+ ;;
+ all)
+ build_arch x64 "$BUILD_TYPE" "$PACKAGE"
+ build_arch x86 "$BUILD_TYPE" "$PACKAGE"
+ ;;
+ *)
+ echo "Usage: $0 [x64|x86|all] [Release|Debug] [appimage]"
+ echo ""
+ echo "Architectures:"
+ echo " x64 - x86_64 64-bit (default)"
+ echo " x86 - x86 32-bit"
+ echo " all - Build both architectures"
+ echo ""
+ echo "Options:"
+ echo " appimage - Generate AppImage package"
+ echo ""
+ echo "Examples:"
+ echo " $0 # Build x64 Release"
+ echo " $0 x86 # Build x86 Release"
+ echo " $0 x64 Release appimage # Build x64 with AppImage"
+ exit 1
+ ;;
+esac
+
+echo "========================================"
+echo "All builds completed successfully!"
+echo "========================================"