Files
eepp/projects/mingw32/make.sh
Martín Lucas Golini 7ec44b1547 Added pending SDL3 script support for MSVC and mingw. It can now be built without previously installing SDL3 manually, it resolves the dependency the same way we do for SDL2.
Scripts now accept the CLI argument: `--backend=sdl3` to force building with SDL3 backend. ecode build script will just generate the package with SDL3.
2026-06-08 21:42:42 -03:00

114 lines
2.7 KiB
Bash
Executable File

#!/bin/bash
cd "$(dirname "$0")" || exit
ARCH=32
BACKEND=sdl2
MAKE_ARGS=()
for i in "$@"; do
case $i in
config=*)
CONFIG="${i#*=}"
MAKE_ARGS+=("$i")
;;
--backend=*)
BACKEND="${i#*=}"
;;
*)
MAKE_ARGS+=("$i")
;;
esac
done
set -- "${MAKE_ARGS[@]}"
PREMAKE5_ARCH=
if [[ "$CONFIG" == *"x86_64"* ]]; then
ARCH=64
elif [[ "$CONFIG" == *"arm64"* && "$(uname -m)" == "x86_64" ]]; then
export CC="aarch64-w64-mingw32-gcc"
export CXX="aarch64-w64-mingw32-g++"
export AR="aarch64-w64-mingw32-ar"
PREMAKE5_ARCH="--arch=arm64"
if ! command -v aarch64-w64-mingw32-gcc &> /dev/null \
|| ! command -v aarch64-w64-mingw32-g++ &> /dev/null \
|| ! command -v aarch64-w64-mingw32-ar &> /dev/null
then
LLVM_MINGW_V="20241015"
URL="https://github.com/mstorsjo/llvm-mingw/releases/download/$LLVM_MINGW_V/llvm-mingw-$LLVM_MINGW_V-ucrt-ubuntu-20.04-x86_64.tar.xz"
FILE_NAME="llvm-mingw-$LLVM_MINGW_V-ucrt-ubuntu-20.04-x86_64"
TAR_FILE_NAME="$FILE_NAME.tar.xz"
RENAMED_FOLDER="llvm-mingw"
BIN_PATH="$(pwd)/$RENAMED_FOLDER/bin"
if [[ ! -f "$TAR_FILE_NAME" ]]; then
echo "Downloading $TAR_FILE_NAME..."
curl -LO "$URL" || { echo "Download failed!"; exit 1; }
else
echo "$TAR_FILE_NAME already exists. Skipping download."
fi
if [[ ! -d "$RENAMED_FOLDER" ]]; then
echo "Extracting $TAR_FILE_NAME..."
tar -xf "$TAR_FILE_NAME" || { echo "Extraction failed!"; exit 1; }
mv "$FILE_NAME" "$RENAMED_FOLDER"
else
echo "$RENAMED_FOLDER directory already exists. Skipping extraction."
fi
export PATH="$PATH:$BIN_PATH"
echo "Added $BIN_PATH to PATH."
fi
fi
detect_backend_arg()
{
if [[ "${BACKEND,,}" == "sdl3" ]]; then
echo "SDL3"
else
echo "SDL2"
fi
}
detect_backend_name()
{
if [[ "${BACKEND,,}" == "sdl3" ]]; then
echo "sdl3"
else
echo "sdl2"
fi
}
PREMAKE5_ARGS="--file=../../premake5.lua --os=windows --cc=gcc --windows-mingw-build --with-backend=$(detect_backend_arg) $PREMAKE5_ARCH gmake"
if command -v premake5 &> /dev/null
then
premake5 $PREMAKE5_ARGS
elif [ -f ../../premake5 ]; then
../../premake5 $PREMAKE5_ARGS
else
echo "premake5 is not available. Please install one."
exit 1
fi
if [[ "$CONFIG" == *"arm64"* ]]; then
bash ./build_$(detect_backend_name).sh --arch=arm64 || exit 1
else
if command -v x86_64-w64-mingw32-gcc-posix &> /dev/null; then
export CC=x86_64-w64-mingw32-gcc-posix
export CXX=x86_64-w64-mingw32-g++-posix
else
export CC=x86_64-w64-mingw32-gcc
export CXX=x86_64-w64-mingw32-g++
fi
fi
cd ../../make/windows/ || exit
if command -v mingw"$ARCH"-make &> /dev/null
then
mingw"$ARCH"-make "$@"
else
# Use x86_64 or arm64 toolchain based on CONFIG
make "$@"
fi