-
-
Notifications
You must be signed in to change notification settings - Fork 419
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 libsdl3 #6225
Draft
SirLynix
wants to merge
32
commits into
dev
Choose a base branch
from
SirLynix-patch-2
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+163
−21
Draft
Add libsdl3 #6225
Changes from 19 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
4749df9
Add libsdl3
SirLynix b19efba
Update xmake.lua
SirLynix 0793388
Update xmake.lua
SirLynix a465c81
Update xmake.lua
SirLynix b2cdc39
Update xmake.lua
SirLynix ae93bfd
Update xmake.lua
SirLynix df875c6
Update xmake.lua
SirLynix 72d2522
Update xmake.lua
SirLynix a388ff4
Update xmake.lua
SirLynix 91eae42
Update xmake.lua
SirLynix c791824
Update xmake.lua
SirLynix d09d5f0
Update xmake.lua
SirLynix 1f789f3
Update xmake.lua
SirLynix e0de0b0
Update xmake.lua
SirLynix 3676065
Update xmake.lua
SirLynix 89c556b
Update xmake.lua
SirLynix c8ebd53
Update xmake.lua
SirLynix d23f3ff
Update xmake.lua
SirLynix cbeec59
Update xmake.lua
SirLynix a0855ac
Merge branch 'dev' into SirLynix-patch-2
SirLynix 552a727
Update xmake.lua
SirLynix a075453
Update xmake.lua
SirLynix 100f785
Update xmake.lua
SirLynix 44425f4
Update xmake.lua
SirLynix d3cd88d
Update xmake.lua
SirLynix 2a4d4b4
Try to enable x11 on cross
SirLynix 5f7d144
Update xmake.lua
SirLynix 6d2afbc
Update xmake.lua
SirLynix 02eda2c
Update xmake.lua
SirLynix 3c05207
Update xmake.lua
SirLynix 9437af4
Update xmake.lua
SirLynix 79218fc
Update xmake.lua
SirLynix File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
package("libsdl3") | ||
set_homepage("https://www.libsdl.org/") | ||
set_description("Simple DirectMedia Layer") | ||
set_license("zlib") | ||
|
||
if is_plat("mingw") and is_subhost("msys") then | ||
add_extsources("pacman::SDL3") | ||
elseif is_plat("linux") then | ||
add_extsources("pacman::sdl3", "apt::libsdl3-dev") | ||
elseif is_plat("macosx") then | ||
add_extsources("brew::sdl3") | ||
end | ||
|
||
add_urls("https://www.libsdl.org/release/SDL3-$(version).zip", | ||
"https://github.com/libsdl-org/SDL/releases/download/release-$(version)/SDL3-$(version).zip", { alias = "archive" }) | ||
add_urls("https://github.com/libsdl-org/SDL.git", { alias = "github" }) | ||
|
||
add_versions("archive:3.2.0", "abe7114fa42edcc8097856787fa5d37f256d97e365b71368b60764fe7c10e4f8") | ||
add_versions("github:3.2.0", "release-3.2.0") | ||
|
||
add_deps("cmake", "egl-headers", "opengl-headers") | ||
|
||
if is_plat("linux", "bsd") then | ||
add_configs("x11", {description = "Enables X11 support (requires it on the system)", default = true, type = "boolean"}) | ||
add_configs("wayland", {description = "Enables Wayland support", default = true, type = "boolean"}) | ||
end | ||
|
||
if is_plat("wasm") then | ||
add_cxflags("-sUSE_SDL=0") | ||
end | ||
|
||
on_load(function (package) | ||
if package:is_plat("windows") then | ||
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 | ||
package:add("deps", "libxext", {private = true}) | ||
end | ||
if package:is_plat("linux", "bsd", "cross") and package:config("wayland") then | ||
package:add("deps", "wayland", {private = true}) | ||
end | ||
local libsuffix = package:is_debug() and "d" or "" | ||
if not package:config("shared") then | ||
if package:is_plat("windows", "mingw") then | ||
package:add("syslinks", "user32", "gdi32", "winmm", "imm32", "ole32", "oleaut32", "version", "uuid", "advapi32", "setupapi", "shell32") | ||
elseif package:is_plat("linux", "bsd") then | ||
package:add("syslinks", "pthread", "dl") | ||
if package:is_plat("bsd") then | ||
package:add("syslinks", "usbhid") | ||
end | ||
elseif package:is_plat("android") then | ||
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") | ||
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) | ||
|
||
on_install("!cross", function (package) | ||
local configs = {} | ||
table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release")) | ||
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 cflags | ||
local packagedeps | ||
if not package:is_plat("wasm") then | ||
packagedeps = {"egl-headers", "opengl-headers"} | ||
end | ||
|
||
if package:is_plat("linux", "bsd") then | ||
table.insert(packagedeps, "libxext") | ||
table.insert(packagedeps, "libx11") | ||
table.insert(packagedeps, "xorgproto") | ||
table.insert(packagedeps, "wayland") | ||
elseif package:is_plat("wasm") then | ||
-- emscripten enables USE_SDL by default which will conflict with the sdl headers | ||
cflags = {"-sUSE_SDL=0"} | ||
end | ||
|
||
local includedirs = {} | ||
for _, depname in ipairs(packagedeps) do | ||
local dep = package:dep(depname) | ||
if dep then | ||
local depfetch = dep:fetch() | ||
if depfetch then | ||
for _, includedir in ipairs(depfetch.includedirs or depfetch.sysincludedirs) do | ||
table.insert(includedirs, includedir) | ||
end | ||
end | ||
end | ||
end | ||
if #includedirs > 0 then | ||
includedirs = table.unique(includedirs) | ||
table.insert(configs, "-DCMAKE_INCLUDE_PATH=" .. table.concat(includedirs, ";")) | ||
cflags = cflags or {} | ||
for _, includedir in ipairs(includedirs) do | ||
table.insert(cflags, "-I" .. includedir) | ||
end | ||
end | ||
|
||
import("package.tools.cmake").install(package, configs, {cflags = cflags}) | ||
end) | ||
|
||
on_test(function (package) | ||
assert(package:check_cxxsnippets({test = [[ | ||
#include <SDL3/SDL.h> | ||
int main(int argc, char** argv) { | ||
SDL_Init(0); | ||
SDL_Quit(); | ||
return 0; | ||
} | ||
]]})); | ||
end) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't do linux development, but is there a reason why these are enabled by default on that platform? I thought you could develop a libsdl3 application without these?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One of the main feature of SDL (and reason people use it) is input and window management, which need x11/wayland to work.
It's very rare to use libsdl without these
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm always wary about defaults being enabled because you can't really take it back later. Even if it's rare, minimal dependencies by default should still be a consideration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand, but libsdl is a bit special, it only requires headers to build as it doesn't link x11 nor wayland, it loads them manually (dlopen/dlsym) at runtime only if they're available.
A good default for libsdl is to build it with as many deps as possible for this reason