diff --git a/packages/l/libsdl/xmake.lua b/packages/l/libsdl/xmake.lua
index f7dacde4f..cf132f200 100644
--- a/packages/l/libsdl/xmake.lua
+++ b/packages/l/libsdl/xmake.lua
@@ -49,6 +49,10 @@ package("libsdl")
add_configs("with_x", {description = "Enables X support (requires it on the system)", default = true, type = "boolean"})
end
+ if is_plat("wasm") then
+ add_cxflags("-sUSE_SDL=0")
+ end
+
on_load(function (package)
if package:config("use_sdlmain") then
package:add("components", "main")
@@ -172,9 +176,6 @@ package("libsdl")
end
table.insert(configs, "-DCMAKE_INCLUDE_PATH=" .. table.concat(includedirs, ";"))
end
- elseif package:is_plat("bsd") then
- opt = opt or {}
- opt.packagedeps = "libusb"
elseif package:is_plat("wasm") then
-- emscripten enables USE_SDL by default which will conflict with the sdl headers
opt = opt or {}
@@ -184,5 +185,6 @@ package("libsdl")
end)
on_test(function (package)
- assert(package:has_cfuncs("SDL_Init", {includes = "SDL2/SDL.h", configs = {defines = "SDL_MAIN_HANDLED"}}))
+ assert(package:has_cfuncs("SDL_Init",
+ {includes = "SDL2/SDL.h", configs = {defines = "SDL_MAIN_HANDLED"}}))
end)
diff --git a/packages/l/libsdl_gfx/patches/1.0.4/add-x64-support.patch b/packages/l/libsdl_gfx/patches/1.0.4/add-x64-support.patch
deleted file mode 100644
index 61bf93909..000000000
--- a/packages/l/libsdl_gfx/patches/1.0.4/add-x64-support.patch
+++ /dev/null
@@ -1,176 +0,0 @@
-diff --git a/SDL2_gfx.sln b/SDL2_gfx.sln
-index 786f339..bd7635b 100644
---- a/SDL2_gfx.sln
-+++ b/SDL2_gfx.sln
-@@ -15,12 +15,18 @@ Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Win32 = Debug|Win32
- Release|Win32 = Release|Win32
-+ Debug|x64 = Debug|x64
-+ Release|x64 = Release|x64
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {AE22EFD3-6E6D-48C0-AF3D-EF190406BEDC}.Debug|Win32.ActiveCfg = Debug|Win32
- {AE22EFD3-6E6D-48C0-AF3D-EF190406BEDC}.Debug|Win32.Build.0 = Debug|Win32
- {AE22EFD3-6E6D-48C0-AF3D-EF190406BEDC}.Release|Win32.ActiveCfg = Release|Win32
- {AE22EFD3-6E6D-48C0-AF3D-EF190406BEDC}.Release|Win32.Build.0 = Release|Win32
-+ {AE22EFD3-6E6D-48C0-AF3D-EF190406BEDC}.Debug|x64.ActiveCfg = Debug|x64
-+ {AE22EFD3-6E6D-48C0-AF3D-EF190406BEDC}.Debug|x64.Build.0 = Debug|x64
-+ {AE22EFD3-6E6D-48C0-AF3D-EF190406BEDC}.Release|x64.ActiveCfg = Release|x64
-+ {AE22EFD3-6E6D-48C0-AF3D-EF190406BEDC}.Release|x64.Build.0 = Release|x64
- {AE22EFD3-6F6D-48C0-AF3D-EF190406BEDC}.Debug|Win32.ActiveCfg = Debug|Win32
- {AE22EFD3-6F6D-48C0-AF3D-EF190406BEDC}.Debug|Win32.Build.0 = Debug|Win32
- {AE22EFD3-6F6D-48C0-AF3D-EF190406BEDC}.Release|Win32.ActiveCfg = Release|Win32
-diff --git a/SDL2_gfx.vcxproj b/SDL2_gfx.vcxproj
-index e842d8a..4ae0cfa 100644
---- a/SDL2_gfx.vcxproj
-+++ b/SDL2_gfx.vcxproj
-@@ -9,24 +9,42 @@
- Release
- Win32
-
-+
-+ Debug
-+ x64
-+
-+
-+ Release
-+ x64
-+
-
-
- {AE22EFD3-6E6D-48C0-AF3D-EF190406BEDC}
- SDL2_gfx
- Win32Proj
-- 10.0.14393.0
-
-
-
- DynamicLibrary
- Unicode
- true
-- v141
-+ v142
-
-
- DynamicLibrary
- Unicode
-- v141
-+ v142
-+
-+
-+ DynamicLibrary
-+ Unicode
-+ true
-+ v142
-+
-+
-+ DynamicLibrary
-+ Unicode
-+ v142
-
-
-
-@@ -37,6 +55,12 @@
-
-
-
-+
-+
-+
-+
-+
-+
-
-
- <_ProjectFileVersion>10.0.30319.1
-@@ -46,6 +70,12 @@
- $(Platform)\$(Configuration)\
- $(Platform)\$(Configuration)\
- false
-+ $(Platform)\$(Configuration)\
-+ $(Platform)\$(Configuration)\
-+ true
-+ $(Platform)\$(Configuration)\
-+ $(Platform)\$(Configuration)\
-+ false
-
-
-
-@@ -104,6 +134,63 @@
-
-
-
-+
-+
-+ Disabled
-+ ..\SDL2-2.0.5\include;%(AdditionalIncludeDirectories)
-+ WIN32;_DEBUG;_WINDOWS;_USRDLL;DLL_EXPORT;USE_MMX;%(PreprocessorDefinitions)
-+ true
-+ EnableFastChecks
-+ MultiThreadedDebugDLL
-+
-+
-+ Level3
-+ EditAndContinue
-+
-+
-+ SDL2.lib;%(AdditionalDependencies)
-+ ..\SDL2-2.0.5\VisualC\$(Platform)\$(Configuration);%(AdditionalLibraryDirectories)
-+ true
-+ Windows
-+ false
-+
-+
-+
-+
-+ MachineX64
-+
-+
-+
-+
-+
-+
-+
-+
-+ MaxSpeed
-+ ..\SDL2-2.0.5\include;%(AdditionalIncludeDirectories)
-+ true
-+ WIN32;_DEBUG;_WINDOWS;_USRDLL;DLL_EXPORT;%(PreprocessorDefinitions)
-+ MultiThreadedDLL
-+ true
-+
-+
-+ Level3
-+ ProgramDatabase
-+
-+
-+ SDL2.lib;%(AdditionalDependencies)
-+ ..\SDL2-2.0.5\VisualC\$(Platform)\$(Configuration);%(AdditionalLibraryDirectories)
-+ true
-+ Windows
-+ true
-+ true
-+ MachineX64
-+
-+
-+
-+
-+
-+
-
-
-
-@@ -121,10 +208,12 @@
-
- Document
- true
-+ true
-
-
- Document
- true
-+ true
-
-
-
diff --git a/packages/l/libsdl_gfx/xmake.lua b/packages/l/libsdl_gfx/xmake.lua
index b93d9d9a9..dba76ecb1 100644
--- a/packages/l/libsdl_gfx/xmake.lua
+++ b/packages/l/libsdl_gfx/xmake.lua
@@ -9,7 +9,6 @@ package("libsdl_gfx")
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", "add-x64-support.patch"), "2ea0eda111d95864bbc9aedbf8aa91dd3923208d2816a626dfd6bc173986e426")
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")
@@ -25,62 +24,47 @@ package("libsdl_gfx")
add_extsources("brew::sdl2_gfx")
end
- add_deps("libsdl")
-
- add_links("SDL2_gfx")
+ 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_install("windows", function(package)
- import("core.tool.toolchain")
- local vs = tonumber(toolchain.load("msvc"):config("vs"))
- if vs < 2019 then
- raise("Your compiler is too old to use this library.")
- end
-
- local file_name = "SDL2_gfx.vcxproj"
- local content = io.readfile(file_name)
- content = content:gsub("%%%(AdditionalIncludeDirectories%)", package:dep("libsdl"):installdir("include", "SDL2") .. ";%%(AdditionalIncludeDirectories)")
- content = content:gsub("%%%(AdditionalLibraryDirectories%)", package:dep("libsdl"):installdir("lib") .. ";%%(AdditionalLibraryDirectories)")
- io.writefile(file_name, content)
-
- -- MSVC trick no longer required since C++11
- io.replace("SDL2_gfxPrimitives.c", "#if defined(_MSC_VER)", "#if 0", {plain = true})
-
- local configs = {}
- local arch = package:is_arch("x86") and "Win32" or "x64"
- local mode = package:debug() and "Debug" or "Release"
-
- table.insert(configs, "/property:Configuration=" .. mode)
- table.insert(configs, "/property:Platform=" .. arch)
- if vs >= 2022 then
- table.insert(configs, "/p:PlatformToolset=v143")
+ on_load(function (package)
+ if package:config("shared") then
+ package:add("deps", "libsdl", { configs = { shared = true }})
+ else
+ package:add("deps", "libsdl")
end
- table.insert(configs, "-target:SDL2_gfx")
-
- import("package.tools.msbuild").build(package, configs)
-
- local build_dir = path.join(arch, mode)
- os.cp(path.join(build_dir, "*.lib"), package:installdir("lib"))
- os.cp(path.join(build_dir, "*.dll"), package:installdir("bin"))
- os.cp("*.h", package:installdir("include", "SDL2"))
end)
- on_install("macosx", "linux", function (package)
+ 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
- table.insert(configs, "--enable-shared=yes")
- else
- table.insert(configs, "--enable-shared=no")
- end
- if package:is_plat("linux") and package:config("pic") ~= false then
- table.insert(configs, "--with-pic")
+ configs.kind = "shared"
end
- local libsdl = package:dep("libsdl")
- if libsdl and not libsdl:is_system() then
- table.insert(configs, "--with-sdl-prefix=" .. libsdl:installdir())
- end
- import("package.tools.autoconf").install(package, configs)
+ import("package.tools.xmake").install(package, configs)
+
end)
on_test(function (package)
diff --git a/packages/l/libsdl_image/xmake.lua b/packages/l/libsdl_image/xmake.lua
index 7997e6827..8e306b6cc 100644
--- a/packages/l/libsdl_image/xmake.lua
+++ b/packages/l/libsdl_image/xmake.lua
@@ -1,5 +1,4 @@
package("libsdl_image")
-
set_homepage("http://www.libsdl.org/projects/SDL_image/")
set_description("Simple DirectMedia Layer image loading library")
set_license("zlib")
@@ -12,71 +11,53 @@ package("libsdl_image")
add_extsources("brew::sdl2_image")
end
- if is_plat("windows", "mingw") then
- set_urls("https://www.libsdl.org/projects/SDL_image/release/SDL2_image-devel-$(version)-VC.zip")
- add_urls("https://github.com/libsdl-org/SDL_image/releases/download/release-$(version)/SDL2_image-devel-$(version)-VC.zip")
- add_versions("2.0.5", "a180f9b75c4d3fbafe02af42c42463cc7bc488e763cfd1ec2ffb75678b4387ac")
- add_versions("2.6.0", "e8953ec28e689fdef7805d0dc6913b8038dc6e250fe340929e459f367e2e75fa")
- add_versions("2.6.1", "b431347d039081b3ec065670d3037f106c8683f11491c45776cde7e69965a5f3")
- add_versions("2.6.2", "f510a58b03ce2b74a68d4e6733c47c1931813ab1736e533ad576f4cecb3a8a4d")
- else
- set_urls("https://www.libsdl.org/projects/SDL_image/release/SDL2_image-$(version).zip")
- add_urls("https://github.com/libsdl-org/SDL_image/releases/download/release-$(version)/SDL2_image-$(version).zip")
- add_versions("2.0.5", "eee0927d1e7819d57c623fe3e2b3c6761c77c474fe9bc425e8674d30ac049b1c")
- add_versions("2.6.0", "2252cdfd5be73cefaf727edc39c2ef3b7682e797acbd3126df117e925d46aaf6")
- add_versions("2.6.1", "cbfea63a46715c63a1db9e41617e550749a95ffd33ef9bd5ba6e58b2bdca6ed3")
- add_versions("2.6.2", "efe3c229853d0d40c35e5a34c3f532d5d9728f0abc623bc62c962bcef8754205")
- 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.6.0", "2252cdfd5be73cefaf727edc39c2ef3b7682e797acbd3126df117e925d46aaf6")
+ add_versions("2.6.1", "cbfea63a46715c63a1db9e41617e550749a95ffd33ef9bd5ba6e58b2bdca6ed3")
+ add_versions("2.6.2", "efe3c229853d0d40c35e5a34c3f532d5d9728f0abc623bc62c962bcef8754205")
- if is_plat("macosx") then
+ 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("libsdl")
+ add_deps("cmake")
- add_links("SDL2_image")
add_includedirs("include", "include/SDL2")
- on_load("macosx", "linux", function (package)
- if package:version():ge("2.6") then
- package:add("deps", "cmake")
+ on_load(function (package)
+ if package:config("shared") then
+ package:add("deps", "libsdl", { configs = { shared = true }})
else
- package:add("deps", "automake", "autoconf")
+ package:add("deps", "libsdl")
end
end)
- on_install("windows", "mingw", function (package)
- local arch = package:arch()
- if package:is_plat("mingw") then
- arch = (arch == "x86_64") and "x64" or "x86"
- end
- os.cp("include/*", package:installdir("include/SDL2"))
- os.cp(path.join("lib", arch, "*.lib"), package:installdir("lib"))
- os.cp(path.join("lib", arch, "*.dll"), package:installdir("bin"))
- end)
-
- on_install("macosx", "linux", function (package)
- if package:version():ge("2.6") then
- local configs = {"-DSDL_TEST=OFF"}
- table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
- table.insert(configs, "-DSDL_STATIC=" .. (package:config("shared") and "OFF" or "ON"))
- table.insert(configs, "-DSDL_SHARED=" .. (package:config("shared") and "ON" or "OFF"))
- if libsdl and not libsdl:is_system() then
- table.insert(configs, "-DSDL2_DIR=" .. libsdl:installdir())
- end
- import("package.tools.cmake").install(package, configs)
- else
- local configs = {}
- table.insert(configs, "--enable-shared=" .. (package:config("shared") and "yes" or "no"))
- table.insert(configs, "--enable-static=" .. (package:config("shared") and "no" or "yes"))
- local libsdl = package:dep("libsdl")
- if libsdl and not libsdl:is_system() then
- table.insert(configs, "--with-sdl-prefix=" .. libsdl:installdir())
+ on_install(function (package)
+ 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
+ for _, libfile in ipairs(fetchinfo.libfiles) do
+ if libfile:match("SDL2%..+$") or libfile:match("SDL2-static%..+$") then
+ table.insert(configs, "-DSDL2_LIBRARY=" .. table.concat(fetchinfo.libfiles, ";"))
+ end
+ end
end
- io.replace("Makefile.am", "noinst_PROGRAMS = showimage.-\n", "\n")
- os.rm("./configure")
- import("package.tools.autoconf").install(package, configs)
end
+ import("package.tools.cmake").install(package, configs)
end)
on_test(function (package)
diff --git a/packages/l/libsdl_mixer/xmake.lua b/packages/l/libsdl_mixer/xmake.lua
index b0bb6e6e7..16f4d581d 100644
--- a/packages/l/libsdl_mixer/xmake.lua
+++ b/packages/l/libsdl_mixer/xmake.lua
@@ -1,23 +1,14 @@
package("libsdl_mixer")
-
set_homepage("https://www.libsdl.org/projects/SDL_mixer/")
set_description("Simple DirectMedia Layer mixer audio library")
+ set_license("zlib")
- if is_plat("windows", "mingw") then
- set_urls("https://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-devel-$(version)-VC.zip")
- add_urls("https://github.com/libsdl-org/SDL_mixer/releases/download/release-$(version)/SDL2_mixer-devel-$(version)-VC.zip")
- add_versions("2.0.4", "258788438b7e0c8abb386de01d1d77efe79287d9967ec92fbb3f89175120f0b0")
- add_versions("2.6.0", "b8862b95340b8990177fdb3fb1f22fe5fd089d8b2ad0a30bf7d84e0f4a6138ae")
- add_versions("2.6.1", "e086e1fed423a801e0e7573af063f2f51d3bcef0c9da356ed8a62a7a7f7a0815")
- add_versions("2.6.2", "7f050663ccc7911bb9c57b11e32ca79578b712490186b8645ddbbe4e7d2fe1c9")
- else
- set_urls("https://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-$(version).zip")
- add_urls("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")
- end
+ 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")
if is_plat("mingw") and is_subhost("msys") then
add_extsources("pacman::SDL2_mixer")
@@ -27,51 +18,50 @@ package("libsdl_mixer")
add_extsources("brew::sdl2_mixer")
end
- add_deps("libsdl")
-
- add_links("SDL2_mixer")
+ add_deps("cmake")
add_includedirs("include", "include/SDL2")
- on_load(function (package)
- if package:version():ge("2.6") and package:is_plat("macosx", "linux") then
- package:add("deps", "cmake")
- end
- end)
+ if is_plat("wasm") then
+ add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
+ end
- on_install("windows", "mingw", function (package)
- local arch = package:arch()
- if package:is_plat("mingw") then
- arch = (arch == "x86_64") and "x64" or "x86"
+ on_load(function (package)
+ if package:config("shared") then
+ package:add("deps", "libsdl", { configs = { shared = true }})
+ else
+ package:add("deps", "libsdl")
end
- os.cp("include/*", package:installdir("include/SDL2"))
- os.cp(path.join("lib", arch, "*.lib"), package:installdir("lib"))
- os.cp(path.join("lib", arch, "*.dll"), package:installdir("bin"))
end)
- on_install("macosx", "linux", function (package)
- if package:version():ge("2.6") then
- local configs = {"-DSDL2MIXER_SAMPLES=OFF",
- "-DSDL2MIXER_FLAC=OFF",
- "-DSDL2MIXER_OPUS=OFF",
- "-DSDL2MIXER_MOD=OFF",
- "-DSDL2MIXER_MIDI=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"))
- if libsdl and not libsdl:is_system() then
- table.insert(configs, "-DSDL2_DIR=" .. libsdl:installdir())
- end
- import("package.tools.cmake").install(package, configs)
- else
- local configs = {}
- table.insert(configs, "--enable-shared=" .. (package:config("shared") and "yes" or "no"))
- table.insert(configs, "--enable-static=" .. (package:config("shared") and "no" or "yes"))
- local libsdl = package:dep("libsdl")
- if libsdl and not libsdl:is_system() then
- table.insert(configs, "--with-sdl-prefix=" .. libsdl:installdir())
+ on_install(function (package)
+ local configs = {"-DSDL2MIXER_SAMPLES=OFF",
+ "-DSDL2MIXER_FLAC=OFF",
+ "-DSDL2MIXER_OPUS=OFF",
+ "-DSDL2MIXER_MOD=OFF",
+ "-DSDL2MIXER_MIDI=OFF",
+ "-DSDL2MIXER_CMD=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
+ for _, libfile in ipairs(fetchinfo.libfiles) do
+ if libfile:match("SDL2%..+$") or libfile:match("SDL2-static%..+$") then
+ table.insert(configs, "-DSDL2_LIBRARY=" .. table.concat(fetchinfo.libfiles, ";"))
+ end
+ end
end
- import("package.tools.autoconf").install(package, configs)
end
+ import("package.tools.cmake").install(package, configs)
end)
on_test(function (package)
diff --git a/packages/l/libsdl_net/xmake.lua b/packages/l/libsdl_net/xmake.lua
index 8e8712e4d..e4932f41f 100644
--- a/packages/l/libsdl_net/xmake.lua
+++ b/packages/l/libsdl_net/xmake.lua
@@ -1,19 +1,11 @@
package("libsdl_net")
-
set_homepage("https://www.libsdl.org/projects/SDL_net/")
set_description("Simple DirectMedia Layer networking library")
+ set_license("zlib")
- if is_plat("windows", "mingw") then
- set_urls("https://www.libsdl.org/projects/SDL_net/release/SDL2_net-devel-$(version)-VC.zip")
- add_urls("https://github.com/libsdl-org/SDL_net/releases/download/release-$(version)/SDL2_net-devel-$(version)-VC.zip")
- add_versions("2.0.1", "c1e423f2068adc6ff1070fa3d6a7886700200538b78fd5adc36903a5311a243e")
- add_versions("2.2.0", "f364e55babb44e47b41d039a43c640aa1f76615b726855591b555321c7d870dd")
- else
- set_urls("https://www.libsdl.org/projects/SDL_net/release/SDL2_net-$(version).zip")
- add_urls("https://github.com/libsdl-org/SDL_net/releases/download/release-$(version)/SDL2_net-$(version).zip")
- add_versions("2.0.1", "52031ed9d08a5eb1eda40e9a0409248bf532dde5e8babff5780ef1925657d59f")
- add_versions("2.2.0", "1eec3a9d43df019d7916a6ecce32f2a3ad5248c82c9c237948afc712399be36d")
- end
+ 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")
@@ -23,49 +15,53 @@ package("libsdl_net")
add_extsources("brew::sdl2_net")
end
- add_deps("libsdl")
+ add_deps("cmake")
- add_links("SDL2_net")
+ 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)
- if package:version():ge("2.2") and package:is_plat("macosx", "linux") then
- package:add("deps", "cmake")
- end
- end)
-
- on_install("windows", "mingw", function (package)
- local arch = package:arch()
- if package:is_plat("mingw") then
- arch = (arch == "x86_64") and "x64" or "x86"
+ if package:config("shared") then
+ package:add("deps", "libsdl", { configs = { shared = true }})
+ else
+ package:add("deps", "libsdl")
end
- os.cp("include/*", package:installdir("include/SDL2"))
- os.cp(path.join("lib", arch, "*.lib"), package:installdir("lib"))
- os.cp(path.join("lib", arch, "*.dll"), package:installdir("bin"))
end)
- on_install("macosx", "linux", function (package)
- if package:version():ge("2.2") then
- 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"))
- if libsdl and not libsdl:is_system() then
- table.insert(configs, "-DSDL2_DIR=" .. libsdl:installdir())
- end
- import("package.tools.cmake").install(package, configs)
- else
- local configs = {}
- table.insert(configs, "--enable-shared=" .. (package:config("shared") and "yes" or "no"))
- table.insert(configs, "--enable-static=" .. (package:config("shared") and "no" or "yes"))
- local libsdl = package:dep("libsdl")
- if libsdl and not libsdl:is_system() then
- table.insert(configs, "--with-sdl-prefix=" .. libsdl:installdir())
+ on_install(function (package)
+ 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
+ for _, libfile in ipairs(fetchinfo.libfiles) do
+ if libfile:match("SDL2%..+$") or libfile:match("SDL2-static%..+$") then
+ table.insert(configs, "-DSDL2_LIBRARY=" .. table.concat(fetchinfo.libfiles, ";"))
+ end
+ end
end
- import("package.tools.autoconf").install(package, configs)
end
+ io.replace("CMakeLists.txt", "find_package(SDL2test)", "", {plain = true})
+ import("package.tools.cmake").install(package, configs)
end)
on_test(function (package)
- assert(package:has_cfuncs("SDLNet_Init", {includes = "SDL2/SDL_net.h", configs = {defines = "SDL_MAIN_HANDLED"}}))
+ assert(package:has_cfuncs("SDLNet_Init",
+ {includes = "SDL2/SDL_net.h", configs = {cxflags = "-sUSE_SDL=0", defines = "SDL_MAIN_HANDLED"}}))
end)
diff --git a/packages/l/libsdl_ttf/patches/2.20.1/cmakelists.patch b/packages/l/libsdl_ttf/patches/2.20.1/cmakelists.patch
new file mode 100644
index 000000000..4251fd688
--- /dev/null
+++ b/packages/l/libsdl_ttf/patches/2.20.1/cmakelists.patch
@@ -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-$.pc\"
+- \"${CMAKE_CURRENT_BINARY_DIR}/SDL2_ttf.pc\" ONLY_IF_DIFFERENT)
++ file(COPY \"${CMAKE_CURRENT_BINARY_DIR}/SDL2_ttf-$.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)
diff --git a/packages/l/libsdl_ttf/xmake.lua b/packages/l/libsdl_ttf/xmake.lua
index 32543d0fa..3dcae0cc0 100644
--- a/packages/l/libsdl_ttf/xmake.lua
+++ b/packages/l/libsdl_ttf/xmake.lua
@@ -1,6 +1,5 @@
package("libsdl_ttf")
-
- set_homepage("https://www.libsdl.org/projects/SDL_ttf/")
+ set_homepage("https://github.com/libsdl-org/SDL_ttf/")
set_description("Simple DirectMedia Layer text rendering library")
set_license("zlib")
@@ -12,69 +11,87 @@ package("libsdl_ttf")
add_extsources("brew::sdl2_ttf")
end
- if is_plat("windows", "mingw") then
- set_urls("https://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-devel-$(version)-VC.zip")
- add_urls("https://github.com/libsdl-org/SDL_ttf/releases/download/release-$(version)/SDL2_ttf-devel-$(version)-VC.zip")
- add_versions("2.0.15", "aab0d81f1aa6fe654be412efc85829f2b188165dca6c90eb4b12b673f93e054b")
- add_versions("2.0.18", "4e1404ac6095bbcd4cb133eb644a765885aa283ae45f36cfbc3cf5a77d7e1cbd")
- add_versions("2.20.0", "bc206392a74d2b32f74d770a3a1e623e87c72374781c115478277ab4c722358b")
- add_versions("2.20.1", "2facfa180f77bac381776376c7598ad504a84d99414418049bb106cb1705fe22")
- else
- set_urls("https://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-$(version).zip")
- add_urls("https://github.com/libsdl-org/SDL_ttf/releases/download/release-$(version)/SDL2_ttf-$(version).zip")
- add_versions("2.0.15", "cdb72b5b1c3b27795fa128af36f369fee5d3e38a96c350855da0b81880555dbc")
- add_versions("2.0.18", "64e6a93c7542aba1e32e1418413898dfde82be95fdd0c73ba265fbdada189b5f")
- add_versions("2.20.0", "04e94fc5ecac3475ab35c1d5cf52650df691867e7e4befcc861bf982a747111a")
- add_versions("2.20.1", "18d81ab399c8e39adababe8918691830ba6e0d6448e5baa141ee0ddf87ede2dc")
- end
+ add_urls("https://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-$(version).tar.gz",
+ "https://github.com/libsdl-org/SDL_ttf/releases/download/release-$(version)/SDL2_ttf-$(version).tar.gz")
+ add_versions("2.20.0", "874680232b72839555a558b48d71666b562e280f379e673b6f0c7445ea3b9b8a")
+ add_versions("2.20.1", "78cdad51f3cc3ada6932b1bb6e914b33798ab970a1e817763f22ddbfd97d0c57")
+ add_versions("2.20.2", "9dc71ed93487521b107a2c4a9ca6bf43fb62f6bddd5c26b055e6b91418a22053")
- add_deps("libsdl")
- if is_plat("linux", "macosx") then
- add_deps("freetype")
- end
+ add_patches(">=2.20.0 <=2.20.1", path.join(os.scriptdir(), "patches", "2.20.1", "cmakelists.patch"), "fe04ada62d9ed70029c0efb3c04bfec22fc7596bd6b73a567beb964e61ebd82c")
+
+ add_deps("cmake", "freetype")
- add_links("SDL2_ttf")
add_includedirs("include", "include/SDL2")
- on_load("macosx", "linux", function (package)
- if package:version():ge("2.20") then
- package:add("deps", "cmake")
- else
- package:add("deps", "automake", "autoconf")
- end
- end)
+ if is_plat("wasm") then
+ add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
+ end
- on_install("windows", "mingw", function (package)
- local arch = package:arch()
- if package:is_plat("mingw") then
- arch = (arch == "x86_64") and "x64" or "x86"
+ on_load(function (package)
+ if package:config("shared") then
+ package:add("deps", "libsdl", { configs = { shared = true }})
+ else
+ package:add("deps", "libsdl")
end
- os.cp("include/*", package:installdir("include/SDL2"))
- os.cp(path.join("lib", arch, "*.lib"), package:installdir("lib"))
- os.cp(path.join("lib", arch, "*.dll"), package:installdir("bin"))
end)
- on_install("macosx", "linux", function (package)
- if package:version():ge("2.20") then
- 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"))
- if libsdl and not libsdl:is_system() then
- table.insert(configs, "-DSDL2_DIR=" .. libsdl:installdir())
+ on_install(function (package)
+ 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"))
+ 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
+ for _, libfile in ipairs(fetchinfo.libfiles) do
+ if libfile:match("SDL2%..+$") or libfile:match("SDL2-static%..+$") then
+ table.insert(configs, "-DSDL2_LIBRARY=" .. libfile)
+ end
+ end
end
- import("package.tools.cmake").install(package, configs)
- else
- local configs = {}
- table.insert(configs, "--enable-shared=" .. (package:config("shared") and "yes" or "no"))
- table.insert(configs, "--enable-static=" .. (package:config("shared") and "no" or "yes"))
- local libsdl = package:dep("libsdl")
- if libsdl and not libsdl:is_system() then
- table.insert(configs, "--with-sdl-prefix=" .. libsdl:installdir())
+ 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
- import("package.tools.autoconf").install(package, configs)
end
+ import("package.tools.cmake").install(package, configs)
end)
on_test(function (package)
- assert(package:has_cfuncs("TTF_Init", {includes = "SDL2/SDL_ttf.h", configs = {defines = "SDL_MAIN_HANDLED"}}))
+ assert(package:has_cfuncs("TTF_Init",
+ {includes = "SDL2/SDL_ttf.h", configs = {defines = "SDL_MAIN_HANDLED"}}))
end)