From 1e33e4a289b74cede666aafc6aabf243c1c563cb Mon Sep 17 00:00:00 2001 From: nk125 Date: Fri, 2 Aug 2024 01:07:09 -0600 Subject: [PATCH 1/8] fix(dpp): Remove repeated have_voice condition --- packages/d/dpp/xmake.lua | 5 ----- 1 file changed, 5 deletions(-) diff --git a/packages/d/dpp/xmake.lua b/packages/d/dpp/xmake.lua index fc0d40de563..464fdc4e44c 100644 --- a/packages/d/dpp/xmake.lua +++ b/packages/d/dpp/xmake.lua @@ -68,11 +68,6 @@ package("dpp") package:add("deps", "libsodium", "libopus") end - if package:config("have_voice") then - package:add("defines", "HAVE_VOICE") - package:add("deps", "libsodium", "libopus") - end - if package:version():le("v10.0.13") then package:add("deps", "fmt") end From baec75d42dd0065fdede09198b1515e5464952b8 Mon Sep 17 00:00:00 2001 From: nk125 Date: Fri, 2 Aug 2024 01:31:46 -0600 Subject: [PATCH 2/8] feat(dpp): Make have_voice option modifiable De-const have_voice option and enables optional download of voice libraries --- packages/d/dpp/port/xmake.lua | 15 +++++++++++++-- packages/d/dpp/xmake.lua | 7 +++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/packages/d/dpp/port/xmake.lua b/packages/d/dpp/port/xmake.lua index 22d9e0f3172..578a0c22ef0 100644 --- a/packages/d/dpp/port/xmake.lua +++ b/packages/d/dpp/port/xmake.lua @@ -1,6 +1,12 @@ add_rules("mode.debug", "mode.release") -add_requires("fmt", "nlohmann_json", "libsodium", "libopus", "openssl", "zlib") +add_requires("fmt", "nlohmann_json", "openssl", "zlib") + +option("have_voice", {default = true}) + +if has_config("have_voice") then + add_requires("libopus", "libsodium") +end target("dpp") set_kind("$(kind)") @@ -8,7 +14,12 @@ target("dpp") 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("have_voice") then + add_packages("libopus", "libsodium") + add_defines("HAVE_VOICE") + end add_defines("DPP_BUILD", "DPP_USE_EXTERNAL_JSON") diff --git a/packages/d/dpp/xmake.lua b/packages/d/dpp/xmake.lua index 464fdc4e44c..aa6550a543e 100644 --- a/packages/d/dpp/xmake.lua +++ b/packages/d/dpp/xmake.lua @@ -53,7 +53,7 @@ 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("have_voice", { description = "Enable voice support for the library.", default = true, type = "boolean" , readonly = false}) if is_plat("linux", "macosx") then add_syslinks("pthread") @@ -98,7 +98,10 @@ package("dpp") io.replace("include/dpp/restrequest.h", "#include ", "#include ", {plain = true}) os.rmdir("include/dpp/nlohmann") - local configs = {} + local configs = { + have_voice = package:config("have_voice") + } + if package:version():ge("v10.0.29") and package:is_plat("windows") then configs.cxflags = "/bigobj /Gy" end From 4db9dfe0ba082eab3f94f98fc38c8f29def95950 Mon Sep 17 00:00:00 2001 From: nk125 Date: Fri, 2 Aug 2024 01:46:48 -0600 Subject: [PATCH 3/8] feat(dpp): Add coroutine support Adds a configurable option to enable coroutine support --- packages/d/dpp/port/xmake.lua | 7 +++++++ packages/d/dpp/xmake.lua | 9 ++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/packages/d/dpp/port/xmake.lua b/packages/d/dpp/port/xmake.lua index 578a0c22ef0..c4fd0d48e6c 100644 --- a/packages/d/dpp/port/xmake.lua +++ b/packages/d/dpp/port/xmake.lua @@ -2,6 +2,8 @@ add_rules("mode.debug", "mode.release") add_requires("fmt", "nlohmann_json", "openssl", "zlib") +option("coro", {default = false}) + option("have_voice", {default = true}) if has_config("have_voice") then @@ -21,6 +23,11 @@ target("dpp") add_defines("HAVE_VOICE") end + if has_config("coro") then + set_languages("c++20") + add_defines("DPP_CORO") + end + add_defines("DPP_BUILD", "DPP_USE_EXTERNAL_JSON") if is_plat("windows", "mingw") then diff --git a/packages/d/dpp/xmake.lua b/packages/d/dpp/xmake.lua index aa6550a543e..179329ee6c5 100644 --- a/packages/d/dpp/xmake.lua +++ b/packages/d/dpp/xmake.lua @@ -55,6 +55,8 @@ package("dpp") add_configs("have_voice", { description = "Enable voice support for the library.", default = true, 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") end @@ -68,6 +70,10 @@ package("dpp") package:add("deps", "libsodium", "libopus") end + if package:config("coro") then + package:add("defines", "DPP_CORO") + end + if package:version():le("v10.0.13") then package:add("deps", "fmt") end @@ -99,7 +105,8 @@ package("dpp") os.rmdir("include/dpp/nlohmann") local configs = { - have_voice = package:config("have_voice") + have_voice = package:config("have_voice"), + coro = package:config("coro") } if package:version():ge("v10.0.29") and package:is_plat("windows") then From 84b45d9f44c4a238f933fab601f7e9764c7d5dcb Mon Sep 17 00:00:00 2001 From: nk125 Date: Sat, 3 Aug 2024 18:30:05 -0600 Subject: [PATCH 4/8] fix(dpp)!: Change have_voice to voice inside package As mentioned in the same pull request, prefixes like have_ are discouraged in xmake packages. BREAKING CHANGES: This WILL break xmake scripts that use the have_voice flag, IMO it's better to keep the previous have_voice flag as a deprecated alias of the new voice flag, and in the next version of D++ completely remove it from the package. --- packages/d/dpp/port/xmake.lua | 6 +++--- packages/d/dpp/xmake.lua | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/d/dpp/port/xmake.lua b/packages/d/dpp/port/xmake.lua index c4fd0d48e6c..45cfa907012 100644 --- a/packages/d/dpp/port/xmake.lua +++ b/packages/d/dpp/port/xmake.lua @@ -4,9 +4,9 @@ add_requires("fmt", "nlohmann_json", "openssl", "zlib") option("coro", {default = false}) -option("have_voice", {default = true}) +option("voice", {default = true}) -if has_config("have_voice") then +if has_config("voice") then add_requires("libopus", "libsodium") end @@ -18,7 +18,7 @@ target("dpp") add_files("src/dpp/**.cpp") add_packages("fmt", "nlohmann_json", "openssl", "zlib") - if has_config("have_voice") then + if has_config("voice") then add_packages("libopus", "libsodium") add_defines("HAVE_VOICE") end diff --git a/packages/d/dpp/xmake.lua b/packages/d/dpp/xmake.lua index 179329ee6c5..880e86c260f 100644 --- a/packages/d/dpp/xmake.lua +++ b/packages/d/dpp/xmake.lua @@ -53,7 +53,7 @@ package("dpp") add_deps("nlohmann_json", "openssl", "zlib") - add_configs("have_voice", { description = "Enable voice support for the library.", default = true, type = "boolean" , readonly = false}) + add_configs("voice", { description = "Enable voice support for the library.", default = true, type = "boolean" , readonly = false}) add_configs("coro", { description = "Enable experimental coroutines support for the library.", default = false, type = "boolean" , readonly = false}) @@ -65,7 +65,7 @@ package("dpp") if not package:config("shared") then package:add("defines", "DPP_STATIC") end - if package:config("have_voice") then + if package:config("voice") then package:add("defines", "HAVE_VOICE") package:add("deps", "libsodium", "libopus") end @@ -105,7 +105,7 @@ package("dpp") os.rmdir("include/dpp/nlohmann") local configs = { - have_voice = package:config("have_voice"), + voice = package:config("voice"), coro = package:config("coro") } From ee9454b58ff9a0dea93220d6393703cc0e1fd59b Mon Sep 17 00:00:00 2001 From: nk125 Date: Sat, 3 Aug 2024 18:48:33 -0600 Subject: [PATCH 5/8] fix(dpp): Add C++ minimum version for test If coroutines are enabled, C++20 is required or the compilation will fail even though the test only requires C++17 to work, as dpp automatically includes coroutines if the macro is defined without checking C++ version --- packages/d/dpp/xmake.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/d/dpp/xmake.lua b/packages/d/dpp/xmake.lua index 880e86c260f..e73907ac8d2 100644 --- a/packages/d/dpp/xmake.lua +++ b/packages/d/dpp/xmake.lua @@ -117,6 +117,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")); @@ -129,5 +133,5 @@ package("dpp") }); bot.start(false); } - ]]}, {configs = {languages = "c++17"}, includes = "dpp/dpp.h"})) + ]]}, {configs = {languages = test_cpp_ver}, includes = "dpp/dpp.h"})) end) From ef43fab0c4d99d0a91151ae59e02704673b88417 Mon Sep 17 00:00:00 2001 From: nk125 Date: Sat, 3 Aug 2024 18:54:09 -0600 Subject: [PATCH 6/8] fix(dpp): Set C++ language for library dinamically The current configuration wasn't proper and when coroutines were enabled, the C++ version would change to C++17 sporadically, ignoring the later C++20 specification that was done later. Now the C++ version will adjust correctly to the coro flag. --- packages/d/dpp/port/xmake.lua | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/d/dpp/port/xmake.lua b/packages/d/dpp/port/xmake.lua index 45cfa907012..958eea339d6 100644 --- a/packages/d/dpp/port/xmake.lua +++ b/packages/d/dpp/port/xmake.lua @@ -12,7 +12,6 @@ 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") @@ -24,10 +23,16 @@ target("dpp") end if has_config("coro") then - set_languages("c++20") 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") if is_plat("windows", "mingw") then From 371cb43eaf7abc11bbca8b2e5552821e776f5908 Mon Sep 17 00:00:00 2001 From: nk125 Date: Sat, 3 Aug 2024 21:30:29 -0600 Subject: [PATCH 7/8] style(dpp): Remove requested empty lines --- packages/d/dpp/port/xmake.lua | 4 ---- 1 file changed, 4 deletions(-) diff --git a/packages/d/dpp/port/xmake.lua b/packages/d/dpp/port/xmake.lua index 958eea339d6..83dd198dbf0 100644 --- a/packages/d/dpp/port/xmake.lua +++ b/packages/d/dpp/port/xmake.lua @@ -1,11 +1,7 @@ add_rules("mode.debug", "mode.release") - 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 From 893669775e0110235b1a4eff910de0f08747740e Mon Sep 17 00:00:00 2001 From: nk125 Date: Sun, 4 Aug 2024 00:27:39 -0600 Subject: [PATCH 8/8] feat(dpp): Re-add have_voice flag with deprecated warning This will bring up again have_voice to avoid codebase breakage, but with many deprecation warnings around to prevent new users to define it. --- packages/d/dpp/xmake.lua | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/packages/d/dpp/xmake.lua b/packages/d/dpp/xmake.lua index e73907ac8d2..aba68b11a96 100644 --- a/packages/d/dpp/xmake.lua +++ b/packages/d/dpp/xmake.lua @@ -54,7 +54,7 @@ package("dpp") add_deps("nlohmann_json", "openssl", "zlib") 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 @@ -65,6 +65,21 @@ package("dpp") if not package:config("shared") then 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") @@ -105,7 +120,7 @@ package("dpp") os.rmdir("include/dpp/nlohmann") local configs = { - voice = package:config("voice"), + voice = package:config("voice") or package:config("have_voice"), coro = package:config("coro") }