Skip to content

Commit

Permalink
CI: build custom SDL
Browse files Browse the repository at this point in the history
  • Loading branch information
black-sliver committed Dec 29, 2024
1 parent 53ed794 commit 942b8ec
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/binaries.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ on:
paths:
- '.github/workflows/binaries.yaml'
- 'macosx/*.sh'
- 'win32/*.sh'
pull_request:
paths:
- '.github/workflows/binaries.yaml'
- 'macosx/*.sh'
- 'win32/*.sh'

jobs:

Expand Down Expand Up @@ -118,6 +120,8 @@ jobs:
coreutils
make
mingw-w64-x86_64-toolchain
autoconf-wrapper
mingw-w64-x86_64-autotools
mingw64/mingw-w64-x86_64-SDL2
mingw64/mingw-w64-x86_64-SDL2_image
mingw64/mingw-w64-x86_64-SDL2_ttf
Expand All @@ -134,6 +138,16 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Build libs
shell: msys2 {0}
run: |
mkdir -p win32-lib-src
cd win32-lib-src
../win32/native-compile-libs-win32.sh
- name: Uninstall system libs
shell: msys2 {0}
run: |
pacman -R --noconfirm mingw-w64-x86_64-SDL2 mingw-w64-x86_64-SDL2_image mingw-w64-x86_64-SDL2_ttf
- name: Build RELEASE
shell: msys2 {0}
run: make native CONF=RELEASE -j2
Expand Down
77 changes: 77 additions & 0 deletions win32/native-compile-libs-win32.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/bin/bash

SDL_SRC=SDL2-2.30.10
SDL_URL="https://github.com/libsdl-org/SDL/releases/download/release-2.30.10/SDL2-2.30.10.tar.gz"
IMAGE_SRC=SDL2_image-2.8.4
IMAGE_URL="https://github.com/libsdl-org/SDL_image/releases/download/release-2.8.4/SDL2_image-2.8.4.tar.gz"
TTF_SRC=SDL2_ttf-2.22.0
TTF_URL="https://github.com/libsdl-org/SDL_ttf/releases/download/release-2.22.0/SDL2_ttf-2.22.0.tar.gz"

# IMPORTANT: dynapi has to be disabled in SDL2-*/src/dynapi/SDL_dynapi.h
# loadso is now required for hardware renderers
# TODO: disable dynapi using sed?
# TODO: automate copying of output

ARCH=`gcc -dumpmachine | sed "s/-.*$//"`
OUTPUT_FLAGS="--enable-static --disable-shared" # --with-gnu-ld"
IMAGE_FEATURE_FLAGS="--disable-sdltest --disable-freetypetest"
TTF_FEATURE_FLAGS="--disable-sdltest --disable-avif --disable-jpg-shared --disable-save-jpg --disable-jxl --disable-jxl-shared --disable-lbm --disable-pcx --disable-png-shared --disable-save-png --disable-pnm --disable-svg --disable-tga --disable-tif --disable-tif-shared --disable-xcf --disable-xpm --disable-xv --disable-goi"
SDL_FEATURE_FLAGS="--disable-alsatest --disable-esdtest --disable-audio --disable-joystick --disable-haptic --disable-sensor --disable-power --disable-filesystem --disable-cpuinfo --disable-jack --disable-esd --disable-pipewire --disable-pulseaudio --disable-arts --disable-nas --disable-sndio --disable-fusionsound --disable-diskaudio --disable-dummyaudio --disable-libsamplerate --disable-libudev"
#RELEASE_FLAGS="-ffunction-sections -fdata-sections -Wl,--gc-sections -Os -s"
RELEASE_FLAGS="-ffunction-sections -fdata-sections -Os"

build() {
[ -z "$2" ] && exit 1
SRC="$1"
TARGET="$3"
FEATURE_FLAGS="$4"
BUILD="build/$TARGET/$2"

echo "Building $2 on $ARCH"

CONFIGURE_FLAGS="$OUTPUT_FLAGS $FEATURE_FLAGS"
echo "$SRC -> $BUILD"
if [ -d "$BUILD" ]; then rm -R "$BUILD" ; fi
mkdir -p "$BUILD"
cd "$BUILD"
../../../$SRC/configure $CONFIGURE_FLAGS
make -j4
cd ../../..
}

# Download missing sources
if [ ! -d $SDL_SRC ]; then
wget "$SDL_URL"
tar -xzvf "$SDL_SRC.tar.gz"
fi
if [ ! -d $IMAGE_SRC ]; then
wget "$IMAGE_URL"
tar -xzvf "$IMAGE_SRC.tar.gz"
cd "$IMAGE_SRC"
autoreconf -f -i # for whatever reason this seems to be required
cd ..
fi
if [ ! -d $TTF_SRC ]; then
wget "$TTF_URL"
tar -xzvf "$TTF_SRC.tar.gz"
fi

build $SDL_SRC "sdl" "native" "$SDL_FEATURE_FLAGS"
build $IMAGE_SRC "sdl2_image" "native" "$IMAGE_FEATURE_FLAGS"
build $TTF_SRC "sdl2_ttf" "native" "$TTF_FEATURE_FLAGS"

DST=`realpath "../win32-lib/$ARCH"`
echo "build/... -> $DST"
mkdir -p $DST/include/SDL2
mkdir -p $DST/lib
cp $SDL_SRC/include/* "$DST/include/SDL2/"
cp $IMAGE_SRC/include/* "$DST/include/SDL2/"
cp $TTF_SRC/*.h "$DST/include/SDL2/"
cp build/native/sdl/include/* "$DST/include/SDL2/"
cp build/native/sdl/build/.libs/* "$DST/lib/"
cp build/native/sdl/build/*.la "$DST/lib/"
cp build/native/sdl2_image/.libs/* "$DST/lib/"
cp build/native/sdl2_image/*.la "$DST/lib/"
cp build/native/sdl2_ttf/.libs/* "$DST/lib/"
cp build/native/sdl2_ttf/*.la "$DST/lib/"
ls $DST/*

0 comments on commit 942b8ec

Please sign in to comment.