diff --git a/packages/d/dpp/port/xmake.lua b/packages/d/dpp/port/xmake.lua index 22d9e0f3172..83dd198dbf0 100644 --- a/packages/d/dpp/port/xmake.lua +++ b/packages/d/dpp/port/xmake.lua @@ -1,14 +1,33 @@ add_rules("mode.debug", "mode.release") - -add_requires("fmt", "nlohmann_json", "libsodium", "libopus", "openssl", "zlib") +add_requires("fmt", "nlohmann_json", "openssl", "zlib") +option("coro", {default = false}) +option("voice", {default = true}) +if has_config("voice") then + add_requires("libopus", "libsodium") +end target("dpp") set_kind("$(kind)") - set_languages("c++17") add_includedirs("include", "include/dpp") add_headerfiles("include/(dpp/**.h)") add_files("src/dpp/**.cpp") - add_packages("fmt", "nlohmann_json", "libsodium", "libopus", "openssl", "zlib") + add_packages("fmt", "nlohmann_json", "openssl", "zlib") + + if has_config("voice") then + add_packages("libopus", "libsodium") + add_defines("HAVE_VOICE") + end + + if has_config("coro") then + add_defines("DPP_CORO") + end + + local target_cpp_lang = "c++17" + if has_config("coro") then + target_cpp_lang = "c++20" + end + + set_languages(target_cpp_lang) add_defines("DPP_BUILD", "DPP_USE_EXTERNAL_JSON") diff --git a/packages/d/dpp/xmake.lua b/packages/d/dpp/xmake.lua index fc0d40de563..aba68b11a96 100644 --- a/packages/d/dpp/xmake.lua +++ b/packages/d/dpp/xmake.lua @@ -53,7 +53,9 @@ package("dpp") add_deps("nlohmann_json", "openssl", "zlib") - add_configs("have_voice", { description = "Enable voice support for the library.", default = true, type = "boolean" , readonly = true}) + add_configs("voice", { description = "Enable voice support for the library.", default = true, type = "boolean" , readonly = false}) + add_configs("have_voice", { description = "Enable voice support for the library (Deprecated flag, move out to newer version 'voice').", default = false, type = "boolean" , readonly = false}) + add_configs("coro", { description = "Enable experimental coroutines support for the library.", default = false, type = "boolean" , readonly = false}) if is_plat("linux", "macosx") then add_syslinks("pthread") @@ -64,13 +66,27 @@ package("dpp") package:add("defines", "DPP_STATIC") end if package:config("have_voice") then + wprint([[ + === Deprecation Warning === + You should move out to use voice flag, instead of have_voice + Deprecated: + add_requires("dpp", { + configs = {have_voice = true} + }) + New (Recommended): + add_requires("dpp", { + configs = {voice = true} + }) + This flag will be removed soon, please migrate ASAP! + ]]) + end + if package:config("voice") then package:add("defines", "HAVE_VOICE") package:add("deps", "libsodium", "libopus") end - if package:config("have_voice") then - package:add("defines", "HAVE_VOICE") - package:add("deps", "libsodium", "libopus") + if package:config("coro") then + package:add("defines", "DPP_CORO") end if package:version():le("v10.0.13") then @@ -103,7 +119,11 @@ package("dpp") io.replace("include/dpp/restrequest.h", "#include ", "#include ", {plain = true}) os.rmdir("include/dpp/nlohmann") - local configs = {} + local configs = { + voice = package:config("voice") or package:config("have_voice"), + coro = package:config("coro") + } + if package:version():ge("v10.0.29") and package:is_plat("windows") then configs.cxflags = "/bigobj /Gy" end @@ -112,6 +132,10 @@ package("dpp") end) on_test(function (package) + local test_cpp_ver = "c++17" + if package:config("coro") then + test_cpp_ver = "c++20" + end assert(package:check_cxxsnippets({test = [[ void test() { dpp::cluster bot(std::getenv("BOT_TOKEN")); @@ -124,5 +148,5 @@ package("dpp") }); bot.start(false); } - ]]}, {configs = {languages = "c++17"}, includes = "dpp/dpp.h"})) + ]]}, {configs = {languages = test_cpp_ver}, includes = "dpp/dpp.h"})) end)