SFML 2.6.0, support for ARM macOS M1 and M2 (#2206)

* SFML 2.6.0

* restore 2.5.1

* Windows ARM and Linux X11

* WIP

* WIP

* Build SFML on every platform

* Update xmake.lua

* Update xmake.lua

* Update xmake.lua

* sfml: Use system deps

* Update xmake.lua

* Update xmake.lua

* Update xmake.lua

* Update xmake.lua

* Update xmake.lua

* Update xmake.lua

* Update xmake.lua

* Update xmake.lua

* Update xmake.lua

* Update xmake.lua

* Update xmake.lua

* Update xmake.lua

* Update xmake.lua

* Update xmake.lua

* Update xmake.lua

* Update xmake.lua

---------

Co-authored-by: Jérôme Leclercq <lynix680@gmail.com>
Co-authored-by: ruki <waruqi@gmail.com>
pull/2587/head
0x2Adr1 1 year ago committed by GitHub
parent 9450b7fe70
commit cc65ca92ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 204
      packages/s/sfml/xmake.lua

@ -1,33 +1,17 @@
package("sfml") package("sfml")
set_homepage("https://www.sfml-dev.org") set_homepage("https://www.sfml-dev.org")
set_description("Simple and Fast Multimedia Library") set_description("Simple and Fast Multimedia Library")
set_license("zlib")
if is_plat("windows", "linux") then add_urls("https://github.com/SFML/SFML/archive/refs/tags/$(version).tar.gz",
set_urls("https://www.sfml-dev.org/files/SFML-$(version)-sources.zip") "https://github.com/SFML/SFML.git")
add_urls("https://github.com/SFML/SFML/releases/download/$(version)/SFML-$(version)-sources.zip")
add_versions("2.5.1", "bf1e0643acb92369b24572b703473af60bac82caf5af61e77c063b779471bb7f")
elseif is_plat("macosx") then
if is_arch("x64", "x86_64") then
set_urls("https://www.sfml-dev.org/files/SFML-$(version)-macOS-clang.tar.gz")
add_versions("2.5.1", "6af0f14fbd41dc038a00d7709f26fb66bb7ccdfe6187657ef0ef8cba578dcf14")
add_configs("debug", {builtin = true, description = "Enable debug symbols.", default = false, type = "boolean", readonly = true}) -- Before 2.6.0 only x86 is supported for Mac
add_configs("shared", {description = "Build shared library.", default = true, type = "boolean", readonly = true}) if not is_plat("macosx") or not is_arch("arm.*") then
end add_versions("2.5.1", "438c91a917cc8aa19e82c6f59f8714da353c488584a007d401efac8368e1c785")
elseif is_plat("mingw") then
if is_arch("x64", "x86_64") then
set_urls("https://www.sfml-dev.org/files/SFML-$(version)-windows-gcc-7.3.0-mingw-64-bit.zip")
add_versions("2.5.1", "671e786f1af934c488cb22c634251c8c8bd441c709b4ef7bc6bbe227b2a28560")
elseif is_arch("x86", "i386") then
set_urls("https://www.sfml-dev.org/files/SFML-$(version)-windows-gcc-7.3.0-mingw-32-bit.zip")
add_versions("2.5.1", "92d864c9c9094dc9d91e0006d66784f25ac900a8ee23c3f79db626de46a1d9d8")
end
end end
if is_plat("linux") then add_versions("2.6.0", "0c3f84898ea1db07dc46fa92e85038d8c449e3c8653fe09997383173de96bc06")
add_syslinks("pthread")
end
add_configs("graphics", {description = "Use the graphics module", default = true, type = "boolean"}) add_configs("graphics", {description = "Use the graphics module", default = true, type = "boolean"})
add_configs("window", {description = "Use the window module", default = true, type = "boolean"}) add_configs("window", {description = "Use the window module", default = true, type = "boolean"})
@ -41,17 +25,12 @@ package("sfml")
add_extsources("brew::sfml/sfml-all") add_extsources("brew::sfml/sfml-all")
end end
on_component = on_component or function() end
on_component("graphics", function (package, component) on_component("graphics", function (package, component)
local e = package:config("shared") and "" or "-s" local e = package:config("shared") and "" or "-s"
if package:debug() then if package:debug() then
e = e .. "-d" e = e .. "-d"
end end
component:add("links", "sfml-graphics" .. e) component:add("links", "sfml-graphics" .. e)
if package:is_plat("windows", "mingw") and not package:config("shared") then
component:add("links", "freetype")
component:add("syslinks", "opengl32", "gdi32", "user32", "advapi32")
end
component:add("deps", "window", "system") component:add("deps", "window", "system")
component:add("extsources", "brew::sfml/sfml-graphics") component:add("extsources", "brew::sfml/sfml-graphics")
end) end)
@ -62,11 +41,21 @@ package("sfml")
e = e .. "-d" e = e .. "-d"
end end
component:add("links", "sfml-window" .. e) component:add("links", "sfml-window" .. e)
if package:is_plat("windows", "mingw") and not package:config("shared") then
component:add("syslinks", "opengl32", "gdi32", "user32", "advapi32")
end
component:add("deps", "system") component:add("deps", "system")
component:add("extsources", "brew::sfml/sfml-window") component:add("extsources", "brew::sfml/sfml-window")
if not package:config("shared") then
if package:is_plat("windows", "mingw") then
component:add("syslinks", "opengl32", "gdi32", "advapi32")
elseif package:is_plat("linux") then
component:add("syslinks", "dl")
elseif package:is_plat("bsd") then
component:add("syslinks", "usbhid")
elseif package:is_plat("macosx") then
component:add("frameworks", "Foundation", "AppKit", "IOKit", "Carbon")
elseif package:is_plat("iphoneos") then
component:add("frameworks", "Foundation", "UIKit", "CoreGraphics", "QuartzCore", "CoreMotion")
end
end
end) end)
on_component("audio", function (package, component) on_component("audio", function (package, component)
@ -75,11 +64,11 @@ package("sfml")
e = e .. "-d" e = e .. "-d"
end end
component:add("links", "sfml-audio" .. e) component:add("links", "sfml-audio" .. e)
if package:is_plat("windows", "mingw") and not package:config("shared") then
component:add("links", "openal32", "flac", "vorbisenc", "vorbisfile", "vorbis", "ogg")
end
component:add("deps", "system") component:add("deps", "system")
component:add("extsources", "brew::sfml/sfml-audio") component:add("extsources", "brew::sfml/sfml-audio")
if not package:config("shared") and package:is_plat("windows", "mingw") then
component:add("links", "openal32", "flac", "vorbisenc", "vorbisfile", "vorbis", "ogg")
end
end) end)
on_component("network", function (package, component) on_component("network", function (package, component)
@ -88,12 +77,12 @@ package("sfml")
e = e .. "-d" e = e .. "-d"
end end
component:add("links", "sfml-network" .. e) component:add("links", "sfml-network" .. e)
if package:is_plat("windows", "mingw") and not package:config("shared") then
component:add("syslinks", "ws2_32")
end
component:add("deps", "system") component:add("deps", "system")
component:add("extsources", "brew::sfml/sfml-network") component:add("extsources", "brew::sfml/sfml-network")
component:add("extsources", "apt::sfml-network") component:add("extsources", "apt::sfml-network")
if not package:config("shared") and package:is_plat("windows", "mingw") then
component:add("syslinks", "ws2_32")
end
end) end)
on_component("system", function (package, component) on_component("system", function (package, component)
@ -109,6 +98,15 @@ package("sfml")
component:add("deps", "main") component:add("deps", "main")
end end
component:add("extsources", "brew::sfml/sfml-system") component:add("extsources", "brew::sfml/sfml-system")
if not package:config("shared") then
if package:is_plat("windows", "mingw") then
component:add("syslinks", "winmm")
elseif package:is_plat("linux") then
component:add("syslinks", "rt", "pthread")
elseif package:is_plat("bsd", "macosx") then
component:add("syslinks", "pthread")
end
end
end) end)
on_component("main", function (package, component) on_component("main", function (package, component)
@ -122,7 +120,7 @@ package("sfml")
end) end)
on_load("windows", "linux", "macosx", "mingw", function (package) on_load("windows", "linux", "macosx", "mingw", function (package)
if package:is_plat("windows", "linux") then if package:is_plat("windows", "linux", "macosx") then
package:add("deps", "cmake") package:add("deps", "cmake")
end end
@ -130,107 +128,119 @@ package("sfml")
package:add("defines", "SFML_STATIC") package:add("defines", "SFML_STATIC")
end end
-- enable components when xmake >=2.7.3 if package:config("graphics") then
if package.components then package:add("deps", "freetype")
end
if package:is_plat("linux") then if package:is_plat("linux") then
if package:config("window") or package:config("graphics") then if package:config("window") or package:config("graphics") then
package:add("deps", "libx11", "libxext", "libxrandr", "libxrender", "freetype", "eudev") package:add("deps", "libx11", "libxcursor", "libxrandr", "libxrender", "libxfixes", "libxext", "eudev")
package:add("deps", "opengl", "glx", {optional = true}) package:add("deps", "opengl", "glx", {optional = true})
end end
end end
if package:config("audio") then if package:config("audio") then
package:add("deps", "libogg", "libflac", "libvorbis", "openal-soft") package:add("deps", "libogg", "libflac", "libvorbis", "openal-soft")
end end
package:add("components", "system") package:add("components", "system")
for _, component in ipairs({"graphics", "window", "audio", "network"}) do for _, component in ipairs({"graphics", "window", "audio", "network"}) do
if package:config(component) then if package:config(component) then
package:add("components", component) package:add("components", component)
end end
end end
if package:is_plat("windows", "mingw") and package:config("main") then if package:is_plat("windows", "mingw") and package:config("main") then
package:add("components", "main") package:add("components", "main")
end end
else end)
local e = package:config("shared") and "" or "-s"
if package:debug() then on_install("windows", "linux", "macosx", "mingw", function (package)
e = e .. "-d" local configs = {"-DSFML_BUILD_DOC=OFF", "-DSFML_BUILD_EXAMPLES=OFF"}
table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
if package:config("shared") then
table.insert(configs, "-DBUILD_SHARED_LIBS=ON")
-- Fix missing system libs
if package:config("audio") then
if package:is_plat("windows", "mingw") then
local file = io.open("src/SFML/Audio/CMakeLists.txt", "a")
file:print("target_link_libraries(OpenAL INTERFACE winmm)")
file:close()
end end
local a = "sfml-"
local main_module = a .. "main"
if package:debug() then
main_module = main_module .. "-d"
end end
if package:config("graphics") then if package:config("graphics") then
package:add("links", a .. "graphics" .. e) local freetype = package:dep("freetype")
if package:is_plat("windows", "mingw") and not package:config("shared") then if freetype then
package:add("links", "freetype") local fetchinfo = freetype:fetch()
if fetchinfo then
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
end end
if package:config("window") or package:config("graphics") then if #libfiles > 0 then
package:add("links", a .. "window" .. e) local libraries = {}
if package:is_plat("windows", "mingw") and not package:config("shared") then for _, libfile in ipairs(libfiles) do
package:add("syslinks", "opengl32", "gdi32", "user32", "advapi32") table.insert(libraries, (libfile:gsub("\\", "/")))
end end
if package:is_plat("linux") then local file = io.open("src/SFML/Graphics/CMakeLists.txt", "a")
package:add("deps", "libx11", "libxext", "libxrandr", "libxrender", "freetype", "eudev") file:print("target_link_libraries(Freetype INTERFACE " .. table.concat(libraries, " ") .. ")")
package:add("deps", "opengl", "glx", {optional = true}) file:close()
end end
end end
if package:config("audio") then
package:add("links", a .. "audio" .. e)
if package:is_plat("windows", "mingw") and not package:config("shared") then
package:add("links", "openal32", "flac", "vorbisenc", "vorbisfile", "vorbis", "ogg")
elseif package:is_plat("linux") then
package:add("deps", "libogg", "libflac", "libvorbis", "openal-soft")
end end
end end
if package:config("network") then
package:add("links", a .. "network" .. e)
if package:is_plat("windows", "mingw") and not package:config("shared") then
package:add("syslinks", "ws2_32")
end end
if package:config("window") and package:is_plat("linux") then
local libfiles = {}
for _, name in ipairs({"libx11", "libxcursor", "libxrandr", "libxrender", "libxfixes", "libxext"}) do
local dep = package:dep(name)
if dep then
local fetchinfo = dep:fetch()
if fetchinfo then
table.join2(libfiles, fetchinfo.libfiles)
print(fetchinfo.libfiles)
end end
if package:is_plat("windows", "mingw") and package:config("main") then
package:add("links", main_module)
end end
package:add("links", a .. "system" .. e) end
if package:is_plat("windows", "mingw") then if #libfiles > 0 then
package:add("syslinks", "winmm") libfiles = table.reverse_unique(libfiles)
local libraries = {}
for _, libfile in ipairs(libfiles) do
table.insert(libraries, (libfile:gsub("\\", "/")))
end
local file = io.open("src/SFML/Window/CMakeLists.txt", "a")
file:print("target_link_libraries(sfml-window PRIVATE " .. table.concat(libraries, " ") .. ")")
file:close()
end end
end end
end)
on_install("windows", "linux", function (package)
local configs = {"-DSFML_BUILD_DOC=OFF", "-DSFML_BUILD_EXAMPLES=OFF"}
table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
if package:config("shared") then
table.insert(configs, "-DBUILD_SHARED_LIBS=ON")
else else
table.insert(configs, "-DBUILD_SHARED_LIBS=OFF") table.insert(configs, "-DBUILD_SHARED_LIBS=OFF")
if package:is_plat("windows") and package:config("vs_runtime"):startswith("MT") then if package:is_plat("windows") and package:config("vs_runtime"):startswith("MT") then
table.insert(configs, "-DSFML_USE_STATIC_STD_LIBS=ON") table.insert(configs, "-DSFML_USE_STATIC_STD_LIBS=ON")
end end
end end
local packagedeps
if package:is_plat("linux") and package:config("shared") then
io.replace("src/SFML/Graphics/CMakeLists.txt", "target_link_libraries(sfml-graphics PRIVATE X11)",
"target_link_libraries(sfml-graphics PRIVATE X11 Xext Xrender)", {plain = true})
packagedeps = {"libxext", "libxrender"}
end
table.insert(configs, "-DSFML_BUILD_AUDIO=" .. (package:config("audio") and "ON" or "OFF")) table.insert(configs, "-DSFML_BUILD_AUDIO=" .. (package:config("audio") and "ON" or "OFF"))
table.insert(configs, "-DSFML_BUILD_GRAPHICS=" .. (package:config("graphics") and "ON" or "OFF")) table.insert(configs, "-DSFML_BUILD_GRAPHICS=" .. (package:config("graphics") and "ON" or "OFF"))
table.insert(configs, "-DSFML_BUILD_WINDOW=" .. (package:config("window") and "ON" or "OFF")) table.insert(configs, "-DSFML_BUILD_WINDOW=" .. (package:config("window") and "ON" or "OFF"))
table.insert(configs, "-DSFML_BUILD_NETWORK=" .. (package:config("network") and "ON" or "OFF")) table.insert(configs, "-DSFML_BUILD_NETWORK=" .. (package:config("network") and "ON" or "OFF"))
import("package.tools.cmake").install(package, configs, {packagedeps = packagedeps}) table.insert(configs, "-DWARNINGS_AS_ERRORS=OFF")
end) table.insert(configs, "-DSFML_USE_SYSTEM_DEPS=TRUE")
local packagedeps
on_install("macosx", "mingw", function (package) if package:config("audio") then
os.cp("lib", package:installdir()) packagedeps = packagedeps or {}
os.cp("include", package:installdir()) table.insert(packagedeps, "openal-soft")
if package:is_plat("mingw") then
os.cp("bin/*", package:installdir("lib"), {rootdir = "bin"})
end end
if package:config("graphics") then
packagedeps = packagedeps or {}
table.insert(packagedeps, "freetype")
table.insert(packagedeps, "zlib")
end
import("package.tools.cmake").install(package, configs, {packagedeps = packagedeps})
end) end)
on_test(function (package) on_test(function (package)
@ -282,5 +292,3 @@ package("sfml")
]]}, {includes = "SFML/Network.hpp"})) ]]}, {includes = "SFML/Network.hpp"}))
end end
end) end)
package_end()

Loading…
Cancel
Save