diff options
| author | 2026-03-16 21:01:30 +0100 | |
|---|---|---|
| committer | 2026-03-16 16:01:30 -0400 | |
| commit | 7f9ebd2ee59bf03ff1b7c2281931cd0017aa46df (patch) | |
| tree | 837e82e25c0a20903d64bcfefeff497bf5ee9d1a /scripts/src | |
| parent | bb83f35d7406a4496c38024f6c1a266b55750c2e (diff) | |
build: autodetect Homebrew SDL3 on macOS (#15108)
Diffstat (limited to 'scripts/src')
| -rw-r--r-- | scripts/src/osd/sdl3.lua | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/scripts/src/osd/sdl3.lua b/scripts/src/osd/sdl3.lua index f6ce6db8221..b68ee0c2771 100644 --- a/scripts/src/osd/sdl3.lua +++ b/scripts/src/osd/sdl3.lua @@ -114,6 +114,24 @@ function sdlconfigcmd() end end +local function sdlpkgconfigcmd() + if _OPTIONS["SDL_PKGCONFIG_PATH"] then + return path.join(_OPTIONS["SDL_PKGCONFIG_PATH"],"pkg-config") + else + return pkgconfigcmd() + end +end + +local function macosx_uses_libsdl_by_default() + if _OPTIONS["targetos"]~="macosx" then + return false + elseif _OPTIONS["SDL_INSTALL_ROOT"] then + return true + else + return os.execute(sdlpkgconfigcmd() .. " --exists sdl3") + end +end + newoption { trigger = "MESA_INSTALL_ROOT", @@ -179,7 +197,7 @@ newoption { newoption { trigger = "SDL_PKGCONFIG_PATH", - description = "Location of pkg-config command that knows about SDL. Useful for non-root Homebrew installs on Linux.", + description = "Location of pkg-config command that knows about SDL. Useful for non-default Homebrew installs.", } newoption { @@ -187,6 +205,8 @@ newoption { description = "Location of SDL framework for custom OS X installations", } +local framework_path_default = (_OPTIONS["SDL_FRAMEWORK_PATH"] == nil) + -- SDL 3's framework now contains all Apple platforms in a single framework, so we need to -- specifically ask for the macOS version. if not _OPTIONS["SDL_FRAMEWORK_PATH"] then @@ -202,10 +222,18 @@ newoption { }, } +local use_libsdl_default = (_OPTIONS["USE_LIBSDL"] == nil) + if not _OPTIONS["USE_LIBSDL"] then _OPTIONS["USE_LIBSDL"] = "0" end +-- Prefer pkg-config/library installs on macOS when available, as that is the +-- common Homebrew layout. Preserve explicit framework and USE_LIBSDL choices. +if use_libsdl_default and framework_path_default and macosx_uses_libsdl_by_default() then + _OPTIONS["USE_LIBSDL"] = "1" +end + BASE_TARGETOS = "unix" SDLOS_TARGETOS = "unix" @@ -227,7 +255,6 @@ if BASE_TARGETOS=="unix" then "-framework QuartzCore", "-framework OpenGL", "-framework IOKit", - "-rpath " .. _OPTIONS["SDL_FRAMEWORK_PATH"], } @@ -238,6 +265,7 @@ if BASE_TARGETOS=="unix" then end if _OPTIONS["USE_LIBSDL"]~="1" then linkoptions { + "-rpath " .. _OPTIONS["SDL_FRAMEWORK_PATH"], "-F" .. _OPTIONS["SDL_FRAMEWORK_PATH"], } links { |
