Enable wasm for bzip2/libpng and rework libsdl (#1671)

* bzip2, libpng: add wasm support

* libsdl: use cmake and components

* Re-add libsdl versions

* Fix libsdl

* Update xmake.lua

* CI: enable verbose

* Update fedora.yml

* Fix bzip2 tests

* Update xmake.lua

* debug

* Update xmake.lua

* Update xmake.lua

* debug

* Update xmake.lua

* Update emsdk

* Fix libsdl with wasm

* Update xmake.lua

* Update xmake.lua

* Update xmake.lua

* Update xmake.lua

* Update xmake.lua

* Try to debug cross

* Update cross_musl.yml

* Update xmake.lua

* Remove debug line

* Remove added verbose flag
pull/1696/head
Jérôme Leclercq 2 years ago committed by GitHub
parent d3f1e6a543
commit 0fd68bc72a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      .github/workflows/wasm_ubuntu.yml
  2. 3
      packages/b/bzip2/port/xmake.lua
  3. 8
      packages/b/bzip2/xmake.lua
  4. 2
      packages/l/libpng/xmake.lua
  5. 130
      packages/l/libsdl/xmake.lua

@ -28,7 +28,7 @@ jobs:
uses: mymindstorm/setup-emsdk@v11
with:
# Make sure to set a version number!
version: 1.38.40
version: 3.1.28
# This is the name of the cache folder.
# The cache folder will be placed in the build directory,
# so make sure it doesn't conflict with anything!

@ -19,6 +19,9 @@ target("bz2")
set_filename("libbz2.dll")
add_files("libbz2.def")
end
if is_plat("wasm") then
add_defines("BZ_STRICT_ANSI")
end
if has_config("enable_tools") then

@ -14,10 +14,10 @@ package("bzip2")
add_extsources("brew::bzip2")
end
on_install("linux", "macosx", "windows", "android", "iphoneos", "cross", "bsd", "mingw", function (package)
on_install(function (package)
local configs = {}
if not package:is_plat("cross", "iphoneos", "android") then
configs.enable_tools = true
configs.enable_tools = true
if not package:is_plat("iphoneos", "android") then
package:addenv("PATH", "bin")
end
@ -26,7 +26,7 @@ package("bzip2")
end)
on_test(function (package)
if not package:is_plat("cross", "iphoneos", "android") then
if not package:is_cross() then
os.vrun("bunzip2 --help")
os.vrun("bzcat --help")
os.vrun("bzip2 --help")

@ -25,7 +25,7 @@ package("libpng")
add_extsources("brew::libpng")
end
on_install("windows", "mingw", "android", "iphoneos", "cross", "bsd", function (package)
on_install("windows", "mingw", "android", "iphoneos", "cross", "bsd", "wasm", function (package)
io.writefile("xmake.lua", [[
add_rules("mode.debug", "mode.release")
add_requires("zlib")

@ -1,5 +1,4 @@
package("libsdl")
set_homepage("https://www.libsdl.org/")
set_description("Simple DirectMedia Layer")
@ -13,33 +12,33 @@ package("libsdl")
set_license("zlib")
if is_plat("windows", "mingw") then
set_urls("https://www.libsdl.org/release/SDL2-devel-$(version)-VC.zip",
"https://github.com/libsdl-org/SDL/releases/download/release-$(version)/SDL2-devel-$(version)-VC.zip")
add_versions("2.0.8", "68505e1f7c16d8538e116405411205355a029dcf2df738dbbc768b2fe95d20fd")
add_versions("2.0.12", "00c55a597cebdb9a4eb2723f2ad2387a4d7fd605e222c69b46099b15d5d8b32d")
add_versions("2.0.14", "232071cf7d40546cde9daeddd0ec30e8a13254c3431be1f60e1cdab35a968824")
add_versions("2.0.16", "f83651227229e059a570aac26be24f5070352c0d23aaf3d2cfbd3eb2c9599334")
add_versions("2.0.18", "d4a56e2ee7c0eae2ef0d511201d3bd38c5ab255662e4b571d4d630762473bf42")
add_versions("2.0.20", "5b1512ca6c9d2427bd2147da01e5e954241f8231df12f54a7074dccde416df18")
add_versions("2.0.22", "32adc96d8b25e5671189f1f38a4fc7deb105fbb1b3ed78ffcb23f5b8f36b3922")
add_versions("2.24.0", "97c6e2d17c0baebf4c84ede27ec42e211358f3694b9f558ead3a9c542c4a004e")
add_versions("2.24.2", "fae7f8f1661fc1fb3ece7b58eca3b2aaeb2ed000a0b7766f859ae12511efd11f")
add_versions("2.26.0", "3dd66b8ebd32fc2110fbffccc82ffb6b9838de382aff641a38a66a64d480f5f9")
else
set_urls("https://www.libsdl.org/release/SDL2-$(version).zip",
"https://github.com/libsdl-org/SDL/releases/download/release-$(version)/SDL2-$(version).zip")
add_versions("2.0.8", "e6a7c71154c3001e318ba7ed4b98582de72ff970aca05abc9f45f7cbdc9088cb")
add_versions("2.0.12", "476e84d6fcbc499cd1f4a2d3fd05a924abc165b5d0e0d53522c9604fe5a021aa")
add_versions("2.0.14", "2c1e870d74e13dfdae870600bfcb6862a5eab4ea5b915144aff8d75a0f9bf046")
add_versions("2.0.16", "010148866e2226e5469f2879425d28ff7c572c736cb3fb65a0604c3cde6bfab9")
add_versions("2.0.18", "2d96cc82020341f7f5957c42001ad526e15fbb7056be8a74dab302483e97aa24")
add_versions("2.0.20", "cc8b16a326eb082c1f48ca30fdf471acfd2334b69bd7527e65ac58369013a1ba")
add_versions("2.0.22", "9a81ab724e6dcef96c61a4a2ebe7758e5b8bb191794650d276a20d5148fbd50c")
add_versions("2.24.0", "4b065503d45652d5f65d807fe98c757c73af2968727945b596861995bc3b69c2")
add_versions("2.24.2", "7fae98ac4e7b39eb2511fc27c2e84b220ac69b5296ff41f833b967c891f9d2ac")
add_versions("2.26.0", "4a181f158f88676816e4993d7e97e7b48ef273aa6f4e2909c6a85497e9af3e9f")
end
add_urls("https://www.libsdl.org/release/SDL2-$(version).zip",
"https://github.com/libsdl-org/SDL/releases/download/release-$(version)/SDL2-$(version).zip", { alias = "archive" })
add_urls("https://github.com/libsdl-org/SDL.git", { alias = "github" })
add_versions("archive:2.0.8", "e6a7c71154c3001e318ba7ed4b98582de72ff970aca05abc9f45f7cbdc9088cb")
add_versions("archive:2.0.12", "476e84d6fcbc499cd1f4a2d3fd05a924abc165b5d0e0d53522c9604fe5a021aa")
add_versions("archive:2.0.14", "2c1e870d74e13dfdae870600bfcb6862a5eab4ea5b915144aff8d75a0f9bf046")
add_versions("archive:2.0.16", "010148866e2226e5469f2879425d28ff7c572c736cb3fb65a0604c3cde6bfab9")
add_versions("archive:2.0.18", "2d96cc82020341f7f5957c42001ad526e15fbb7056be8a74dab302483e97aa24")
add_versions("archive:2.0.20", "cc8b16a326eb082c1f48ca30fdf471acfd2334b69bd7527e65ac58369013a1ba")
add_versions("archive:2.0.22", "9a81ab724e6dcef96c61a4a2ebe7758e5b8bb191794650d276a20d5148fbd50c")
add_versions("archive:2.24.0", "4b065503d45652d5f65d807fe98c757c73af2968727945b596861995bc3b69c2")
add_versions("archive:2.24.2", "7fae98ac4e7b39eb2511fc27c2e84b220ac69b5296ff41f833b967c891f9d2ac")
add_versions("archive:2.26.0", "4a181f158f88676816e4993d7e97e7b48ef273aa6f4e2909c6a85497e9af3e9f")
add_versions("archive:2.26.1", "c038222fcac6ccc448daaa3febcae93fdac401aed12fd60da3b7939529276b1b")
add_versions("github:2.0.8", "release-2.0.8")
add_versions("github:2.0.12", "release-2.0.12")
add_versions("github:2.0.14", "release-2.0.14")
add_versions("github:2.0.16", "release-2.0.16")
add_versions("github:2.0.18", "release-2.0.18")
add_versions("github:2.0.20", "release-2.0.20")
add_versions("github:2.0.22", "release-2.0.22")
add_versions("github:2.24.0", "release-2.24.0")
add_versions("github:2.24.2", "release-2.24.2")
add_versions("github:2.26.0", "release-2.26.0")
add_versions("github:2.26.1", "release-2.26.1")
add_deps("cmake")
if is_plat("macosx") then
add_frameworks("OpenGL", "CoreVideo", "CoreAudio", "AudioToolbox", "Carbon", "CoreGraphics", "ForceFeedback", "Metal", "AppKit", "IOKit", "CoreFoundation", "Foundation")
@ -56,19 +55,23 @@ package("libsdl")
add_includedirs("include", "include/SDL2")
add_configs("use_sdlmain", {description = "Use SDL_main entry point", default = true, type = "boolean"})
if is_plat("windows", "mingw") then
add_configs("shared", {description = "Build shared library.", default = true, type = "boolean", readonly = true})
add_configs("vs_runtime", {description = "Set vs compiler runtime.", default = "MD", readonly = true})
elseif is_plat("linux") then
if is_plat("linux") then
add_configs("with_x", {description = "Enables X support (requires it on the system)", default = true, type = "boolean"})
end
on_load(function (package)
if package:config("use_sdlmain") then
package:add("links", "SDL2main", "SDL2")
package:add("defines", "SDL_MAIN_HANDLED")
if package.components then
if package:config("use_sdlmain") then
package:add("components", "main")
end
package:add("components", "lib")
else
package:add("links", "SDL2")
if package:config("use_sdlmain") then
package:add("links", "SDL2main", "SDL2")
package:add("defines", "SDL_MAIN_HANDLED")
else
package:add("links", "SDL2")
end
end
if package:is_plat("linux") and package:config("with_x") then
package:add("deps", "libxext", {private = true})
@ -78,6 +81,17 @@ package("libsdl")
end
end)
on_component = on_component or function() end
on_component("main", function (package, component)
component:add("links", "SDL2main")
component:add("defines", "SDL_MAIN_HANDLED")
component:add("deps", "lib")
end)
on_component("main", function (package, component)
component:add("links", "SDL2")
end)
on_fetch("linux", "macosx", "bsd", function (package, opt)
if opt.system then
-- use sdl2-config
@ -126,44 +140,44 @@ package("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", "bsd", function (package)
on_install(function (package)
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"))
if package:config("pic") ~= false then
table.insert(configs, "--with-pic")
end
table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
table.insert(configs, "-DLIBTYPE=" .. (package:config("shared") and "SHARED" or "STATIC"))
local opt
if package:is_plat("linux") then
local cflags = {}
opt = opt or {}
opt.cflags = cflags
if package:is_plat("linux", "cross") then
local includedirs = {}
for _, depname in ipairs({"libxext", "libx11", "xorgproto"}) do
local dep = package:dep(depname)
if dep then
local depfetch = dep:fetch()
if depfetch then
for _, includedir in ipairs(depfetch.includedirs or depfetch.sysincludedirs) do
table.join2(cflags, "-I" .. includedir)
table.insert(includedirs, includedir)
end
end
end
end
if #includedirs > 0 then
includedirs = table.unique(includedirs)
local cflags = {}
opt = opt or {}
opt.cflags = cflags
for _, includedir in ipairs(includedirs) do
table.insert(cflags, "-I" .. includedir)
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 {}
opt.cflags = {"-sUSE_SDL=0"}
end
import("package.tools.autoconf").install(package, configs, opt)
import("package.tools.cmake").install(package, configs, opt)
end)
on_test(function (package)

Loading…
Cancel
Save