From 321e28c810a370a435063140df3ac30db87a8f4e Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Mon, 5 May 2025 18:51:01 +0300 Subject: [PATCH] scripts: waifulib: sdl2: fix SDL3 sanity test --- scripts/waifulib/sdl2.py | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/scripts/waifulib/sdl2.py b/scripts/waifulib/sdl2.py index 61c9b7ca..115d9972 100644 --- a/scripts/waifulib/sdl2.py +++ b/scripts/waifulib/sdl2.py @@ -13,6 +13,14 @@ import os +SDL_SANITY_FRAGMENT='''#define SDL_MAIN_HANDLED +#include <%s> +int main( void ) +{ + SDL_Init( SDL_INIT_AUDIO ); + return 0; +}''' + def options(opt): grp = opt.add_option_group('SDL2/SDL3 options') grp.add_option('-s', '--sdl2', action='store', dest = 'SDL_PATH', default = None, @@ -97,18 +105,9 @@ def configure(conf): conf.env[HAVE] = 0 if conf.env[HAVE] and conf.options.SDL_SANITY_CHECK: - try: - conf.check_cc( - fragment=''' - #define SDL_MAIN_HANDLED - #include - int main( void ) - { - SDL_Init( SDL_INIT_EVENTS ); - return 0; - }''', - msg = 'Checking for %s sanity' % libname, - use = libname, - execute = False) - except conf.errors.ConfigurationError: - conf.env.HAVE_SDL2 = 0 + if conf.options.SDL3: + fragment = SDL_SANITY_FRAGMENT % 'SDL3/SDL.h' + else: + fragment = SDL_SANITY_FRAGMENT % 'SDL.h' + + conf.env[HAVE] = conf.check_cc(fragment=fragment, msg = 'Checking for %s sanity' % libname, use = libname, execute = False, mandatory = False)