From 364e09a249b6e36014b4465039dbab41c123418a Mon Sep 17 00:00:00 2001 From: rempas <60424977+rempas@users.noreply.github.com> Date: Fri, 17 Apr 2026 21:48:02 +0300 Subject: [PATCH 1/2] libsdl3: Added extre configuration options This patch adds extra configuration options to allow to disable parts of sdl3 that we don't need. --- packages/l/libsdl3/xmake.lua | 79 ++++++++++++++++++++++++++++++------ 1 file changed, 66 insertions(+), 13 deletions(-) diff --git a/packages/l/libsdl3/xmake.lua b/packages/l/libsdl3/xmake.lua index fdaafc528a4..5172b58ae5c 100644 --- a/packages/l/libsdl3/xmake.lua +++ b/packages/l/libsdl3/xmake.lua @@ -1,4 +1,5 @@ package("libsdl3") + set_homepage("https://www.libsdl.org/") set_description("Simple DirectMedia Layer") set_license("zlib") @@ -45,7 +46,24 @@ package("libsdl3") add_patches("3.4.0", "patches/3.4.0/fix-ios.patch", "feffa146aa825f97fc431f115f3990a7a0ad0214d05a9765f2cfbd3633465bf8") - add_deps("cmake", "egl-headers", "opengl-headers") + add_deps("cmake") + + add_configs("video", { description = "Enable support for video (creating windows)", default = true, type = "boolean"}) + add_configs("audio", { description = "Enable support for SDL_Audio", default = true, type = "boolean"}) + add_configs("gpu", { description = "Enable support for SDL_GPU", default = true, type = "boolean"}) + add_configs("renderer", { description = "Enable support for SDL_Renderer", default = true, type = "boolean"}) + add_configs("joystick", { description = "Enable support for SDL_joystick", default = true, type = "boolean"}) + add_configs("haptic", { description = "Enable haptic input support", default = true, type = "boolean"}) + add_configs("camera", { description = "Enable support for SDL_Camera", default = true, type = "boolean"}) + add_configs("storage", { description = "Enable support for SDL_Storage", default = true, type = "boolean"}) + add_configs("process", { description = "Enable support for SDL's cross-platform process spawing", default = true, type = "boolean"}) + add_configs("dialog", { description = "Enable support for SDL's native file/directory picker and dialog", default = true, type = "boolean"}) + add_configs("tray", { description = "Enable support for SDL's tray system API", default = true, type = "boolean"}) + add_configs("filesystem", { description = "Enable support for SDL's standar file path handling", default = true, type = "boolean"}) + add_configs("threads", { description = "Enable support for SDL's threading and mutex wrappers", default = true, type = "boolean"}) + add_configs("timers", { description = "Enable support for SDL's timers and delay functions", default = true, type = "boolean"}) + add_configs("loadso", { description = "Enable support for loading shared libraries through SDL's runtime", default = true, type = "boolean"}) + add_configs("locale", { description = "Enable SDL's system locale's detection", default = true, type = "boolean"}) if is_plat("linux", "bsd", "cross") then add_configs("x11", {description = "Enables X11 support", default = true, type = "boolean"}) @@ -59,9 +77,21 @@ package("libsdl3") end on_load(function (package) + local supports_video = package:config("video") + + if supports_video then + package:add("deps", "egl-headers") + package:add("deps", "opengl-headers") + else + package:config_set("gpu", false) + package:config_set("renderer", false) + package:config_set("dialog", false) + package:config_set("tray", false) + end + if package:is_plat("linux", "android", "cross") then -- Enable Wayland by default except when cross-compiling (wayland package doesn't support cross-compilation yet) - if package:config("wayland") == nil and not package:is_cross() then + if package:config("wayland") == nil and not package:is_cross() and supports_video then package:config_set("wayland", true) end end @@ -69,14 +99,14 @@ package("libsdl3") package:add("deps", "ninja") package:set("policy", "package.cmake_generator.ninja", true) end - if package:is_plat("linux", "bsd", "cross") and package:config("x11") then + if package:is_plat("linux", "bsd", "cross") and package:config("x11") and supports_video then local deplibs = {"libx11", "libxcb", "libxext", "libxcursor", "libxfixes", "libxi", "libxrandr", "libxrender", "libxss"} local depconfig = package:config("x11_shared") and {private = true, configs = {shared = true}} or nil for _, lib in ipairs(deplibs) do package:add("deps", lib, depconfig) end end - if package:is_plat("linux", "bsd", "cross") and package:config("wayland") then + if package:is_plat("linux", "bsd", "cross") and package:config("wayland") and supports_video then if package:config("wayland_shared") then package:add("deps", "wayland", {private = true, configs = {shared = true}}) else @@ -96,13 +126,13 @@ package("libsdl3") package:add("syslinks", "dl", "log", "android", "GLESv1_CM", "GLESv2", "OpenSLES") elseif package:is_plat("iphoneos", "macosx") then package:add("frameworks", "AudioToolbox", "AVFoundation", "CoreAudio", "CoreHaptics", "CoreMedia", "CoreVideo", "Foundation", "GameController", "Metal", "QuartzCore", "CoreFoundation", "UniformTypeIdentifiers") - package:add("syslinks", "iconv") + package:add("syslinks", "iconv") if package:is_plat("macosx") then package:add("frameworks", "Cocoa", "Carbon", "ForceFeedback", "IOKit") else package:add("frameworks", "CoreBluetooth", "CoreGraphics", "CoreMotion", "OpenGLES", "UIKit") end - end + end end end) @@ -112,6 +142,18 @@ package("libsdl3") table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF")) table.insert(configs, "-DSDL_TEST_LIBRARY=OFF") table.insert(configs, "-DSDL_EXAMPLES=OFF") + + local toggle_configs = { + video = "VIDEO", audio = "AUDIO", gpu = "GPU", renderer = "RENDER", + joystick = "JOYSTICK", haptic = "HAPTIC", camera = "CAMERA", + storage = "STORAGE", process = "PROCESS", dialog = "DIALOG", + tray = "TRAY", filesystem = "FILESYSTEM", threads = "THREADS", + timers = "TIMERS", loadso = "LOADSO", locale = "LOCALE" + } + for conf_name, cmake_suffix in pairs(toggle_configs) do + table.insert(configs, "-DSDL_" .. cmake_suffix .. "=" .. (package:config(conf_name) and "ON" or "OFF")) + end + if package:is_plat("linux", "bsd", "cross") then table.insert(configs, "-DSDL_X11=" .. (package:config("x11") and "ON" or "OFF")) table.insert(configs, "-DSDL_X11_SHARED=" .. (package:config("x11_shared") and "ON" or "OFF")) @@ -121,15 +163,26 @@ package("libsdl3") end local cflags - local packagedeps - if not package:is_plat("wasm") then - packagedeps = table.join2(packagedeps or {}, {"egl-headers", "opengl-headers"}) + local packagedeps = {} + + -- Only fetch include directories for video dependencies if video support is enabled! + if package:config("video") then + if not package:is_plat("wasm") then + table.insert(packagedeps, "egl-headers") + table.insert(packagedeps, "opengl-headers") + end + + if package:is_plat("linux", "bsd", "cross") then + if package:config("x11") then + packagedeps = table.join2(packagedeps, {"libxcursor", "libxext", "libxfixes", "libxcb", "libx11", "libxi", "libxrandr", "libxrender", "libxss", "xorgproto"}) + end + if package:config("wayland") then + table.insert(packagedeps, "wayland") + end + end end - if package:is_plat("linux", "bsd", "cross") then - packagedeps = table.join2(packagedeps or {}, {"libxcursor", "libxext", "libxfixes", "libxcb", "libx11", "libxi", "libxrandr", "libxrender", "libxss", "xorgproto", "wayland"}) - elseif package:is_plat("wasm") then - -- emscripten enables USE_SDL by default which will conflict with libsdl headers + if package:is_plat("wasm") then cflags = {"-sUSE_SDL=0"} end From d51a69cbeb983b8ea613a499d191d1dea766d51f Mon Sep 17 00:00:00 2001 From: rempas <60424977+rempas@users.noreply.github.com> Date: Fri, 17 Apr 2026 22:00:38 +0300 Subject: [PATCH 2/2] libsdl3: Added more configuration options --- packages/l/libsdl3/xmake.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/l/libsdl3/xmake.lua b/packages/l/libsdl3/xmake.lua index 5172b58ae5c..8ab9c93392e 100644 --- a/packages/l/libsdl3/xmake.lua +++ b/packages/l/libsdl3/xmake.lua @@ -56,10 +56,10 @@ package("libsdl3") add_configs("haptic", { description = "Enable haptic input support", default = true, type = "boolean"}) add_configs("camera", { description = "Enable support for SDL_Camera", default = true, type = "boolean"}) add_configs("storage", { description = "Enable support for SDL_Storage", default = true, type = "boolean"}) - add_configs("process", { description = "Enable support for SDL's cross-platform process spawing", default = true, type = "boolean"}) + add_configs("process", { description = "Enable support for SDL's cross-platform process spawning", default = true, type = "boolean"}) add_configs("dialog", { description = "Enable support for SDL's native file/directory picker and dialog", default = true, type = "boolean"}) add_configs("tray", { description = "Enable support for SDL's tray system API", default = true, type = "boolean"}) - add_configs("filesystem", { description = "Enable support for SDL's standar file path handling", default = true, type = "boolean"}) + add_configs("filesystem", { description = "Enable support for SDL's standard file path handling", default = true, type = "boolean"}) add_configs("threads", { description = "Enable support for SDL's threading and mutex wrappers", default = true, type = "boolean"}) add_configs("timers", { description = "Enable support for SDL's timers and delay functions", default = true, type = "boolean"}) add_configs("loadso", { description = "Enable support for loading shared libraries through SDL's runtime", default = true, type = "boolean"}) @@ -79,7 +79,7 @@ package("libsdl3") on_load(function (package) local supports_video = package:config("video") - if supports_video then + if supports_video and not package:is_plat("wasm") then package:add("deps", "egl-headers") package:add("deps", "opengl-headers") else @@ -100,7 +100,7 @@ package("libsdl3") package:set("policy", "package.cmake_generator.ninja", true) end if package:is_plat("linux", "bsd", "cross") and package:config("x11") and supports_video then - local deplibs = {"libx11", "libxcb", "libxext", "libxcursor", "libxfixes", "libxi", "libxrandr", "libxrender", "libxss"} + local deplibs = {"libx11", "libxcb", "libxext", "libxcursor", "libxfixes", "libxi", "libxrandr", "libxrender", "libxss", "xorgproto"} local depconfig = package:config("x11_shared") and {private = true, configs = {shared = true}} or nil for _, lib in ipairs(deplibs) do package:add("deps", lib, depconfig)