xmake.lua 5.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. package("dpp")
  2. set_homepage("https://github.com/brainboxdotcc/DPP")
  3. set_description("D++ Extremely Lightweight C++ Discord Library")
  4. set_license("Apache-2.0")
  5. add_urls("https://github.com/brainboxdotcc/DPP/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/brainboxdotcc/DPP.git")
  7. -- NOTE !
  8. -- Keep all versions with the same major number. If D++ switch to a new major version,
  9. -- keep only the latest previous versions.
  10. -- i.e. if D++ switch to v11.x.x, keep only the latest v10.x.x and delete the rest.
  11. add_versions("v10.0.15", "5370e7fa3e76ed78b87dc4d9c01cc5a5f1a5789ebf1d3d0e8deff05cb665c539")
  12. add_patches("v10.0.15", path.join(os.scriptdir(), "patches", "v10.0.14", "static_export.patch"), "2a5d47e09438e17b67d9fd73a943653ab8d1739f118f102ed44ae8d34c19da07")
  13. add_versions("v10.0.14", "5eb4cf3b4f4ba200d5f0d57929a1b96cc79e2398004afccc9d9c63aee865ca9d")
  14. add_patches("v10.0.14", path.join(os.scriptdir(), "patches", "v10.0.10", "permission_include.patch"), "4fdf8e406c7f610453090253bf1640e42c47a06968f65a4a21d01104a2d04fd4")
  15. add_patches("v10.0.14", path.join(os.scriptdir(), "patches", "v10.0.13", "cstring_include.patch"), "fd3af16877d46ba572f2aa33d80d36b44892a886fb3987953ac2e5fbd14263b9")
  16. add_patches("v10.0.14", path.join(os.scriptdir(), "patches", "v10.0.14", "static_export.patch"), "2a5d47e09438e17b67d9fd73a943653ab8d1739f118f102ed44ae8d34c19da07")
  17. add_versions("v10.0.13", "35dc9f5dc265d70047df67b13ae45f7345ed3f3b842b114fd89cacb3c83428ed")
  18. add_patches("v10.0.13", path.join(os.scriptdir(), "patches", "v10.0.8", "static_export.patch"), "d18487580faa9af21862bcff30ddfa5d5ab5cda6aa5f779bcc1787a96ca66447")
  19. add_patches("v10.0.13", path.join(os.scriptdir(), "patches", "v10.0.10", "permission_include.patch"), "4fdf8e406c7f610453090253bf1640e42c47a06968f65a4a21d01104a2d04fd4")
  20. add_patches("v10.0.13", path.join(os.scriptdir(), "patches", "v10.0.13", "cstring_include.patch"), "fd3af16877d46ba572f2aa33d80d36b44892a886fb3987953ac2e5fbd14263b9")
  21. add_versions("v10.0.12", "a986fcd0e6d491b0df6522fe2c85bff1e16f5513bcc3abee1b774ff25e03ee1b")
  22. add_patches("v10.0.12", path.join(os.scriptdir(), "patches", "v10.0.8", "static_export.patch"), "d18487580faa9af21862bcff30ddfa5d5ab5cda6aa5f779bcc1787a96ca66447")
  23. add_patches("v10.0.12", path.join(os.scriptdir(), "patches", "v10.0.10", "permission_include.patch"), "4fdf8e406c7f610453090253bf1640e42c47a06968f65a4a21d01104a2d04fd4")
  24. add_patches("v10.0.12", path.join(os.scriptdir(), "patches", "v10.0.12", "mutex_include.patch"), "0fc8ee9d6bca65d591ce473aa1136fc30209e27746e91d4088cf3198564b715d")
  25. add_versions("v10.0.11", "33463292f3030eabf70ab54ff09475945b4d87a9c6e428c712015cba93a1ed96")
  26. add_patches("v10.0.11", path.join(os.scriptdir(), "patches", "v10.0.8", "static_export.patch"), "d18487580faa9af21862bcff30ddfa5d5ab5cda6aa5f779bcc1787a96ca66447")
  27. add_patches("v10.0.11", path.join(os.scriptdir(), "patches", "v10.0.10", "permission_include.patch"), "4fdf8e406c7f610453090253bf1640e42c47a06968f65a4a21d01104a2d04fd4")
  28. add_versions("v10.0.10", "2a1c26f606298e5b683d1e140219c434e61c4b22e8510fa2a2d5f7b6758dff95")
  29. add_patches("v10.0.10", path.join(os.scriptdir(), "patches", "v10.0.8", "static_export.patch"), "d18487580faa9af21862bcff30ddfa5d5ab5cda6aa5f779bcc1787a96ca66447")
  30. add_patches("v10.0.10", path.join(os.scriptdir(), "patches", "v10.0.10", "permission_include.patch"), "4fdf8e406c7f610453090253bf1640e42c47a06968f65a4a21d01104a2d04fd4")
  31. add_versions("v10.0.8", "7a16d31841fc67fabcafbc33abb1a6b2ac472202df7e8c48542f77e089de08e3")
  32. add_patches("v10.0.8", path.join(os.scriptdir(), "patches", "v10.0.8", "static_export.patch"), "d18487580faa9af21862bcff30ddfa5d5ab5cda6aa5f779bcc1787a96ca66447")
  33. add_deps("nlohmann_json", "libsodium", "libopus", "openssl", "zlib")
  34. if is_plat("linux", "macosx") then
  35. add_syslinks("pthread")
  36. end
  37. on_load("windows", "mingw", function (package)
  38. if not package:config("shared") then
  39. package:add("defines", "DPP_STATIC")
  40. end
  41. if package:version():le("v10.0.13") then
  42. package:add("deps", "fmt")
  43. end
  44. end)
  45. on_install("windows", "linux", "macosx", "mingw", function (package)
  46. -- fix dpp dependencies
  47. for _, file in ipairs(table.join(os.files("include/**.h"), os.files("src/**.cpp"))) do
  48. io.replace(file, "#include <dpp/fmt/", "#include <fmt/", {plain = true})
  49. io.replace(file, "#include <dpp/nlohmann/", "#include <nlohmann/", {plain = true})
  50. end
  51. for _, file in ipairs(os.files("src/**.cpp")) do
  52. io.replace(file, "#include <nlohmann/json_fwd.hpp>", "#include <nlohmann/json.hpp>", {plain = true})
  53. end
  54. if package:version():le("v10.0.14") then
  55. os.rmdir("include/dpp/fmt")
  56. end
  57. io.replace("include/dpp/restrequest.h", "#include <nlohmann/json_fwd.hpp>", "#include <nlohmann/json.hpp>", {plain = true})
  58. os.rmdir("include/dpp/nlohmann")
  59. os.cp(path.join(package:scriptdir(), "port", "xmake.lua"), "xmake.lua")
  60. import("package.tools.xmake").install(package)
  61. end)
  62. on_test(function (package)
  63. assert(package:check_cxxsnippets({test = [[
  64. void test() {
  65. dpp::cluster bot(std::getenv("BOT_TOKEN"));
  66. bot.on_ready([&bot](auto event) {
  67. if (dpp::run_once<struct register_bot_commands>()) {
  68. bot.global_command_create(
  69. dpp::slashcommand("ping", "Ping pong!", bot.me.id)
  70. );
  71. }
  72. });
  73. bot.start(false);
  74. }
  75. ]]}, {configs = {languages = "c++17"}, includes = "dpp/dpp.h"}))
  76. end)