xmake.lua 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. package("coost")
  2. set_homepage("https://github.com/idealvin/coost")
  3. set_description("A tiny boost library in C++11.")
  4. set_license("MIT")
  5. add_urls("https://github.com/idealvin/coost/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/idealvin/coost.git")
  7. add_versions("v3.0.2", "922ba21fb9a922c84f6a4b3bd568ed3b3463ccb1ae906cd7c49d90c7f0359b24")
  8. add_versions("v3.0.1", "f2285d59dc8317dd2494d7628a56f10de9b814d90b86aedf93a3305f94c6ae1a")
  9. add_versions("v3.0.0", "f962201201cd77aaf45f33d72bd012231a31d4310d30e9bb580ffb1e94c8148d")
  10. add_patches("3.0.2", "https://github.com/idealvin/coost/commit/c9488af72e9086ef1d910e29f9efa4b4210a5190.patch", "837feb2b49dc5d162f27175627689680a61e54e761dcf972f0e27896249addc6")
  11. for _, name in ipairs({"libcurl", "openssl", "libbacktrace"}) do
  12. local default = false
  13. if name == "libbacktrace" and is_plat("linux") then
  14. default = true
  15. end
  16. add_configs(name, {description = "Enable " .. name .. " library.", default = default, type = "boolean"})
  17. end
  18. if is_plat("linux") then
  19. add_syslinks("pthread", "dl")
  20. end
  21. on_load(function (package)
  22. for _, dep in ipairs({"libcurl", "openssl"}) do
  23. if package:config(dep) then
  24. package:add("deps", dep)
  25. end
  26. end
  27. end)
  28. on_install("macosx", "linux", "windows|x64", "windows|x86", function (package)
  29. local configs = {}
  30. if package:config("shared") then
  31. configs.kind = "shared"
  32. end
  33. for _, name in ipairs({"libcurl", "openssl"}) do
  34. if package:config(name) then
  35. configs["with_" .. name] = true
  36. end
  37. end
  38. if package:is_plat("windows") then
  39. local vs_runtime = package:config("vs_runtime")
  40. if vs_runtime then
  41. io.replace("xmake.lua", "set_runtimes%(.-%)", "set_runtimes(\"" .. vs_runtime .. "\")")
  42. end
  43. end
  44. import("package.tools.xmake").install(package, configs)
  45. end)
  46. on_test(function (package)
  47. assert(package:check_cxxsnippets({test = [[
  48. #include "co/def.h"
  49. #include "co/atomic.h"
  50. void test() {
  51. int32 i32 = 0;
  52. atomic_inc(&i32);
  53. }
  54. ]]}, {configs = {languages = "c++11"}}))
  55. end)