Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SDL3 wrap. #1919

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions ci_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -1077,6 +1077,18 @@
"libjack-dev"
]
},
"sdl3": {
"debian_packages": [
"libudev-dev",
"libdbus-1-dev",
"libpipewire-0.3-dev",
"libwayland-dev",
"libwayland-bin",
"libxkbcommon-dev",
"libegl-dev",
"libgl-dev"
]
},
"sds": {
"build_on": {
"windows": false
Expand Down
8 changes: 8 additions & 0 deletions releases.json
Original file line number Diff line number Diff line change
Expand Up @@ -3368,6 +3368,14 @@
"2.0.12-1"
]
},
"sdl3": {
"dependency_names": [
"sdl3"
],
"versions": [
"3.2.4-2"
]
},
"sds": {
"dependency_names": [
"sds"
Expand Down
252 changes: 252 additions & 0 deletions subprojects/packagefiles/sdl3/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,252 @@
project('sdl3', 'c',
version : '3.2.4',
license : 'zlib',
meson_version : '>=1.6',
default_options : ['c_std=none'],
)

cc = meson.get_compiler('c')

varr = meson.project_version().split('.')

sdl_major = varr[0].to_int()
sdl_minor = varr[1].to_int()
sdl_patch = varr[2].to_int()

cdata = configuration_data()

cdata.set('HAVE_LIBC', 1)
cdata.set('SDL_DEFAULT_ASSERT_LEVEL', true)

sdl_deps = [dependency('threads'), dependency('dl'), cc.find_library('m', required: false)]

add_project_arguments('-DUSING_GENERATED_CONFIG_H', language: 'c')
add_project_arguments('-DSDL_BUILD_MAJOR_VERSION=@0@'.format(sdl_major),
'-DSDL_BUILD_MINOR_VERSION=@0@'.format(sdl_minor),
'-DSDL_BUILD_MICRO_VERSION=@0@'.format(sdl_patch),
language: 'c')

basic_headers = [
['float.h', 'HAVE_FLOAT_H'],
['stdarg.h', 'HAVE_STDARG_H'],
['stddef.h', 'HAVE_STDDEF_H'],
['stdint.h', 'HAVE_STDINT_H'],
['iconv.h', 'HAVE_ICONV_H'],
['inttypes.h', 'HAVE_INTTYPES_H'],
['limits.h', 'HAVE_LIMITS_H'],
['malloc.h', 'HAVE_MALLOC_H'],
['math.h', 'HAVE_MATH_H'],
['memory.h', 'HAVE_MEMORY_H'],
['signal.h', 'HAVE_SIGNAL_H'],
['stdio.h', 'HAVE_STDIO_H'],
['stdlib.h', 'HAVE_STDLIB_H'],
['strings.h', 'HAVE_STRINGS_H'],
['string.h', 'HAVE_STRING_H'],
['sys/types.h', 'HAVE_SYS_TYPES_H'],
['wchar.h', 'HAVE_WCHAR_H'],
['pthread_np.h', 'HAVE_PTHREAD_NP_H'],
['linux/input.h', 'HAVE_LINUX_INPUT_H'],
]

foreach i: basic_headers
hname = i[0]
define = i[1]
cdata.set10(define, cc.has_header(hname))
endforeach

check_functions = [
# check token ['HAVE_GCC_ATOMICS']
# check token ['HAVE_GCC_SYNC_LOCK_TEST_AND_SET']
# check token ['HAVE_LIBC']
# check token ['HAVE_LIBC']
['HAVE_DLOPEN', 'dlopen', '#include<dlfcn.h>'],
['HAVE_MALLOC', 'malloc', '#include<stdlib.h>'],
['HAVE_FDATASYNC', 'fdatasync', '#include<unistd.h>'],
['HAVE_GETENV', 'getenv', '#include<stdlib.h>'],
# check token ['HAVE_GETHOSTNAME']
['HAVE_SETENV', 'setenv', '#include<stdlib.h>'],
['HAVE_PUTENV', 'putenv', '#include<stdlib.h>'],
['HAVE_UNSETENV', 'unsetenv', '#include<stdlib.h>'],
['HAVE_ABS', 'abs', '#include<stdlib.h>'],
['HAVE_BCOPY', 'bcopy', '#include<strings.h>'],
['HAVE_MEMSET', 'memset', '#include<string.h>'],
['HAVE_MEMCPY', 'memcpy', '#include<string.h>'],
['HAVE_MEMMOVE', 'memmove', '#include<string.h>'],
['HAVE_MEMCMP', 'memcmp', '#include<string.h>'],
# check token ['HAVE_WCSLEN']
# check token ['HAVE_WCSNLEN']
# check token ['HAVE_WCSLCPY']
# check token ['HAVE_WCSLCAT']
# check token ['HAVE_WCSSTR']
# check token ['HAVE_WCSCMP']
# check token ['HAVE_WCSNCMP']
# check token ['HAVE_WCSTOL']
['HAVE_STRLEN', 'strlen', '#include<string.h>'],
['HAVE_STRNLEN', 'strnlen', '#include<string.h>'],
['HAVE_STRLCPY', 'strlcpy', '#include<string.h>'],
['HAVE_STRLCAT', 'strlcat', '#include<string.h>'],
# check token ['HAVE_STRPBRK']
['HAVE__STRREV', '_strrev', '#include<string.h>'],
['HAVE_INDEX', 'index', '#include<strings.h>'],
['HAVE_RINDEX', 'rindex', '#include<strings.h>'],
['HAVE_STRCHR', 'strchr', '#include<string.h>'],
['HAVE_STRRCHR', 'strrchr', '#include<string.h>'],
['HAVE_STRSTR', 'strstr', '#include<string.h>'],
# check token ['HAVE_STRNSTR']
['HAVE_STRTOK_R', 'strtok_r', '#include<string.h>'],
# check token ['HAVE_ITOA']
# check token ['HAVE__LTOA']
# check token ['HAVE__UITOA']
# check token ['HAVE__ULTOA']
['HAVE_STRTOL', 'strtol', '#include<stdlib.h>'],
['HAVE_STRTOUL', 'strtoul', '#include<stdlib.h>'],
# check token ['HAVE__I64TOA']
# check token ['HAVE__UI64TOA']
['HAVE_STRTOLL', 'strtoll', '#include<stdlib.h>'],
['HAVE_STRTOULL', 'strtoull', '#include<stdlib.h>'],
['HAVE_STRTOD', 'strtod', '#include<stdlib.h>'],
['HAVE_ATOI', 'atoi', '#include<stdlib.h>'],
['HAVE_ATOF', 'atof', '#include<stdlib.h>'],
['HAVE_STRCMP', 'strcmp', '#include<string.h>'],
['HAVE_STRNCMP', 'strncmp', '#include<string.h>'],
['HAVE_VSSCANF', 'vsscanf', '#include<stdio.h>'],
['HAVE_VSNPRINTF', 'vsnprintf', '#include<stdio.h>'],
['HAVE_ACOS', 'acos', '#include<math.h>'],
['HAVE_ACOSF', 'acosf', '#include<math.h>'],
['HAVE_ASIN', 'asin', '#include<math.h>'],
['HAVE_ASINF', 'asinf', '#include<math.h>'],
['HAVE_ATAN', 'atan', '#include<math.h>'],
['HAVE_ATANF', 'atanf', '#include<math.h>'],
['HAVE_ATAN2', 'atan2', '#include<math.h>'],
['HAVE_ATAN2F', 'atan2f', '#include<math.h>'],
['HAVE_CEIL', 'ceil', '#include<math.h>'],
['HAVE_CEILF', 'ceil', '#include<math.h>'],
['HAVE_COPYSIGN', 'copysign', '#include<math.h>'],
['HAVE_COPYSIGNF', 'copysign', '#include<math.h>'],
# check token ['HAVE__COPYSIGN']
['HAVE_COS', 'cos', '#include<math.h>'],
['HAVE_COSF', 'cosf', '#include<math.h>'],
['HAVE_EXP', 'exp', '#include<math.h>'],
['HAVE_EXPF', 'expf', '#include<math.h>'],
['HAVE_FABS', 'fabs', '#include<math.h>'],
['HAVE_FABSF', 'fabsf', '#include<math.h>'],
['HAVE_FLOOR', 'floor', '#include<math.h>'],
['HAVE_FLOORF', 'floorf', '#include<math.h>'],
['HAVE_FMOD', 'fmod', '#include<math.h>'],
['HAVE_FMODF', 'fmodf', '#include<math.h>'],
['HAVE_ISINF', 'isinf', '#include<math.h>'],
['HAVE_ISINFF', 'isinff', '#include<math.h>'],
# check token ['HAVE_ISINF_FLOAT_MACRO']
['HAVE_ISNAN', 'isnan', '#include<math.h>'],
['HAVE_ISNANF', 'isnanf', '#include<math.h>'],
# check token ['HAVE_ISNAN_FLOAT_MACRO']
['HAVE_LOG', 'log', '#include<math.h>'],
['HAVE_LOGF', 'logf', '#include<math.h>'],
['HAVE_LOG10', 'log10', '#include<math.h>'],
['HAVE_LOG10F', 'log10f', '#include<math.h>'],
# check token ['HAVE_LROUND']
# check token ['HAVE_LROUNDF']
# check token ['HAVE_MODF']
# check token ['HAVE_MODFF']
['HAVE_POW', 'pow', '#include<math.h>'],
# check token ['HAVE_POWF']
['HAVE_ROUND', 'round', '#include<math.h>'],
# check token ['HAVE_ROUNDF']
['HAVE_SCALBN', 'scalbn', '#include<math.h>'],
# check token ['HAVE_SCALBNF']
['HAVE_SIN', 'sin', '#include<math.h>'],
['HAVE_SINF', 'sinf', '#include<math.h>'],
['HAVE_SQRT', 'sqrt', '#include<math.h>'],
['HAVE_SQRTF', 'sqrtf', '#include<math.h>'],
# check token ['HAVE_TAN']
# check token ['HAVE_TANF']
# check token ['HAVE_TRUNC']
# check token ['HAVE_TRUNCF']
# check token ['HAVE__FSEEKI64']
# check token ['HAVE_FOPEN64']
['HAVE_FSEEKO', 'fseeko', '#include<stdio.h>'],
['HAVE_FSEEKO64', 'fseeko64', '#include<stdio.h>'],
# check token ['HAVE_MEMFD_CREATE']
# check token ['HAVE_POSIX_FALLOCATE']
['HAVE_SIGACTION', 'sigaction', '#include<signal.h>'],
# check token ['HAVE_SA_SIGACTION']
# check token ['HAVE_ST_MTIM']
['HAVE_SETJMP', 'setjmp', '#include<setjmp.h>'],
['HAVE_NANOSLEEP', 'nanosleep', '#include<time.h>'],
['HAVE_GMTIME_R', 'gmtime_r', '#include<time.h>'],
# check token ['HAVE_LOCALTIME_R']
# check token ['HAVE_NL_LANGINFO']
['HAVE_SYSCONF', 'sysconf', '#include<unistd.h>'],
['HAVE_SYSCTLBYNAME', 'sysctlbyname', '#include<sys/sysctl.h>'],
['HAVE_CLOCK_GETTIME', 'clock_gettime', '#include<time.h>'],
['HAVE_GETPAGESIZE', 'getpagesize', '#include<unistd.h>'],
# check token ['HAVE_ICONV']
['HAVE_PTHREAD_SETNAME_NP', 'pthread_setname_np', '#include<pthread.h>'],
['HAVE_PTHREAD_SET_NAME_NP', 'pthread_set_name_np', '#include<pthread.h>'],
['HAVE_SEM_TIMEDWAIT', 'sem_timedwait', '#include<semaphore.h>'],
# check token ['HAVE_GETAUXVAL']
# check token ['HAVE_ELF_AUX_INFO']
['HAVE_POLL', 'poll', '#include<poll.h>'],
# check token ['HAVE__EXIT']
# check token ['HAVE_FCITX']
['HAVE_INOTIFY_INIT1', 'inotify_init1', '#include<sys/inotify.h>'],
# check token ['HAVE_INOTIFY']
# check token ['HAVE_LIBUSB']
# check token ['HAVE_O_CLOEXEC']
]

foreach f : check_functions
if cc.has_function(f.get(1), prefix : f.get(2), dependencies: [sdl_deps])
cdata.set(f.get(0), 1)
endif
endforeach
Comment on lines +198 to +202
Copy link
Member

@eli-schwartz eli-schwartz Feb 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Early Windows failure since dl can be a Windows emulated one which we happen to provide in the wrapdb -- and thus has_function fails as it's forbidden to try to check an un-built subproject.

I suppose that isn't a general problem outside of the wrapdb CI... if https://github.com/dlfcn-win32/dlfcn-win32 isn't useful for SDL3 we can just use allow_fallback: false for it?


sources = []

if host_machine.system() == 'linux'
cdata.set('SDL_PLATFORM_LINUX ', 1)
cdata.set('SDL_THREAD_PTHREAD', 1)
cdata.set('HAVE_STRLEN', 1)
cdata.set('SDL_LOADSO_DLOPEN', 1)
cdata.set('SDL_PROCESS_POSIX', 1)
cdata.set('SDL_INPUT_LINUXEV', 1)
cdata.set('SDL_VIDEO_RENDER_OGL', 1)
cdata.set('SDL_GPU_VULKAN', 1)
cdata.set('SDL_VIDEO_VULKAN', 1)
cdata.set('SDL_VIDEO_RENDER_VULKAN', 1)
sdl_deps += dependency('libudev')
sdl_deps += dependency('dbus-1')
sdl_deps += dependency('libpipewire-0.3')
sdl_deps += dependency('wayland-client')
sdl_deps += dependency('wayland-egl')
sdl_deps += dependency('wayland-cursor')
sdl_deps += dependency('xkbcommon')
cdata.set('HAVE_DBUS_DBUS_H', 1)
wayland_scanner = find_program('wayland-scanner')
subdir('wayland-protocols')
else
error('Platform not yet supported.')
endif

if get_option('default_library') == 'both' and cc.get_argument_syntax() == 'msvc'
error('default_library=both not supported when compiling with MSVC')
endif

subdir('src')

# FIXME, this is to work around a bug in upstream headers
cdata.set('SDL_LIBDECOR_VERSION_MAJOR', 99)
cdata.set('SDL_LIBDECOR_VERSION_MINOR', 99)
cdata.set('SDL_LIBDECOR_VERSION_PATCH', 99)

configure_file(input: 'include/build_config/SDL_build_config.h.cmake',
output: 'SDL_build_config.h',
configuration: cdata,
format: 'cmake')

sdl_lib = library('SDL3', sources,
include_directories: ['include', 'src'],
dependencies: sdl_deps)

sdl3_dep = declare_dependency(include_directories: 'include',
link_with: sdl_lib)
4 changes: 4 additions & 0 deletions subprojects/packagefiles/sdl3/src/atomic/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources += files(
'SDL_spinlock.c',
'SDL_atomic.c',
)
3 changes: 3 additions & 0 deletions subprojects/packagefiles/sdl3/src/audio/aaudio/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
sources += files(
'SDL_aaudio.c',
)
3 changes: 3 additions & 0 deletions subprojects/packagefiles/sdl3/src/audio/alsa/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
sources += files(
'SDL_alsa_audio.c',
)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sources += files(
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
sources += files(
'SDL_directsound.c',
)
3 changes: 3 additions & 0 deletions subprojects/packagefiles/sdl3/src/audio/disk/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
sources += files(
'SDL_diskaudio.c',
)
3 changes: 3 additions & 0 deletions subprojects/packagefiles/sdl3/src/audio/dsp/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
sources += files(
'SDL_dspaudio.c',
)
3 changes: 3 additions & 0 deletions subprojects/packagefiles/sdl3/src/audio/dummy/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
sources += files(
'SDL_dummyaudio.c',
)
3 changes: 3 additions & 0 deletions subprojects/packagefiles/sdl3/src/audio/jack/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
sources += files(
'SDL_jackaudio.c',
)
17 changes: 17 additions & 0 deletions subprojects/packagefiles/sdl3/src/audio/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
if host_machine.system() == 'windows'
subdir('directsound')
else
cdata.set('SDL_AUDIO_DRIVER_PIPEWIRE', 1)
subdir('pipewire')
endif

sources += files(
'SDL_audiodev.c',
'SDL_audioresample.c',
'SDL_audioqueue.c',
'SDL_audio.c',
'SDL_audiocvt.c',
'SDL_wave.c',
'SDL_audiotypecvt.c',
'SDL_mixer.c',
)
3 changes: 3 additions & 0 deletions subprojects/packagefiles/sdl3/src/audio/openslES/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
sources += files(
'SDL_openslES.c',
)
3 changes: 3 additions & 0 deletions subprojects/packagefiles/sdl3/src/audio/pipewire/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
sources += files(
'SDL_pipewire.c',
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
sources += files(
'SDL_pulseaudio.c',
)
3 changes: 3 additions & 0 deletions subprojects/packagefiles/sdl3/src/audio/qnx/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
sources += files(
'SDL_qsa_audio.c',
)
3 changes: 3 additions & 0 deletions subprojects/packagefiles/sdl3/src/audio/sndio/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
sources += files(
'SDL_sndioaudio.c',
)
3 changes: 3 additions & 0 deletions subprojects/packagefiles/sdl3/src/audio/wasapi/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
sources += files(
'SDL_wasapi.c',
)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sources += files(
3 changes: 3 additions & 0 deletions subprojects/packagefiles/sdl3/src/camera/dummy/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
sources += files(
'SDL_camera_dummy.c',
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
sources += files(
'SDL_camera_mediafoundation.c',
)
5 changes: 5 additions & 0 deletions subprojects/packagefiles/sdl3/src/camera/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
subdir('dummy')

sources += files(
'SDL_camera.c',
)
3 changes: 3 additions & 0 deletions subprojects/packagefiles/sdl3/src/camera/pipewire/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
sources += files(
'SDL_camera_pipewire.c',
)
3 changes: 3 additions & 0 deletions subprojects/packagefiles/sdl3/src/camera/v4l2/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
sources += files(
'SDL_camera_v4l2.c',
)
1 change: 1 addition & 0 deletions subprojects/packagefiles/sdl3/src/core/gdk/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sources += files(
Loading
Loading