diff --git a/.gitignore b/.gitignore index 4266be92..d8ac9dd1 100644 --- a/.gitignore +++ b/.gitignore @@ -44,6 +44,10 @@ /deps/png/bin/png-fix-itxt /deps/png/bin/pngfix /deps/samplerate/bin/ +/deps/sdl2/include/SDL2/SDL_config_*.h +/deps/sdl2/include/SDL2/SDL_copying.h +/deps/sdl2/include/SDL2/SDL_test*.h +/deps/sdl2/lib/cmake/ /deps/sndfile/bin/ /deps/sndfile/include/sndfile.hh /deps/sndfile/lib/cmake/ diff --git a/build.py b/build.py index 47175c98..993639e3 100755 --- a/build.py +++ b/build.py @@ -1249,6 +1249,44 @@ class SamplerateTarget(ConfigureMakeStaticDependencyTarget): return os.path.exists(builder.source_path + 'samplerate.pc.in') +class Sdl2FileTarget(CMakeStaticDependencyTarget): + def __init__(self, name='sdl2'): + super().__init__(name) + + def prepare_source(self, builder: 'Builder'): + builder.download_source( + 'https://libsdl.org/release/SDL2-2.0.12.tar.gz', + '349268f695c02efbc9b9148a70b85e58cefbbf704abd3e91be654db7f1e2c863') + + def detect(self, builder: 'Builder') -> bool: + return os.path.exists(builder.source_path + 'sdl2.pc.in') + + LINKER_FLAGS = ' -L${libdir} -lSDL2'\ + ' -framework AudioToolbox -framework AVFoundation -framework Carbon -framework Cocoa'\ + ' -framework CoreAudio -framework CoreFoundation -framework CoreVideo'\ + ' -framework ForceFeedback -framework Foundation -framework IOKit\n' + + def post_build(self, builder: 'Builder'): + super().post_build(builder) + + def update_libs(line: str): + if line.startswith(' echo -L${exec_prefix}/lib'): + return ' echo' + Sdl2FileTarget.LINKER_FLAGS + + return line + + Target.update_prefix_shell_script(self.prefix + '/bin/sdl2-config', update_libs) + + @staticmethod + def _process_pkg_config(pcfile: str, line: str) -> str: + libs_private = 'Libs.private:' + + if line.startswith(libs_private): + return libs_private + Sdl2FileTarget.LINKER_FLAGS + + return line + + class SndFileTarget(CMakeStaticDependencyTarget): def __init__(self, name='sndfile'): super().__init__(name) @@ -1643,6 +1681,7 @@ class Builder(object): PkgConfigTarget(), PngTarget(), SamplerateTarget(), + Sdl2FileTarget(), SndFileTarget(), VorbisTarget(), VpxTarget(), diff --git a/patch/sdl2.patch b/patch/sdl2.patch new file mode 100644 index 00000000..006572e3 --- /dev/null +++ b/patch/sdl2.patch @@ -0,0 +1,16 @@ +--- a/src/video/cocoa/SDL_cocoawindow.m ++++ b/src/video/cocoa/SDL_cocoawindow.m +@@ -1813,6 +1813,13 @@ + This is no longer needed as of Mac OS X 10.15, according to bug 4822. + */ + NSProcessInfo *processInfo = [NSProcessInfo processInfo]; ++#if MAC_OS_X_VERSION_MAX_ALLOWED < 101000 /* NSOperatingSystemVersion added in the 10.10 SDK */ ++ typedef struct { ++ NSInteger majorVersion; ++ NSInteger minorVersion; ++ NSInteger patchVersion; ++ } NSOperatingSystemVersion; ++#endif + NSOperatingSystemVersion version = { 10, 15, 0 }; + if (![processInfo respondsToSelector:@selector(isOperatingSystemAtLeastVersion:)] || + ![processInfo isOperatingSystemAtLeastVersion:version]) {