Alien-SDL3
view release on metacpan or search on metacpan
recipes/packages/l/libsdl3/xmake.lua view on Meta::CPAN
-- Local override of the xmake-repo package recipe for libsdl3.
--
-- Deviations from packages/l/libsdl3/xmake.lua in xmake-repo:
-- * builds sdl3 v 3.4.18
-- * gates the add_extsources() system path on a minimum version
-- * declares a Windows/vcpkg extsource; upstream declares none on Windows
-- Keep this file in sync with the upstream recipe when bumping versions.
--
package("libsdl3")
set_homepage("https://www.libsdl.org/")
set_description("Simple DirectMedia Layer")
set_license("zlib")
-- Oldest system SDL3 we will link against. Bump this together with the 3.4.18
-- add_versions() entry below; the two are the same release and must not drift.
local _MIN_SYSTEM_VERSION = "3.4.18"
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")
elseif is_plat("windows") then
add_extsources("vcpkg::sdl3")
end
-- add_extsources() only says *where* to look, never *which versions are
-- acceptable*, so xmake happily resolves apt::libsdl3-dev on Ubuntu 25.10
-- (3.4.2) or a stale brew/vcpkg tree and reports success. The extension
-- libraries are built from source against 3.4.18 headers, so a system core
-- older than that mixes two ABIs in one link and breaks at runtime rather
-- than at configure time.
--
-- The probe below mirrors the candidate list xmake's own fallback uses
-- (extsources, then the bare package name -- @see
-- core/package/package.lua:1978-1998), so the only thing it changes is which
-- versions are accepted. The bare name is self:name(), i.e. "libsdl3", while
-- the vcpkg port is "sdl3", so bare-name probing never reaches vcpkg; the
-- explicit vcpkg::sdl3 extsource declared above is what puts vcpkg (and this
-- gate) on the Windows candidate list at all.
on_fetch(function (self, opt)
if not opt.system then
-- Not a system install: let the normal from-xmake-repo path run.
return
end
local semver = import("core.base.semver")
local names = {}
if not self:is_thirdparty() then
table.join2(names, self:extsources())
end
table.insert(names, self:name())
for _, name in ipairs(names) do
-- self:find_package() rather than the global find_package(): it
-- defaults to system-only for non-xmake:: names, which is what the
-- fallback below uses, so we test the same package it would pick.
local fetchinfo = self:find_package(name, {system = true})
if fetchinfo then
local found = fetchinfo.version
-- pkgconfig-style managers report a plain semver; vcpkg reports
-- "<semver>-<portrevision>" (libsdl3_3.4.18-1_x64-windows.list).
-- semver reads that as a 3.4.18 pre-release, so a perfectly
-- current vcpkg SDL3 would look older than it is. Drop the port
-- revision before comparing.
local comparable = found and found:gsub("%-%d+$", "")
-- try() returns the try-function's return values directly, not
-- (ok, result) -- @see core/sandbox/modules/try.lua:132 -- so an
-- unparseable version arrives here as nil rather than false.
local satisfies = try {
function () return semver.satisfies(comparable, ">=" .. _MIN_SYSTEM_VERSION) end
}
if satisfies then
return fetchinfo
end
-- Returning false (not nil) is what disables xmake's extsource
-- fallback -- @see core/package/package.lua _fetch_library -- so
-- the too-old package is skipped and we build the pinned release
-- instead. Returning nil here would hand it straight back.
print(string.format("libsdl3: system SDL3 %s is older than %s, building from source",
found or "of unknown version", _MIN_SYSTEM_VERSION))
return false
end
end
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.4.18", "9cd42377704398796071b8597cd7e21da254a43bad98c4199739647adc13fa6f")
add_versions("archive:3.4.16", "5f399fdfbc040169ef4418a3cb99ccc5a0641681f7ccc1da66eeec3c97fa4076")
add_versions("archive:3.4.12", "3d4de8967a49c0451e775a0c1e9022092c19fdef41ba38a83fcf031c5a6496e2")
add_versions("archive:3.4.4", "6bd4fbb665f77899a488b381c5b6e9681fc57c60b669738f985fea714f3456c5")
add_versions("archive:3.4.2", "4954d436c95c42aa258d4eb3fb95f8ecc5d7a3dc411f0f41ac2692d34b9b9e9c")
add_versions("archive:3.4.0", "9ac2debb493e0d3e13dbd2729fb91f4bfeb00a0f4dff5e04b73cc9bac276b38d")
add_versions("archive:3.2.28", "24a30069af514a6c6b773bdc8ccca8b321661b251381acc1daeebf8c8f4a109a")
add_versions("archive:3.2.26", "739356eef1192fff9d641c320a8f5ef4a10506b8927def4b9ceb764c7e947369")
add_versions("archive:3.2.22", "3d60068b1e5c83c66bb14c325dfef46f8fcc380735b4591de6f5e7b9738929d1")
add_versions("archive:3.2.16", "0cc7430fb827c1f843e31b8b26ba7f083b1eeb8f6315a65d3744fd4d25b6c373")
add_versions("archive:3.2.14", "46a17d3ea71fe2580a7f43ca7da286c5b9106dd761e2fd5533bb113e5d86b633")
add_versions("archive:3.2.10", "01d9ab20fc071b076be91df5396b464b4ef159e93b2b2addda1cc36750fc1f29")
add_versions("archive:3.2.8", "7f8ff5c8246db4145301bc122601a5f8cef25ee2c326eddb3e88668849c61ddf")
add_versions("archive:3.2.6", "665e5aa2a613affe099a38d61257ecc5ef4bf38b109d915147aa8b005399d68a")
add_versions("archive:3.2.2", "58d8adc7068d38923f918e0bdaa9c4948f93d9ba204fe4de8cc6eaaf77ad6f82")
add_versions("archive:3.2.0", "abe7114fa42edcc8097856787fa5d37f256d97e365b71368b60764fe7c10e4f8")
add_versions("github:3.4.18", "release-3.4.18")
add_versions("github:3.4.16", "release-3.4.16")
add_versions("github:3.4.12", "release-3.4.12")
add_versions("github:3.4.4", "release-3.4.4")
add_versions("github:3.4.2", "release-3.4.2")
add_versions("github:3.4.0", "release-3.4.0")
add_versions("github:3.2.28", "release-3.2.28")
add_versions("github:3.2.26", "release-3.2.26")
( run in 1.255 second using v1.01-cache-2.11-cpan-4716db65a44 )