xmake.lua 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. package("tgbot-cpp")
  2. set_homepage("http://reo7sp.github.io/tgbot-cpp")
  3. set_description("C++ library for Telegram bot API")
  4. set_license("MIT")
  5. set_urls("https://github.com/reo7sp/tgbot-cpp/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/reo7sp/tgbot-cpp.git")
  7. add_versions("v1.7.2", "3a41c25c5e4b60bda3f278550a380f1c7c382fd50ea1ab1801edc837d1535462")
  8. add_configs("curl", {description = "Use curl-based http client CurlHttpClient", default = false, type = "boolean"})
  9. add_deps("openssl", "zlib")
  10. add_deps("boost", {configs = {system = true}})
  11. on_load(function (package)
  12. if package:config("curl") then
  13. package:add("deps", "libcurl", {configs = {openssl = true}})
  14. end
  15. end)
  16. on_install("windows", "linux", "macosx", "mingw", "cross", function (package)
  17. local configs = {}
  18. io.writefile("xmake.lua", [[
  19. add_requires("openssl", "zlib")
  20. add_requires("boost", {configs = {system = true}})
  21. if has_config("curl") then
  22. add_requires("libcurl", {configs = {openssl = true}})
  23. end
  24. add_rules("mode.debug", "mode.release")
  25. target("tgbot-cpp")
  26. set_kind("$(kind)")
  27. add_files("src/**.cpp")
  28. add_includedirs("include")
  29. add_headerfiles("include/(tgbot/**.h)")
  30. set_languages("c++14")
  31. if is_plat("windows") then
  32. add_defines("_WIN32_WINNT=0x0601", "WIN32_LEAN_AND_MEAN", "NOMINMAX")
  33. end
  34. if is_kind("shared") then
  35. -- add_defines("TGBOT_DLL")
  36. if is_plat("windows") then
  37. add_rules("utils.symbols.export_all", {export_classes = true})
  38. end
  39. end
  40. add_packages("boost", "openssl", "zlib")
  41. if has_config("curl") then
  42. add_packages("libcurl")
  43. add_defines("HAVE_CURL")
  44. end
  45. ]])
  46. if package:config("shared") then
  47. configs.kind = "shared"
  48. end
  49. import("package.tools.xmake").install(package, configs)
  50. end)
  51. on_test(function (package)
  52. assert(package:check_cxxsnippets({test = [[
  53. #include <tgbot/tgbot.h>
  54. void test() {
  55. TgBot::Bot bot("PLACE YOUR TOKEN HERE");
  56. }
  57. ]]}, {configs = {languages = "c++14"}}))
  58. end)