Skip to content

Commit

Permalink
Compile SDL and friends with cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
ankith26 committed Jan 4, 2024
1 parent 15da5f0 commit 7d81d29
Showing 1 changed file with 29 additions and 36 deletions.
65 changes: 29 additions & 36 deletions buildconfig/manylinux-build/docker_base/sdl_libs/build-sdl2-libs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,88 +27,81 @@ tar xzf ${SDL2}.tar.gz
# this is for renaming the tip.tar.gz
# mv SDL-* ${SDL2}

if [[ "$MAC_ARCH" == "arm64" ]]; then
# Build SDL with ARM optimisations on M1 macs
export M1_MAC_EXTRA_FLAGS="--enable-arm-simd --enable-arm-neon"
if [ "$(uname -m)" == "arm64" ] || [ "$(uname -m)" == "aarch64" ]; then
export ARM_EXTRA_FLAGS="-DSDL_ARMSIMD=1 -DSDL_ARMNEON=1"
fi

cd $SDL2
./configure --disable-video-vulkan $PG_BASE_CONFIGURE_FLAGS $M1_MAC_EXTRA_FLAGS
mkdir builddir && cd builddir

cmake -S .. -B . $PG_BASE_CMAKE_FLAGS -DSDL_VULKAN=0 $ARM_EXTRA_FLAGS
make
make install

cd ..
cd ../..


# Build SDL_image
tar xzf ${IMG2}.tar.gz
cd $IMG2
# The --disable-x-shared flags make it use standard dynamic linking rather than
mkdir builddir && cd builddir
# The SDL2IMAGE_DEPS_SHARED flag makes it use standard dynamic linking rather than
# dlopen-ing the library itself. This is important for when auditwheel moves
# libraries into the wheel.
if [[ "$OSTYPE" == "darwin"* ]]; then
# Mac OSX
# --disable-imageio is so it doesn't use the built in mac image loading.
# Since it is not as compatible with some jpg/png files.
export SDL_IMAGE_CONFIGURE=--disable-imageio
# disable imageio is so it doesn't use the built in mac image loading.
# Since it is not as compatible with some jpg/png files.
export SDL_IMAGE_CONFIGURE="-DSDL2IMAGE_BACKEND_IMAGEIO=0"
else
export SDL_IMAGE_CONFIGURE=
fi

# We prefer libpng and libjpeg-turbo over stb-image at the moment
# We also don't compile avif and jxl support at the moment
./configure $ARCHS_CONFIG_FLAG \
--disable-stb-image \
--disable-avif --disable-avif-shared \
--disable-jxl --disable-jxl-shared \
--enable-png --disable-png-shared \
--enable-jpg --disable-jpg-shared \
--enable-tif --disable-tif-shared \
--enable-webp --disable-webp-shared \
$SDL_IMAGE_CONFIGURE $PG_BASE_CONFIGURE_FLAGS
cmake -S .. -B . $PG_BASE_CMAKE_FLAGS $SDL_IMAGE_CONFIGURE \
-DSDL2IMAGE_DEPS_SHARED=0 -DSDL2IMAGE_VENDORED=0 \
-DSDL2IMAGE_TIF=1 -DSDL2IMAGE_WEBP=1 \
-DSDL2IMAGE_BACKEND_STB=0

make
make install

cd ..
cd ../..

# Build SDL_ttf
tar xzf ${TTF2}.tar.gz
cd $TTF2
mkdir builddir && cd builddir

# We already build freetype+harfbuzz for pygame.freetype
# So we make SDL_ttf use that instead of SDL_ttf vendored copies
./configure $PG_BASE_CONFIGURE_FLAGS --disable-freetype-builtin --disable-harfbuzz-builtin
cmake -S .. -B . $PG_BASE_CMAKE_FLAGS -DSDL2TTF_VENDORED=0 -DSDL2TTF_HARFBUZZ=1
make
make install

cd ..
cd ../..


# Build SDL_mixer
tar xzf ${MIX2}.tar.gz
cd $MIX2
mkdir builddir && cd builddir

# The --disable-x-shared flags make it use standard dynamic linking rather than
# The SDL2MIXER_DEPS_SHARED flag make it use standard dynamic linking rather than
# dlopen-ing the library itself. This is important for when auditwheel moves
# libraries into the wheel.
# We prefer libflac, mpg123 and ogg-vorbis over SDL vendored implementations
# at the moment. This can be changed later if need arises.
# For now, libmodplug is preferred over libxmp (but this may need changing
# in the future)
./configure $PG_BASE_CONFIGURE_FLAGS \
--disable-dependency-tracking \
--disable-music-ogg-stb --enable-music-ogg-vorbis \
--disable-music-flac-drflac --enable-music-flac-libflac \
--disable-music-mp3-drmp3 --enable-music-mp3-mpg123 \
--enable-music-mod-modplug --disable-music-mod-mikmod-shared \
--disable-music-mod-xmp --disable-music-mod-xmp-shared \
--enable-music-midi-fluidsynth --disable-music-midi-fluidsynth-shared \
--enable-music-opus --disable-music-opus-shared \
--disable-music-ogg-vorbis-shared \
--disable-music-ogg-tremor-shared \
--disable-music-flac-libflac-shared \
--disable-music-mp3-mpg123-shared \
--disable-music-mod-modplug-shared
cmake -S .. -B . $PG_BASE_CMAKE_FLAGS \
-DSDL2MIXER_DEPS_SHARED=0 -DSDL2MIXER_VENDORED=0 \
-DSDL2MIXER_FLAC_LIBFLAC=1 -DSDL2MIXER_FLAC_DRFLAC=0 \
-DSDL2MIXER_MOD_MODPLUG=1 -DSDL2MIXER_MOD_XMP=0 \
-DSDL2MIXER_MP3_MPG123=1 -DSDL2MIXER_MP3_DRMP3=0 \
-DSDL2MIXER_VORBIS=VORBISFILE -DSDL2MIXER_VORBIS_VORBISFILE_SHARED=0 \
-DSDL2MIXER_OPUS_SHARED=0

make
make install
Expand Down

0 comments on commit 7d81d29

Please sign in to comment.