centurion: remove limits & add patch | libsdl_*: use configs from install (#5097)

* centurion: remove limits

* libsdl_*: update if statements

* libsdl_*: improve pattern for older libsdl_* versions

* libsdl_image: fix pattern

* libsdl_ttf: remove `plain = true`

* libsdl_*: make patches only wasm and improve replace by using two instead of pattern

* libsdl_*: use `package:is_plat`
pull/5114/head
Chi Huu Huynh 3 months ago committed by GitHub
parent 622ed4facd
commit 426b3877db
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 13
      packages/c/centurion/patches/7.3.0/fix_method_name.patch
  2. 30
      packages/c/centurion/xmake.lua
  3. 24
      packages/l/libsdl_image/xmake.lua
  4. 24
      packages/l/libsdl_mixer/xmake.lua
  5. 24
      packages/l/libsdl_net/xmake.lua
  6. 24
      packages/l/libsdl_ttf/xmake.lua

@ -0,0 +1,13 @@
diff --git a/src/centurion/video/renderer.hpp b/src/centurion/video/renderer.hpp
index 5b253902..e097be79 100644
--- a/src/centurion/video/renderer.hpp
+++ b/src/centurion/video/renderer.hpp
@@ -182,7 +182,7 @@ class basic_renderer final {
[[nodiscard]] auto make_texture(file& file) const -> texture
{
- if (auto* ptr = IMG_LoadTextureRW(get(), file.data(), SDL_FALSE)) {
+ if (auto* ptr = IMG_LoadTexture_RW(get(), file.data(), SDL_FALSE)) {
return texture {ptr};
}
else {

@ -9,6 +9,8 @@ package("centurion")
add_versions("v7.3.0", "ad8b7c27074939fa46380a878e82c2b0365d1c4ad31b4a71bfcd5ce3ac0198e6")
add_patches("v7.3.0", path.join(os.scriptdir(), "patches", "7.3.0", "fix_method_name.patch"), "2c5faf24867440e53bdabf79b4354cdbf2c79707ca9e372ba7cdd94bcb1dcc52")
add_configs("pragma_once", { description = "Use #pragma once in centurion.hpp", default = true, type = "boolean" })
add_configs("debug_macros", { description = "Include debug-only logging macros, such as CENTURION_LOG_INFO", default = true, type = "boolean" })
@ -26,12 +28,8 @@ package("centurion")
add_includedirs("include", "include/SDL2")
on_load(function (package)
if package:config("shared") then
package:add("deps", "libsdl", { configs = { shared = true } })
else
package:add("deps", "libsdl")
end
package:add("deps", "libsdl", { configs = { shared = package:config("shared") } })
if not package:config("pragma_once") then
package:add("defines", "CENTURION_NO_PRAGMA_ONCE")
end
@ -40,29 +38,17 @@ package("centurion")
end
if package:config("sdl_image") then
if package:config("shared") then
package:add("deps", "libsdl_image", { configs = { shared = true } })
else
package:add("deps", "libsdl_image")
end
package:add("deps", "libsdl_image", { configs = { shared = package:config("shared") } })
else
package:add("defines", "CENTURION_NO_SDL_IMAGE")
end
if package:config("sdl_mixer") then
if package:config("shared") then
package:add("deps", "libsdl_mixer", { configs = { shared = true } })
else
package:add("deps", "libsdl_mixer")
end
package:add("deps", "libsdl_mixer", { configs = { shared = package:config("shared") } })
else
package:add("defines", "CENTURION_NO_SDL_MIXER")
end
if package:config("sdl_ttf") then
if package:config("shared") then
package:add("deps", "libsdl_ttf", { configs = { shared = true } })
else
package:add("deps", "libsdl_ttf")
end
package:add("deps", "libsdl_ttf", { configs = { shared = package:config("shared") } })
else
package:add("defines", "CENTURION_NO_SDL_TTF")
end
@ -75,7 +61,7 @@ package("centurion")
end
end)
on_install("!wasm", function (package)
on_install(function (package)
os.cp("src/*", package:installdir("include"))
end)

@ -32,14 +32,22 @@ package("libsdl_image")
add_includedirs("include", "include/SDL2")
on_load(function (package)
if package:config("shared") then
package:add("deps", "libsdl", { configs = { shared = true }})
else
package:add("deps", "libsdl")
end
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"))
@ -54,11 +62,15 @@ package("libsdl_image")
break
end
end
local libfiles = {}
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, ";"))
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)

@ -28,14 +28,22 @@ package("libsdl_mixer")
end
on_load(function (package)
if package:config("shared") then
package:add("deps", "libsdl", { configs = { shared = true }})
else
package:add("deps", "libsdl")
end
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",
@ -61,11 +69,15 @@ package("libsdl_mixer")
break
end
end
local libfiles = {}
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, ";"))
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)

@ -28,14 +28,22 @@ package("libsdl_net")
add_includedirs("include", "include/SDL2")
on_load(function (package)
if package:config("shared") then
package:add("deps", "libsdl", { configs = { shared = true }})
else
package:add("deps", "libsdl")
end
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"))
@ -50,11 +58,15 @@ package("libsdl_net")
break
end
end
local libfiles = {}
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, ";"))
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})

@ -30,14 +30,22 @@ package("libsdl_ttf")
end
on_load(function (package)
if package:config("shared") then
package:add("deps", "libsdl", { configs = { shared = true }})
else
package:add("deps", "libsdl")
end
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"))
@ -53,11 +61,15 @@ package("libsdl_ttf")
break
end
end
local libfiles = {}
for _, libfile in ipairs(fetchinfo.libfiles) do
if libfile:match("SDL2%..+$") or libfile:match("SDL2-static%..+$") then
table.insert(configs, "-DSDL2_LIBRARY=" .. libfile)
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")

Loading…
Cancel
Save