rename libsdl_xxx to libsdl2_xxx (#6316)
parent
7bd41fa835
commit
079396268b
12 changed files with 514 additions and 438 deletions
@ -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>
|
@ -0,0 +1,78 @@ |
||||
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:is_plat("windows") then |
||||
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 |
||||
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) |
@ -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) |
@ -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) |
@ -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) |
@ -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)
|
@ -0,0 +1,119 @@ |
||||
package("libsdl2_ttf") |
||||
set_homepage("https://github.com/libsdl-org/SDL_ttf/") |
||||
set_description("Simple DirectMedia Layer text rendering library") |
||||
set_license("zlib") |
||||
|
||||
if is_plat("mingw") and is_subhost("msys") then |
||||
add_extsources("pacman::SDL2_ttf") |
||||
elseif is_plat("linux") then |
||||
add_extsources("pacman::sdl2_ttf", "apt::libsdl2-ttf-dev") |
||||
elseif is_plat("macosx") then |
||||
add_extsources("brew::sdl2_ttf") |
||||
end |
||||
|
||||
add_urls("https://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-$(version).zip", |
||||
"https://github.com/libsdl-org/SDL_ttf/releases/download/release-$(version)/SDL2_ttf-$(version).zip") |
||||
|
||||
add_versions("2.20.0", "04e94fc5ecac3475ab35c1d5cf52650df691867e7e4befcc861bf982a747111a") |
||||
add_versions("2.20.1", "18d81ab399c8e39adababe8918691830ba6e0d6448e5baa141ee0ddf87ede2dc") |
||||
add_versions("2.20.2", "aa6256bfcffd8381a75b3a2a2384ac12109b5b148e72722a19b0ede54c4051dc") |
||||
add_versions("2.22.0", "5766070145111cb047807fa3f91c2c6b81bc1008d63817e100417959b42a2484") |
||||
|
||||
add_patches(">=2.20.0 <=2.20.1", path.join(os.scriptdir(), "patches", "2.20.1", "cmakelists.patch"), "fe04ada62d9ed70029c0efb3c04bfec22fc7596bd6b73a567beb964e61ebd82c") |
||||
|
||||
add_deps("cmake", "freetype") |
||||
|
||||
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_ttf PRIVATE $<BUILD_INTERFACE:${sdl2_target_name}>)", [[ |
||||
target_include_directories(SDL2_ttf PRIVATE ${SDL2_INCLUDE_DIR}) |
||||
target_link_libraries(SDL2_ttf PRIVATE $<BUILD_INTERFACE:${SDL2_LIBRARY}>) |
||||
]], {plain = true}) |
||||
io.replace("CMakeLists.txt", "target_link_libraries(SDL2_ttf PRIVATE ${sdl2_target_name})", [[ |
||||
target_include_directories(SDL2_ttf PRIVATE ${SDL2_INCLUDE_DIR}) |
||||
target_link_libraries(SDL2_ttf PRIVATE ${SDL2_LIBRARY}) |
||||
]], {plain = true}) |
||||
end |
||||
|
||||
local configs = {"-DSDL2TTF_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")) |
||||
table.insert(configs, "-DSDL2TTF_VENDORED=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 |
||||
local freetype = package:dep("freetype") |
||||
if freetype then |
||||
local fetchinfo = freetype:fetch() |
||||
if fetchinfo then |
||||
local includedirs = table.wrap(fetchinfo.includedirs or fetchinfo.sysincludedirs) |
||||
if #includedirs > 0 then |
||||
table.insert(configs, "-DFREETYPE_INCLUDE_DIRS=" .. table.concat(includedirs, ";")) |
||||
end |
||||
local libfiles = table.wrap(fetchinfo.libfiles) |
||||
if #libfiles > 0 then |
||||
table.insert(configs, "-DFREETYPE_LIBRARY=" .. libfiles[1]) |
||||
end |
||||
if not freetype:config("shared") then |
||||
local libfiles = {} |
||||
for _, dep in ipairs(freetype:librarydeps()) do |
||||
local depinfo = dep:fetch() |
||||
if depinfo then |
||||
table.join2(libfiles, depinfo.libfiles) |
||||
end |
||||
end |
||||
if #libfiles > 0 then |
||||
local libraries = "" |
||||
for _, libfile in ipairs(libfiles) do |
||||
libraries = libraries .. " " .. (libfile:gsub("\\", "/")) |
||||
end |
||||
io.replace("CMakeLists.txt", "target_link_libraries(SDL2_ttf PRIVATE Freetype::Freetype)", |
||||
"target_link_libraries(SDL2_ttf PRIVATE Freetype::Freetype " .. libraries .. ")", {plain = true}) |
||||
end |
||||
end |
||||
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_ttf.h> |
||||
int main(int argc, char** argv) { |
||||
TTF_Init(); |
||||
TTF_Quit(); |
||||
return 0; |
||||
} |
||||
]]}, {configs = {defines = "SDL_MAIN_HANDLED"}})); |
||||
end) |
@ -1,75 +1,9 @@ |
||||
package("libsdl_gfx") |
||||
set_base("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") |
||||
add_deps("cmake") |
||||
|
||||
on_load(function (package) |
||||
if package:config("shared") then |
||||
package:add("deps", "libsdl", { configs = { shared = true }}) |
||||
else |
||||
package:add("deps", "libsdl") |
||||
end |
||||
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("libsdl", {configs = {shared = true}}) |
||||
else |
||||
add_requires("libsdl") |
||||
end |
||||
target("SDL2_gfx") |
||||
set_kind("$(kind)") |
||||
add_files("*.c") |
||||
add_headerfiles("*.h", {prefixdir = "SDL2"}) |
||||
add_packages("libsdl") |
||||
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) |
||||
assert(package:has_cfuncs("aacircleRGBA", {includes = {"SDL2/SDL_main.h", "SDL2/SDL2_gfxPrimitives.h"}})) |
||||
assert(package:has_cfuncs("SDL_initFramerate", {includes = {"SDL2/SDL_main.h", "SDL2/SDL2_framerate.h"}})) |
||||
assert(package:has_cfuncs("rotozoomSurface", {includes = {"SDL2/SDL_main.h", "SDL2/SDL2_rotozoom.h"}})) |
||||
assert(package:has_cfuncs("SDL_imageFilterAdd", {includes = {"SDL2/SDL_main.h", "SDL2/SDL2_imageFilter.h"}})) |
||||
wprint("libsdl_gfx package has been renamed to libsdl2_gfx following the release of SDL3, please update the package name in your xmake.lua.${clear}") |
||||
package:base():script("load")(package) |
||||
end) |
||||
|
@ -1,91 +1,9 @@ |
||||
package("libsdl_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 |
||||
set_base("libsdl2_image") |
||||
|
||||
add_deps("cmake") |
||||
|
||||
add_includedirs("include", "include/SDL2") |
||||
|
||||
on_load(function (package) |
||||
package:add("deps", "libsdl", { 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 libsdl = package:dep("libsdl") |
||||
if libsdl and not libsdl:is_system() then |
||||
table.insert(configs, "-DSDL2_DIR=" .. libsdl:installdir()) |
||||
local fetchinfo = libsdl: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"}})); |
||||
wprint("libsdl_image package has been renamed to libsdl2_image following the release of SDL3, please update the package name in your xmake.lua.${clear}") |
||||
package:base():script("load")(package) |
||||
end) |
||||
|
@ -1,96 +1,9 @@ |
||||
package("libsdl_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 |
||||
set_base("libsdl2_mixer") |
||||
|
||||
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", "libsdl", { 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 libsdl = package:dep("libsdl") |
||||
if libsdl and not libsdl:is_system() then |
||||
table.insert(configs, "-DSDL2_DIR=" .. libsdl:installdir()) |
||||
local fetchinfo = libsdl: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"}})); |
||||
wprint("libsdl_mixer package has been renamed to libsdl2_mixer following the release of SDL3, please update the package name in your xmake.lua.${clear}") |
||||
package:base():script("load")(package) |
||||
end) |
||||
|
@ -1,86 +1,9 @@ |
||||
package("libsdl_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 |
||||
set_base("libsdl2_net") |
||||
|
||||
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", "libsdl", { 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 libsdl = package:dep("libsdl") |
||||
if libsdl and not libsdl:is_system() then |
||||
table.insert(configs, "-DSDL2_DIR=" .. libsdl:installdir()) |
||||
local fetchinfo = libsdl: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"}})); |
||||
wprint("libsdl_net package has been renamed to libsdl2_net following the release of SDL3, please update the package name in your xmake.lua.${clear}") |
||||
package:base():script("load")(package) |
||||
end) |
||||
|
@ -1,119 +1,9 @@ |
||||
package("libsdl_ttf") |
||||
set_homepage("https://github.com/libsdl-org/SDL_ttf/") |
||||
set_description("Simple DirectMedia Layer text rendering library") |
||||
set_license("zlib") |
||||
|
||||
if is_plat("mingw") and is_subhost("msys") then |
||||
add_extsources("pacman::SDL2_ttf") |
||||
elseif is_plat("linux") then |
||||
add_extsources("pacman::sdl2_ttf", "apt::libsdl2-ttf-dev") |
||||
elseif is_plat("macosx") then |
||||
add_extsources("brew::sdl2_ttf") |
||||
end |
||||
|
||||
add_urls("https://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-$(version).zip", |
||||
"https://github.com/libsdl-org/SDL_ttf/releases/download/release-$(version)/SDL2_ttf-$(version).zip") |
||||
|
||||
add_versions("2.20.0", "04e94fc5ecac3475ab35c1d5cf52650df691867e7e4befcc861bf982a747111a") |
||||
add_versions("2.20.1", "18d81ab399c8e39adababe8918691830ba6e0d6448e5baa141ee0ddf87ede2dc") |
||||
add_versions("2.20.2", "aa6256bfcffd8381a75b3a2a2384ac12109b5b148e72722a19b0ede54c4051dc") |
||||
add_versions("2.22.0", "5766070145111cb047807fa3f91c2c6b81bc1008d63817e100417959b42a2484") |
||||
|
||||
add_patches(">=2.20.0 <=2.20.1", path.join(os.scriptdir(), "patches", "2.20.1", "cmakelists.patch"), "fe04ada62d9ed70029c0efb3c04bfec22fc7596bd6b73a567beb964e61ebd82c") |
||||
set_base("libsdl2_ttf") |
||||
|
||||
add_deps("cmake", "freetype") |
||||
|
||||
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", "libsdl", { 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_ttf PRIVATE $<BUILD_INTERFACE:${sdl2_target_name}>)", [[ |
||||
target_include_directories(SDL2_ttf PRIVATE ${SDL2_INCLUDE_DIR}) |
||||
target_link_libraries(SDL2_ttf PRIVATE $<BUILD_INTERFACE:${SDL2_LIBRARY}>) |
||||
]], {plain = true}) |
||||
io.replace("CMakeLists.txt", "target_link_libraries(SDL2_ttf PRIVATE ${sdl2_target_name})", [[ |
||||
target_include_directories(SDL2_ttf PRIVATE ${SDL2_INCLUDE_DIR}) |
||||
target_link_libraries(SDL2_ttf PRIVATE ${SDL2_LIBRARY}) |
||||
]], {plain = true}) |
||||
end |
||||
|
||||
local configs = {"-DSDL2TTF_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")) |
||||
table.insert(configs, "-DSDL2TTF_VENDORED=OFF") |
||||
local libsdl = package:dep("libsdl") |
||||
if libsdl and not libsdl:is_system() then |
||||
table.insert(configs, "-DSDL2_DIR=" .. libsdl:installdir()) |
||||
local fetchinfo = libsdl: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 |
||||
local freetype = package:dep("freetype") |
||||
if freetype then |
||||
local fetchinfo = freetype:fetch() |
||||
if fetchinfo then |
||||
local includedirs = table.wrap(fetchinfo.includedirs or fetchinfo.sysincludedirs) |
||||
if #includedirs > 0 then |
||||
table.insert(configs, "-DFREETYPE_INCLUDE_DIRS=" .. table.concat(includedirs, ";")) |
||||
end |
||||
local libfiles = table.wrap(fetchinfo.libfiles) |
||||
if #libfiles > 0 then |
||||
table.insert(configs, "-DFREETYPE_LIBRARY=" .. libfiles[1]) |
||||
end |
||||
if not freetype:config("shared") then |
||||
local libfiles = {} |
||||
for _, dep in ipairs(freetype:librarydeps()) do |
||||
local depinfo = dep:fetch() |
||||
if depinfo then |
||||
table.join2(libfiles, depinfo.libfiles) |
||||
end |
||||
end |
||||
if #libfiles > 0 then |
||||
local libraries = "" |
||||
for _, libfile in ipairs(libfiles) do |
||||
libraries = libraries .. " " .. (libfile:gsub("\\", "/")) |
||||
end |
||||
io.replace("CMakeLists.txt", "target_link_libraries(SDL2_ttf PRIVATE Freetype::Freetype)", |
||||
"target_link_libraries(SDL2_ttf PRIVATE Freetype::Freetype " .. libraries .. ")", {plain = true}) |
||||
end |
||||
end |
||||
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_ttf.h> |
||||
int main(int argc, char** argv) { |
||||
TTF_Init(); |
||||
TTF_Quit(); |
||||
return 0; |
||||
} |
||||
]]}, {configs = {defines = "SDL_MAIN_HANDLED"}})); |
||||
wprint("libsdl_ttf package has been renamed to libsdl2_ttf following the release of SDL3, please update the package name in your xmake.lua.${clear}") |
||||
package:base():script("load")(package) |
||||
end) |
||||
|
Loading…
Reference in new issue