Skip to content

Commit

Permalink
rename libsdl_xxx to libsdl2_xxx
Browse files Browse the repository at this point in the history
  • Loading branch information
waruqi committed Feb 8, 2025
1 parent 9239b34 commit d3ff3e7
Show file tree
Hide file tree
Showing 12 changed files with 512 additions and 438 deletions.
13 changes: 13 additions & 0 deletions packages/l/libsdl2_gfx/patches/1.0.4/lrint_fix.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/SDL2_gfxPrimitives.c b/SDL2_gfxPrimitives.c
index c6f7894..0ab6b22 100644
--- a/SDL2_gfxPrimitives.c
+++ b/SDL2_gfxPrimitives.c
@@ -1757,7 +1757,7 @@ int filledCircleRGBA(SDL_Renderer * renderer, Sint16 x, Sint16 y, Sint16 rad, Ui
/* ----- AA Ellipse */

/* Windows targets do not have lrint, so provide a local inline version */
-#if defined(_MSC_VER)
+#if defined(_MSC_VER) && _MSC_VER < 1928
/* Detect 64bit and use intrinsic version */
#ifdef _M_X64
#include <emmintrin.h>
76 changes: 76 additions & 0 deletions packages/l/libsdl2_gfx/xmake.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package("libsdl2_gfx")
set_homepage("https://www.ferzkopp.net/wordpress/2016/01/02/sdl_gfx-sdl2_gfx/")
set_description("Simple DirectMedia Layer primitives drawing library")

if is_plat("windows") then
set_urls("https://www.ferzkopp.net/Software/SDL2_gfx/SDL2_gfx-$(version).zip", {alias = "ferzkopp"})
add_urls("https://sourceforge.net/projects/sdl2gfx/files/SDL2_gfx-$(version).tar.gz", {alias = "sourceforge"})
add_versions("ferzkopp:1.0.4", "b6da07583b7fb8f4d8cee97cac9176b97a287f56a8112e22f38183ecf47b9dcb")
add_versions("sourceforge:1.0.4", "63e0e01addedc9df2f85b93a248f06e8a04affa014a835c2ea34bfe34e576262")

add_patches("1.0.4", path.join(os.scriptdir(), "patches", "1.0.4", "lrint_fix.patch"), "9fb928306fb25293720214377bff2f605f60ea26f43ea5346cf1268c504aff1a")
elseif is_plat("macosx", "linux") then
set_urls("https://www.ferzkopp.net/Software/SDL2_gfx/SDL2_gfx-$(version).tar.gz")
add_urls("https://sourceforge.net/projects/sdl2gfx/files/SDL2_gfx-$(version).tar.gz")
add_versions("1.0.4", "63e0e01addedc9df2f85b93a248f06e8a04affa014a835c2ea34bfe34e576262")
end

if is_plat("mingw") and is_subhost("msys") then
add_extsources("pacman::SDL2_gfx")
elseif is_plat("linux") then
add_extsources("pacman::sdl2_gfx", "apt::libsdl2-gfx-dev")
elseif is_plat("macosx") then
add_extsources("brew::sdl2_gfx")
end

if is_plat("wasm") then
add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
end

add_includedirs("include", "include/SDL2")

on_load(function (package)
package:add("deps", "libsdl2", { configs = { shared = package:config("shared") }})
end)

on_install("windows|x86", "windows|x64", "macosx", "linux", function(package)
io.writefile("xmake.lua", [[
add_rules("mode.debug", "mode.release")
if is_kind("shared") then
add_requires("libsdl2", {configs = {shared = true}})
else
add_requires("libsdl2")
end
target("SDL2_gfx")
set_kind("$(kind)")
add_files("*.c")
add_headerfiles("*.h", {prefixdir = "SDL2"})
add_packages("libsdl2")
add_rules("utils.install.pkgconfig_importfiles")
if is_plat("windows") and is_kind("shared") then
add_defines("DLL_EXPORT")
end
if is_arch("x86", "i386") then
add_defines("USE_MMX")
end
]])
local configs = {}
if package:config("shared") then
configs.kind = "shared"
end
import("package.tools.xmake").install(package, configs)

end)

on_test(function (package)
local ldflags
if package:has_tool("cxx", "cl", "clang-cl") then
ldflags = "-subsystem:console"
elseif package:has_tool("cxx", "clang", "clangxx") then
ldflags = "-Wl,/subsystem:console"
end
assert(package:has_cfuncs("aacircleRGBA", {includes = {"SDL2/SDL_main.h", "SDL2/SDL2_gfxPrimitives.h"}, configs = {ldflags = ldflags}}))
assert(package:has_cfuncs("SDL_initFramerate", {includes = {"SDL2/SDL_main.h", "SDL2/SDL2_framerate.h"}, configs = {ldflags = ldflags}}))
assert(package:has_cfuncs("rotozoomSurface", {includes = {"SDL2/SDL_main.h", "SDL2/SDL2_rotozoom.h"}, configs = {ldflags = ldflags}}))
assert(package:has_cfuncs("SDL_imageFilterAdd", {includes = {"SDL2/SDL_main.h", "SDL2/SDL2_imageFilter.h"}, configs = {ldflags = ldflags}}))
end)
91 changes: 91 additions & 0 deletions packages/l/libsdl2_image/xmake.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
package("libsdl2_image")
set_homepage("http://www.libsdl.org/projects/SDL_image/")
set_description("Simple DirectMedia Layer image loading library")
set_license("zlib")

if is_plat("mingw") and is_subhost("msys") then
add_extsources("pacman::SDL2_image")
elseif is_plat("linux") then
add_extsources("pacman::sdl2_image", "apt::libsdl2-image-dev")
elseif is_plat("macosx") then
add_extsources("brew::sdl2_image")
end

add_urls("https://www.libsdl.org/projects/SDL_image/release/SDL2_image-$(version).zip",
"https://github.com/libsdl-org/SDL_image/releases/download/release-$(version)/SDL2_image-$(version).zip")
add_versions("2.8.4", "a99a906b23d13707df63bc02b7b6a2911282ff82f0f0bd72eaad7a6e53bd1f63")
add_versions("2.8.3", "3d24c5a2b29813d515d4e37a9703bc3ae849963d1dc09e1ad6b46e1b4a6bb3c1")
add_versions("2.6.0", "2252cdfd5be73cefaf727edc39c2ef3b7682e797acbd3126df117e925d46aaf6")
add_versions("2.6.1", "cbfea63a46715c63a1db9e41617e550749a95ffd33ef9bd5ba6e58b2bdca6ed3")
add_versions("2.6.2", "efe3c229853d0d40c35e5a34c3f532d5d9728f0abc623bc62c962bcef8754205")
add_versions("2.6.3", "b448a8ca5b7927d9bd1577d393f4d6c59581f87ee525652a27e699941db37b7c")
add_versions("2.8.0", "fed33c3fe9f8d38ab4460bdd100c4495be40f8afdac1d44bfcd2b0259b74a123")
add_versions("2.8.1", "0c5afef0ac4bc951a46c6790e576c9b3e7ed2c5ab1d2bbfa5e7e9300718f67d2")
add_versions("2.8.2", "2196ad6665b68fc453a659e172d67fbf18d548277aa07344dfd2deed9d9b84bd")

if is_plat("macosx", "iphoneos") then
add_frameworks("CoreFoundation", "CoreGraphics", "ImageIO", "CoreServices")
elseif is_plat("wasm") then
add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
end

add_deps("cmake")

add_includedirs("include", "include/SDL2")

on_load(function (package)
package:add("deps", "libsdl2", { configs = { shared = package:config("shared") }})
end)

on_install(function (package)
if package:is_plat("wasm") then
io.replace("CMakeLists.txt", "sdl_find_sdl2(${sdl2_target_name} ${SDL_REQUIRED_VERSION})", "", {plain = true})
io.replace("CMakeLists.txt", "target_link_libraries(SDL2_image PRIVATE $<BUILD_INTERFACE:${sdl2_target_name}>)", [[
target_include_directories(SDL2_image PRIVATE ${SDL2_INCLUDE_DIR})
target_link_libraries(SDL2_image PRIVATE $<BUILD_INTERFACE:${SDL2_LIBRARY}>)
]], {plain = true})
io.replace("CMakeLists.txt", "target_link_libraries(SDL2_image PRIVATE ${sdl2_target_name})", [[
target_include_directories(SDL2_image PRIVATE ${SDL2_INCLUDE_DIR})
target_link_libraries(SDL2_image PRIVATE ${SDL2_LIBRARY})
]], {plain = true})
end

local configs = {"-DSDL2IMAGE_SAMPLES=OFF", "-DSDL2IMAGE_TESTS=OFF"}
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"))
local libsdl2 = package:dep("libsdl2")
if libsdl2 and not libsdl2:is_system() then
table.insert(configs, "-DSDL2_DIR=" .. libsdl2:installdir())
local fetchinfo = libsdl2:fetch()
if fetchinfo then
for _, dir in ipairs(fetchinfo.includedirs or fetchinfo.sysincludedirs) do
if os.isfile(path.join(dir, "SDL_version.h")) then
table.insert(configs, "-DSDL2_INCLUDE_DIR=" .. dir)
break
end
end
local libfiles = {}
for _, libfile in ipairs(fetchinfo.libfiles) do
if libfile:match("SDL2%..+$") or libfile:match("SDL2-static%..+$") then
if not (package:config("shared") and libfile:endswith(".dll")) then
table.insert(libfiles, libfile)
end
end
end
table.insert(configs, "-DSDL2_LIBRARY=" .. table.concat(libfiles, ";"))
end
end
import("package.tools.cmake").install(package, configs)
end)

on_test(function (package)
assert(package:check_cxxsnippets({test = [[
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
int main(int argc, char** argv) {
IMG_Init(IMG_INIT_PNG);
IMG_Quit();
return 0;
}
]]}, {configs = {defines = "SDL_MAIN_HANDLED"}}));
end)
96 changes: 96 additions & 0 deletions packages/l/libsdl2_mixer/xmake.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
package("libsdl2_mixer")
set_homepage("https://www.libsdl.org/projects/SDL_mixer/")
set_description("Simple DirectMedia Layer mixer audio library")
set_license("zlib")

add_urls("https://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-$(version).zip",
"https://github.com/libsdl-org/SDL_mixer/releases/download/release-$(version)/SDL2_mixer-$(version).zip")
add_versions("2.0.4", "9affb8c7bf6fbffda0f6906bfb99c0ea50dca9b188ba9e15be90042dc03c5ded")
add_versions("2.6.0", "aca0ffc96a4bf2a56a16536a269de28e341ce38a46a25180bc1ef75e19b08a3a")
add_versions("2.6.1", "788c748c1d3a87126511e60995b03526ed4e31e2ba053dffd9dcc8abde97b950")
add_versions("2.6.2", "61549615a67e731805ca1df553e005be966a625c1d20fb085bf99edeef6e0469")
add_versions("2.8.0", "02df784cc68723419dd266530ee6964f810a6f02a27b03ecc85689c2e5e442ce")

if is_plat("mingw") and is_subhost("msys") then
add_extsources("pacman::SDL2_mixer")
elseif is_plat("linux") then
add_extsources("pacman::sdl2_mixer", "apt::libsdl2-mixer-dev")
elseif is_plat("macosx") then
add_extsources("brew::sdl2_mixer")
end

add_deps("cmake")

add_includedirs("include", "include/SDL2")

if is_plat("wasm") then
add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
end

on_load(function (package)
package:add("deps", "libsdl2", { configs = { shared = package:config("shared") }})
end)

on_install(function (package)
if package:is_plat("wasm") then
io.replace("CMakeLists.txt", "sdl_find_sdl2(${sdl2_target_name} ${SDL_REQUIRED_VERSION})", "", {plain = true})
io.replace("CMakeLists.txt", "target_link_libraries(SDL2_mixer PRIVATE $<BUILD_INTERFACE:${sdl2_target_name}>)", [[
target_include_directories(SDL2_mixer PRIVATE ${SDL2_INCLUDE_DIR})
target_link_libraries(SDL2_mixer PRIVATE $<BUILD_INTERFACE:${SDL2_LIBRARY}>)
]], {plain = true})
io.replace("CMakeLists.txt", "target_link_libraries(SDL2_mixer PRIVATE ${sdl2_target_name})", [[
target_include_directories(SDL2_mixer PRIVATE ${SDL2_INCLUDE_DIR})
target_link_libraries(SDL2_mixer PRIVATE ${SDL2_LIBRARY})
]], {plain = true})
end

local configs = {
"-DSDL2MIXER_CMD=OFF",
"-DSDL2MIXER_FLAC=OFF",
"-DSDL2MIXER_GME=OFF",
"-DSDL2MIXER_MIDI=OFF",
"-DSDL2MIXER_MOD=OFF",
"-DSDL2MIXER_MP3=ON", -- was on by not being here
"-DSDL2MIXER_OPUS=OFF",
"-DSDL2MIXER_SAMPLES=OFF",
"-DSDL2MIXER_WAVE=ON", -- was on by not being here
"-DSDL2MIXER_WAVPACK=OFF",
}
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"))
local libsdl2 = package:dep("libsdl2")
if libsdl2 and not libsdl2:is_system() then
table.insert(configs, "-DSDL2_DIR=" .. libsdl2:installdir())
local fetchinfo = libsdl2:fetch()
if fetchinfo then
for _, dir in ipairs(fetchinfo.includedirs or fetchinfo.sysincludedirs) do
if os.isfile(path.join(dir, "SDL_version.h")) then
table.insert(configs, "-DSDL2_INCLUDE_DIR=" .. dir)
break
end
end
local libfiles = {}
for _, libfile in ipairs(fetchinfo.libfiles) do
if libfile:match("SDL2%..+$") or libfile:match("SDL2-static%..+$") then
if not (package:config("shared") and libfile:endswith(".dll")) then
table.insert(libfiles, libfile)
end
end
end
table.insert(configs, "-DSDL2_LIBRARY=" .. table.concat(libfiles, ";"))
end
end
import("package.tools.cmake").install(package, configs)
end)

on_test(function (package)
assert(package:check_cxxsnippets({test = [[
#include <SDL2/SDL.h>
#include <SDL2/SDL_mixer.h>
int main(int argc, char** argv) {
Mix_Init(MIX_INIT_OGG);
Mix_Quit();
return 0;
}
]]}, {configs = {defines = "SDL_MAIN_HANDLED"}}));
end)
86 changes: 86 additions & 0 deletions packages/l/libsdl2_net/xmake.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
package("libsdl2_net")
set_homepage("https://www.libsdl.org/projects/SDL_net/")
set_description("Simple DirectMedia Layer networking library")
set_license("zlib")

add_urls("https://www.libsdl.org/projects/SDL_net/release/SDL2_net-$(version).zip",
"https://github.com/libsdl-org/SDL_net/releases/download/release-$(version)/SDL2_net-$(version).zip")
add_versions("2.2.0", "1eec3a9d43df019d7916a6ecce32f2a3ad5248c82c9c237948afc712399be36d")

if is_plat("mingw") and is_subhost("msys") then
add_extsources("pacman::SDL2_net")
elseif is_plat("linux") then
add_extsources("pacman::sdl2_net", "apt::libsdl2-net-dev")
elseif is_plat("macosx") then
add_extsources("brew::sdl2_net")
end

add_deps("cmake")

if is_plat("windows", "mingw") then
add_syslinks("iphlpapi", "ws2_32")
end

if is_plat("wasm") then
add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
end

add_includedirs("include", "include/SDL2")

on_load(function (package)
package:add("deps", "libsdl2", { configs = { shared = package:config("shared") }})
end)

on_install(function (package)
if package:is_plat("wasm") then
io.replace("CMakeLists.txt", "sdl_find_sdl2(${sdl2_target_name} ${SDL_REQUIRED_VERSION})", "", {plain = true})
io.replace("CMakeLists.txt", "target_link_libraries(SDL2_net PRIVATE $<BUILD_INTERFACE:${sdl2_target_name}>)", [[
target_include_directories(SDL2_net PRIVATE ${SDL2_INCLUDE_DIR})
target_link_libraries(SDL2_net PRIVATE $<BUILD_INTERFACE:${SDL2_LIBRARY}>)
]], {plain = true})
io.replace("CMakeLists.txt", "target_link_libraries(SDL2_net PRIVATE ${sdl2_target_name})", [[
target_include_directories(SDL2_net PRIVATE ${SDL2_INCLUDE_DIR})
target_link_libraries(SDL2_net PRIVATE ${SDL2_LIBRARY})
]], {plain = true})
end

local configs = {"-DSDL2NET_SAMPLES=OFF"}
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"))
local libsdl2 = package:dep("libsdl2")
if libsdl2 and not libsdl2:is_system() then
table.insert(configs, "-DSDL2_DIR=" .. libsdl2:installdir())
local fetchinfo = libsdl2:fetch()
if fetchinfo then
for _, dir in ipairs(fetchinfo.includedirs or fetchinfo.sysincludedirs) do
if os.isfile(path.join(dir, "SDL_version.h")) then
table.insert(configs, "-DSDL2_INCLUDE_DIR=" .. dir)
break
end
end
local libfiles = {}
for _, libfile in ipairs(fetchinfo.libfiles) do
if libfile:match("SDL2%..+$") or libfile:match("SDL2-static%..+$") then
if not (package:config("shared") and libfile:endswith(".dll")) then
table.insert(libfiles, libfile)
end
end
end
table.insert(configs, "-DSDL2_LIBRARY=" .. table.concat(libfiles, ";"))
end
end
io.replace("CMakeLists.txt", "find_package(SDL2test)", "", {plain = true})
import("package.tools.cmake").install(package, configs)
end)

on_test(function (package)
assert(package:check_cxxsnippets({test = [[
#include <SDL2/SDL.h>
#include <SDL2/SDL_net.h>
int main(int argc, char** argv) {
SDLNet_Init();
SDLNet_Quit();
return 0;
}
]]}, {configs = {defines = "SDL_MAIN_HANDLED"}}));
end)
15 changes: 15 additions & 0 deletions packages/l/libsdl2_ttf/patches/2.20.1/cmakelists.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0aac377..94a44f4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -348,8 +348,8 @@ if(SDL2TTF_INSTALL)
endif()
# Only install a SDL2_ttf.pc file in Release mode
install(CODE "
- file(COPY_FILE \"${CMAKE_CURRENT_BINARY_DIR}/SDL2_ttf-$<CONFIG>.pc\"
- \"${CMAKE_CURRENT_BINARY_DIR}/SDL2_ttf.pc\" ONLY_IF_DIFFERENT)
+ file(COPY \"${CMAKE_CURRENT_BINARY_DIR}/SDL2_ttf-$<CONFIG>.pc\"
+ DESTINATION \"${CMAKE_CURRENT_BINARY_DIR}/SDL2_ttf.pc\")
file(INSTALL DESTINATION \"\${CMAKE_INSTALL_PREFIX}/${PC_DESTDIR}\"
TYPE FILE
FILES \"${CMAKE_CURRENT_BINARY_DIR}/SDL2_ttf.pc\")" CONFIG Release)
Loading

0 comments on commit d3ff3e7

Please sign in to comment.