-
-
Notifications
You must be signed in to change notification settings - Fork 164
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3141 from pygame-community/sdl3_compile
Add meson flag for compiling with SDL3
- Loading branch information
Showing
14 changed files
with
320 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
# SDL3 porting is WIP | ||
name: SDL3 build | ||
|
||
# Run CI only when a release is created, on changes to main branch, or any PR | ||
# to main. Do not run CI on any other branch. Also, skip any non-source changes | ||
# from running on CI | ||
on: | ||
push: | ||
branches: main | ||
paths-ignore: | ||
- 'docs/**' | ||
- 'examples/**' | ||
- '.gitignore' | ||
- '*.rst' | ||
- '*.md' | ||
- '.github/workflows/*.yml' | ||
# re-include current file to not be excluded | ||
- '!.github/workflows/build-sdl3.yml' | ||
|
||
pull_request: | ||
branches: main | ||
paths-ignore: | ||
- 'docs/**' | ||
- 'examples/**' | ||
- '.gitignore' | ||
- '*.rst' | ||
- '*.md' | ||
- '.github/workflows/*.yml' | ||
# re-include current file to not be excluded | ||
- '!.github/workflows/build-sdl3.yml' | ||
|
||
# the github release drafter can call this workflow | ||
workflow_call: | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }}-ubuntu-sdist | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
build: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false # if a particular matrix build fails, don't skip the rest | ||
matrix: | ||
os: [ubuntu-24.04, windows-latest, macos-14] | ||
|
||
env: | ||
# Pip now forces us to either make a venv or set this flag, so we will do | ||
# this | ||
PIP_BREAK_SYSTEM_PACKAGES: 1 | ||
# We are using dependencies installed from apt | ||
PG_DEPS_FROM_SYSTEM: 1 | ||
|
||
steps: | ||
- uses: actions/[email protected] | ||
|
||
- name: Install deps (linux) | ||
if: matrix.os == 'ubuntu-24.04' | ||
run: sudo apt-get install libfreetype6-dev libportmidi-dev python3-dev | ||
|
||
- name: Install deps (mac) | ||
if: matrix.os == 'macos-14' | ||
run: brew install freetype portmidi | ||
|
||
# taken from https://wiki.libsdl.org/SDL3/Installation | ||
- name: Install SDL3 | ||
if: matrix.os != 'windows-latest' | ||
run: | | ||
git clone https://github.com/libsdl-org/SDL | ||
cd SDL | ||
mkdir build | ||
cd build | ||
cmake -DCMAKE_BUILD_TYPE=Release .. | ||
cmake --build . --config Release --parallel | ||
sudo cmake --install . --config Release | ||
- name: Make sdist and install it | ||
run: > | ||
python3 -m pip install . -v -Csetup-args=-Dsdl_api=3 | ||
-Csetup-args=-Dimage=disabled | ||
-Csetup-args=-Dmixer=disabled | ||
-Csetup-args=-Dfont=disabled | ||
# - name: Run tests | ||
# env: | ||
# SDL_VIDEODRIVER: "dummy" | ||
# SDL_AUDIODRIVER: "disk" | ||
# run: python3 -m pygame.tests -v --exclude opengl,music,timing --time_out 300 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -78,6 +78,16 @@ endif | |
|
||
pg_dir = py.get_install_dir() / pg | ||
|
||
sdl_api = get_option('sdl_api') | ||
sdl = 'SDL@0@'.format(sdl_api) | ||
sdl_mixer = '@0@_mixer'.format(sdl) | ||
sdl_ttf = '@0@_ttf'.format(sdl) | ||
sdl_image = '@0@_image'.format(sdl) | ||
|
||
if sdl_api == 3 | ||
add_global_arguments('-DPG_SDL3=1', language: 'c') | ||
endif | ||
|
||
pg_inc_dirs = [] | ||
pg_lib_dirs = [] | ||
if plat == 'win' and host_machine.cpu_family().startswith('x86') | ||
|
@@ -99,60 +109,68 @@ if plat == 'win' and host_machine.cpu_family().startswith('x86') | |
) | ||
endif | ||
|
||
sdl_ver = '2.30.7' | ||
sdl_ver = (sdl_api == 3) ? '3.1.3' : '2.30.7' | ||
sdl_image_ver = '2.8.2' | ||
sdl_mixer_ver = '2.8.0' | ||
sdl_ttf_ver = '2.22.0' | ||
|
||
dlls = [] | ||
|
||
# SDL2 | ||
sdl_dir = prebuilt_dir / 'SDL2-@0@'.format(sdl_ver) | ||
# SDL | ||
sdl_dir = prebuilt_dir / '@0@-@1@'.format(sdl, sdl_ver) | ||
sdl_lib_dir = sdl_dir / 'lib' / arch_suffix | ||
pg_inc_dirs += fs.relative_to(sdl_dir / 'include', base_dir) | ||
pg_lib_dirs += sdl_lib_dir | ||
dlls += sdl_lib_dir / 'SDL2.dll' | ||
|
||
# SDL2_image | ||
sdl_image_dir = prebuilt_dir / 'SDL2_image-@0@'.format(sdl_image_ver) | ||
sdl_image_lib_dir = sdl_image_dir / 'lib' / arch_suffix | ||
pg_inc_dirs += fs.relative_to(sdl_image_dir / 'include', base_dir) | ||
pg_lib_dirs += sdl_image_lib_dir | ||
dlls += [ | ||
sdl_image_lib_dir / 'SDL2_image.dll', | ||
sdl_image_lib_dir / 'optional' / 'libjpeg-62.dll', | ||
sdl_image_lib_dir / 'optional' / 'libpng16-16.dll', | ||
sdl_image_lib_dir / 'optional' / 'libtiff-5.dll', | ||
sdl_image_lib_dir / 'optional' / 'libwebp-7.dll', | ||
sdl_image_lib_dir / 'optional' / 'libwebpdemux-2.dll', | ||
] | ||
|
||
# SDL2_mixer | ||
sdl_mixer_dir = prebuilt_dir / 'SDL2_mixer-@0@'.format(sdl_mixer_ver) | ||
sdl_mixer_lib_dir = sdl_mixer_dir / 'lib' / arch_suffix | ||
pg_inc_dirs += fs.relative_to(sdl_mixer_dir / 'include', base_dir) | ||
pg_lib_dirs += sdl_mixer_lib_dir | ||
dlls += [ | ||
sdl_mixer_lib_dir / 'SDL2_mixer.dll', | ||
sdl_mixer_lib_dir / 'optional' / 'libogg-0.dll', | ||
sdl_mixer_lib_dir / 'optional' / 'libopus-0.dll', | ||
sdl_mixer_lib_dir / 'optional' / 'libopusfile-0.dll', | ||
sdl_mixer_lib_dir / 'optional' / 'libwavpack-1.dll', | ||
sdl_mixer_lib_dir / 'optional' / 'libxmp.dll', | ||
] | ||
|
||
# SDL2_ttf | ||
sdl_ttf_dir = prebuilt_dir / 'SDL2_ttf-@0@'.format(sdl_ttf_ver) | ||
sdl_ttf_lib_dir = sdl_ttf_dir / 'lib' / arch_suffix | ||
pg_inc_dirs += fs.relative_to(sdl_ttf_dir / 'include', base_dir) | ||
pg_lib_dirs += sdl_ttf_lib_dir | ||
dlls += sdl_ttf_lib_dir / 'SDL2_ttf.dll' | ||
dlls += sdl_lib_dir / '@[email protected]'.format(sdl) | ||
|
||
# SDL_image | ||
if get_option('image').enabled() | ||
sdl_image_dir = prebuilt_dir / '@0@-@1@'.format(sdl_image, sdl_image_ver) | ||
sdl_image_lib_dir = sdl_image_dir / 'lib' / arch_suffix | ||
pg_inc_dirs += fs.relative_to(sdl_image_dir / 'include', base_dir) | ||
pg_lib_dirs += sdl_image_lib_dir | ||
dlls += [ | ||
sdl_image_lib_dir / '@[email protected]'.format(sdl_image), | ||
sdl_image_lib_dir / 'optional' / 'libjpeg-62.dll', | ||
sdl_image_lib_dir / 'optional' / 'libpng16-16.dll', | ||
sdl_image_lib_dir / 'optional' / 'libtiff-5.dll', | ||
sdl_image_lib_dir / 'optional' / 'libwebp-7.dll', | ||
sdl_image_lib_dir / 'optional' / 'libwebpdemux-2.dll', | ||
] | ||
endif | ||
|
||
# SDL_mixer | ||
if get_option('mixer').enabled() | ||
sdl_mixer_dir = prebuilt_dir / '@0@-@1@'.format(sdl_mixer, sdl_mixer_ver) | ||
sdl_mixer_lib_dir = sdl_mixer_dir / 'lib' / arch_suffix | ||
pg_inc_dirs += fs.relative_to(sdl_mixer_dir / 'include', base_dir) | ||
pg_lib_dirs += sdl_mixer_lib_dir | ||
dlls += [ | ||
sdl_mixer_lib_dir / '@[email protected]'.format(sdl_mixer), | ||
sdl_mixer_lib_dir / 'optional' / 'libogg-0.dll', | ||
sdl_mixer_lib_dir / 'optional' / 'libopus-0.dll', | ||
sdl_mixer_lib_dir / 'optional' / 'libopusfile-0.dll', | ||
sdl_mixer_lib_dir / 'optional' / 'libwavpack-1.dll', | ||
sdl_mixer_lib_dir / 'optional' / 'libxmp.dll', | ||
] | ||
endif | ||
|
||
# SDL_ttf | ||
if get_option('font').enabled() | ||
sdl_ttf_dir = prebuilt_dir / '@0@-@1@'.format(sdl_ttf, sdl_ttf_ver) | ||
sdl_ttf_lib_dir = sdl_ttf_dir / 'lib' / arch_suffix | ||
pg_inc_dirs += fs.relative_to(sdl_ttf_dir / 'include', base_dir) | ||
pg_lib_dirs += sdl_ttf_lib_dir | ||
dlls += sdl_ttf_lib_dir / '@[email protected]'.format(sdl_ttf) | ||
endif | ||
|
||
# freetype, portmidi and porttime | ||
common_lib_dir = prebuilt_dir / 'lib' | ||
pg_inc_dirs += fs.relative_to(prebuilt_dir / 'include', base_dir) | ||
pg_lib_dirs += common_lib_dir | ||
dlls += [common_lib_dir / 'freetype.dll', common_lib_dir / 'portmidi.dll'] | ||
if get_option('freetype').enabled() and get_option('midi').enabled() | ||
common_lib_dir = prebuilt_dir / 'lib' | ||
pg_inc_dirs += fs.relative_to(prebuilt_dir / 'include', base_dir) | ||
pg_lib_dirs += common_lib_dir | ||
dlls += [common_lib_dir / 'freetype.dll', common_lib_dir / 'portmidi.dll'] | ||
endif | ||
|
||
# clean unneeded file that causes build issues | ||
unneeded_file = common_lib_dir / 'libportmidi.dll.a' | ||
|
@@ -183,7 +201,7 @@ else | |
foreach inc_dir : bases | ||
foreach sub_inc : [ | ||
'', | ||
'/SDL2', | ||
'/@0@'.format(sdl), | ||
'/freetype2', | ||
] | ||
full_inc = inc_dir / 'include' + sub_inc | ||
|
@@ -204,45 +222,45 @@ else | |
endif | ||
|
||
# TODO: add version constraints? | ||
sdl_dep = dependency('sdl2', required: false) | ||
sdl_dep = dependency(sdl, required: false) | ||
if not sdl_dep.found() | ||
sdl_dep = declare_dependency( | ||
include_directories: pg_inc_dirs, | ||
dependencies: cc.find_library('SDL2', dirs: pg_lib_dirs), | ||
dependencies: cc.find_library(sdl, dirs: pg_lib_dirs), | ||
) | ||
endif | ||
|
||
# optional | ||
sdl_image_dep = dependency('SDL2_image', required: false) | ||
sdl_image_dep = dependency(sdl_image, required: false) | ||
if not sdl_image_dep.found() | ||
sdl_image_dep = declare_dependency( | ||
include_directories: pg_inc_dirs, | ||
dependencies: cc.find_library( | ||
'SDL2_image', | ||
sdl_image, | ||
dirs: pg_lib_dirs, | ||
required: get_option('image'), | ||
), | ||
) | ||
endif | ||
|
||
sdl_mixer_dep = dependency('SDL2_mixer', required: false) | ||
sdl_mixer_dep = dependency(sdl_mixer, required: false) | ||
if not sdl_mixer_dep.found() | ||
sdl_mixer_dep = declare_dependency( | ||
include_directories: pg_inc_dirs, | ||
dependencies: cc.find_library( | ||
'SDL2_mixer', | ||
sdl_mixer, | ||
dirs: pg_lib_dirs, | ||
required: get_option('mixer'), | ||
), | ||
) | ||
endif | ||
|
||
sdl_ttf_dep = dependency('SDL2_ttf', required: false) | ||
sdl_ttf_dep = dependency(sdl_ttf, required: false) | ||
if not sdl_ttf_dep.found() | ||
sdl_ttf_dep = declare_dependency( | ||
include_directories: pg_inc_dirs, | ||
dependencies: cc.find_library( | ||
'SDL2_ttf', | ||
sdl_ttf, | ||
dirs: pg_lib_dirs, | ||
required: get_option('font'), | ||
), | ||
|
@@ -296,10 +314,10 @@ pg_base_deps = [sdl_dep, py_dep] | |
|
||
summary( | ||
{ | ||
'SDL2': sdl_dep.found(), | ||
'SDL2_image': sdl_image_dep.found(), | ||
'SDL2_mixer': sdl_mixer_dep.found(), | ||
'SDL2_ttf': sdl_ttf_dep.found(), | ||
sdl: sdl_dep.found(), | ||
sdl_image: sdl_image_dep.found(), | ||
sdl_mixer: sdl_mixer_dep.found(), | ||
sdl_ttf: sdl_ttf_dep.found(), | ||
'freetype2': freetype_dep.found(), | ||
'portmidi': portmidi_dep.found(), | ||
'porttime': portmidi_dep.found() ? porttime_dep.found() : false, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.