From 57ee511b8637b4eddc1f36d302051d3c604f43d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Thu, 3 Jun 2021 17:22:00 +0200 Subject: [PATCH] XMake: Add OpenAL-soft package In order to provide openal-soft DLL when running or installing the engine --- xmake-repo/packages/l/libvorbis/xmake.lua | 97 ----------------------- xmake.lua | 16 ++-- 2 files changed, 10 insertions(+), 103 deletions(-) delete mode 100644 xmake-repo/packages/l/libvorbis/xmake.lua diff --git a/xmake-repo/packages/l/libvorbis/xmake.lua b/xmake-repo/packages/l/libvorbis/xmake.lua deleted file mode 100644 index b4e493467..000000000 --- a/xmake-repo/packages/l/libvorbis/xmake.lua +++ /dev/null @@ -1,97 +0,0 @@ -package("libvorbis") - - set_homepage("https://xiph.org/vorbis") - set_description("Reference implementation of the Ogg Vorbis audio format.") - set_license("BSD-3") - - set_urls("https://ftp.osuosl.org/pub/xiph/releases/vorbis/libvorbis-$(version).tar.gz", - "https://github.com/xiph/vorbis/releases/download/v$(version)/libvorbis-$(version).tar.gz", - "https://gitlab.xiph.org/xiph/vorbis.git") - - add_versions("1.3.7", "0e982409a9c3fc82ee06e08205b1355e5c6aa4c36bca58146ef399621b0ce5ab") - - add_configs("with_vorbisenc", {description = "Includes libvorbisenc", default = true, type = "boolean"}) - add_configs("with_vorbisfile", {description = "Includes libvorbisfile", default = true, type = "boolean"}) - - add_deps("cmake", "libogg") - - on_fetch(function (package, opt) - if opt.system then - local vorbis = find_package("vorbis") - if not vorbis then - return - end - local result = table.copy(vorbis) - - if package:config("with_vorbisenc") then - local vorbisenc = find_package("vorbisenc") - if not vorbisenc then - return - end - - result.includedirs = table.join(vorbisenc.includedirs, result.includedirs or {}) - result.linkdirs = table.join(vorbisenc.linkdirs, result.linkdirs or {}) - result.links = table.join(vorbisenc.links, result.links or {}) - end - - if package:config("with_vorbisfile") then - local vorbisfile = find_package("vorbisfile") - if not vorbisfile then - return - end - - result.includedirs = table.join(vorbisfile.includedirs, result.includedirs or {}) - result.linkdirs = table.join(vorbisfile.linkdirs, result.linkdirs or {}) - result.links = table.join(vorbisfile.links, result.links or {}) - end - - return result - end - end) - - on_load(function (package) - if package:config("with_vorbisenc") then - package:add("links", "vorbisenc") - end - if package:config("with_vorbisfile") then - package:add("links", "vorbisfile") - end - package:add("links", "vorbis") - end) - - on_install("windows", "linux", "macosx", "iphoneos", "mingw", "android", function (package) - local configs = {} - table.insert(configs, "-DBUILD_TESTING=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 not package:config("with_vorbisenc") then - io.replace("CMakeLists.txt", "${CMAKE_CURRENT_BINARY_DIR}/vorbisenc.pc", "", {plain = true}) - end - if not package:config("with_vorbisfile") then - io.replace("CMakeLists.txt", "${CMAKE_CURRENT_BINARY_DIR}/vorbisfile.pc", "", {plain = true}) - end - -- we pass libogg as packagedeps instead of findOgg.cmake (it does not work) - local libogg = package:dep("libogg"):fetch() - if libogg then - local links = table.concat(table.wrap(libogg.links), " ") - io.replace("CMakeLists.txt", "find_package(Ogg REQUIRED)", "", {plain = true}) - io.replace("lib/CMakeLists.txt", "Ogg::ogg", links, {plain = true}) - end - -- disable .def file for mingw - if package:config("shared") and package:is_plat("mingw") then - io.replace("lib/CMakeLists.txt", [[list(APPEND VORBIS_SOURCES ../win32/vorbis.def) - list(APPEND VORBISENC_SOURCES ../win32/vorbisenc.def) - list(APPEND VORBISFILE_SOURCES ../win32/vorbisfile.def)]], "", {plain = true}) - end - import("package.tools.cmake").install(package, configs, {packagedeps = "libogg"}) - end) - - on_test(function (package) - assert(package:has_cfuncs("vorbis_info_init", {includes = "vorbis/codec.h"})) - if package:config("with_vorbisenc") then - assert(package:has_cfuncs("vorbis_encode_init", {includes = "vorbis/vorbisenc.h"})) - end - if package:config("with_vorbisfile") then - assert(package:has_cfuncs("ov_open_callbacks", {includes = "vorbis/vorbisfile.h"})) - end - end) diff --git a/xmake.lua b/xmake.lua index c2d1780a1..34f8c8a21 100644 --- a/xmake.lua +++ b/xmake.lua @@ -2,6 +2,9 @@ local modules = { Audio = { Deps = {"NazaraCore"}, Packages = {"dr_wav", "libflac", "libvorbis", "minimp3"}, + Custom = function () + add_packages("openal-soft", {links = {}}) -- Don't link OpenAL (it will be loaded dynamically) + end }, Core = { Custom = function () @@ -97,6 +100,7 @@ add_repositories("local-repo xmake-repo") add_requires("chipmunk2d", "dr_wav", "freetype", "libflac", "libsdl", "minimp3", "stb") add_requires("libvorbis", { configs = { with_vorbisenc = false } }) +add_requires("openal-soft", { configs = { shared = true }}) add_requires("newtondynamics", { debug = is_plat("windows") and is_mode("debug") }) -- Newton doesn't like compiling in Debug on Linux set_project("NazaraEngine") @@ -142,11 +146,15 @@ for name, module in pairs(modules) do add_rules("embed_resources") if module.Deps then - add_deps(module.Deps) + add_deps(table.unpack(module.Deps)) end if module.Packages then - add_packages(module.Packages) + add_packages(table.unpack(module.Packages)) + end + + if module.Custom then + module.Custom() end add_defines("NAZARA_BUILD") @@ -175,10 +183,6 @@ for name, module in pairs(modules) do if not is_plat("linux") then del_files("src/Nazara/" .. name .. "/Linux/**.cpp") end - - if module.Custom then - module.Custom() - end end includes("xmake/actions/*.lua")