Skip to content

Commit a02d60e

Browse files
committed
Build SDL and friends with cmake
1 parent a7bc8a2 commit a02d60e

File tree

1 file changed

+32
-44
lines changed

1 file changed

+32
-44
lines changed

buildconfig/manylinux-build/docker_base/sdl_libs/build-sdl2-libs.sh

Lines changed: 32 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ curl -sL --retry 10 https://github.com/libsdl-org/SDL_mixer/releases/download/re
2020
curl -sL --retry 10 https://github.com/libsdl-org/SDL_ttf/releases/download/release-$TTF2_VER/$TTF2.tar.gz > ${TTF2}.tar.gz
2121
sha512sum -c sdl2.sha512
2222

23-
23+
# On mac/manylinux we have to make use of standard dynamic linking rather than
24+
# dlopen-ing the library itself. This is important for when auditwheel/delocate
25+
# moves libraries into the wheel.
26+
PG_DEPS_SHARED=0
2427

2528
# Build SDL
2629
tar xzf ${SDL2}.tar.gz
@@ -30,87 +33,72 @@ tar xzf ${SDL2}.tar.gz
3033

3134
if [[ "$MAC_ARCH" == "arm64" ]]; then
3235
# Build SDL with ARM optimisations on M1 macs
33-
export M1_MAC_EXTRA_FLAGS="--enable-arm-simd --enable-arm-neon"
36+
export ARM_EXTRA_FLAGS="-DSDL_ARMSIMD=1 -DSDL_ARMNEON=1"
3437
fi
3538

3639
cd $SDL2
37-
./configure --disable-video-vulkan $PG_BASE_CONFIGURE_FLAGS $M1_MAC_EXTRA_FLAGS
40+
mkdir builddir && cd builddir
41+
42+
cmake -S .. -B . $PG_BASE_CMAKE_FLAGS -DSDL_VULKAN=0 $ARM_EXTRA_FLAGS
3843
make
3944
make install
4045

41-
cd ..
46+
cd ../..
4247

4348

4449
# Build SDL_image
4550
tar xzf ${IMG2}.tar.gz
4651
cd $IMG2
47-
# The --disable-x-shared flags make it use standard dynamic linking rather than
48-
# dlopen-ing the library itself. This is important for when auditwheel moves
49-
# libraries into the wheel.
50-
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
51-
# linux
52-
export SDL_IMAGE_CONFIGURE=
53-
elif [[ "$OSTYPE" == "darwin"* ]]; then
52+
if [[ "$OSTYPE" == "darwin"* ]]; then
5453
# Mac OSX
55-
# --disable-imageio is so it doesn't use the built in mac image loading.
56-
# Since it is not as compatible with some jpg/png files.
57-
export SDL_IMAGE_CONFIGURE=--disable-imageio
54+
# disable imageio is so it doesn't use the built in mac image loading.
55+
# Since it is not as compatible with some jpg/png files.
56+
export SDL_IMAGE_CONFIGURE="-DSDL2IMAGE_BACKEND_IMAGEIO=0"
57+
else
58+
export SDL_IMAGE_CONFIGURE=
5859
fi
5960

61+
mkdir builddir && cd builddir
62+
6063
# We prefer libpng and libjpeg-turbo over stb-image at the moment
6164
# We also don't compile avif and jxl support at the moment
62-
./configure $ARCHS_CONFIG_FLAG \
63-
--disable-stb-image \
64-
--disable-avif --disable-avif-shared \
65-
--disable-jxl --disable-jxl-shared \
66-
--enable-png --disable-png-shared \
67-
--enable-jpg --disable-jpg-shared \
68-
--enable-tif --disable-tif-shared \
69-
--enable-webp --disable-webp-shared \
70-
$SDL_IMAGE_CONFIGURE $PG_BASE_CONFIGURE_FLAGS
65+
cmake -S .. -B . $PG_BASE_CMAKE_FLAGS $SDL_IMAGE_CONFIGURE \
66+
-DSDL2IMAGE_DEPS_SHARED=$PG_DEPS_SHARED -DSDL2IMAGE_VENDORED=0 \
67+
-DSDL2IMAGE_BACKEND_STB=0 -DSDL2IMAGE_AVIF=0 -DSDL2IMAGE_JXL=0 \
68+
-DSDL2IMAGE_TIF=1 -DSDL2IMAGE_WEBP=1
69+
7170
make
7271
make install
7372

74-
cd ..
73+
cd ../..
7574

7675
# Build SDL_ttf
7776
tar xzf ${TTF2}.tar.gz
7877
cd $TTF2
78+
mkdir builddir && cd builddir
7979

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

86-
cd ..
86+
cd ../..
8787

8888

8989
# Build SDL_mixer
9090
tar xzf ${MIX2}.tar.gz
9191
cd $MIX2
92+
mkdir builddir && cd builddir
9293

93-
# The --disable-x-shared flags make it use standard dynamic linking rather than
94-
# dlopen-ing the library itself. This is important for when auditwheel moves
95-
# libraries into the wheel.
9694
# We prefer libflac, mpg123 and ogg-vorbis over SDL vendored implementations
9795
# at the moment. This can be changed later if need arises.
9896
# We don't build with libgme for now
99-
./configure $PG_BASE_CONFIGURE_FLAGS \
100-
--disable-dependency-tracking \
101-
--disable-music-ogg-stb --enable-music-ogg-vorbis \
102-
--disable-music-flac-drflac --enable-music-flac-libflac \
103-
--disable-music-mp3-drmp3 --disable-music-mp3-minimp3 --enable-music-mp3-mpg123 \
104-
--disable-music-mod-modplug \
105-
--enable-music-mod-xmp --disable-music-mod-xmp-shared \
106-
--enable-music-midi-fluidsynth --disable-music-midi-fluidsynth-shared \
107-
--enable-music-opus --disable-music-opus-shared \
108-
--enable-music-wavpack --disable-music-wavpack-shared \
109-
--disable-music-ogg-vorbis-shared \
110-
--disable-music-ogg-tremor \
111-
--disable-music-flac-libflac-shared \
112-
--disable-music-mp3-mpg123-shared \
113-
--disable-music-gme
97+
cmake -S .. -B . $PG_BASE_CMAKE_FLAGS \
98+
-DSDL2MIXER_DEPS_SHARED=$PG_DEPS_SHARED -DSDL2MIXER_VENDORED=0 \
99+
-DSDL2MIXER_FLAC_LIBFLAC=1 -DSDL2MIXER_FLAC_DRFLAC=0 \
100+
-DSDL2MIXER_MP3_MPG123=1 -DSDL2MIXER_MP3_MINIMP3=0 \
101+
-DSDL2MIXER_VORBIS=VORBISFILE
114102

115103
make
116104
make install

0 commit comments

Comments
 (0)