2
0

xmake.lua 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package("stx")
  2. set_homepage("https://lamarrr.github.io/STX")
  3. set_description("C++17 & C++ 20 error-handling and utility extensions. ")
  4. set_license("MIT")
  5. add_urls("https://github.com/lamarrr/STX/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/lamarrr/STX.git")
  7. add_versions("v1.0.5", "d21a1895bc7057c8c6118a042ec39f364b2ad768394d4facb2fd64b73b07d97f")
  8. add_versions("v1.0.3", "0118b76a5f2a7a60132edecc9b632d9fc82a187bc232ac1a3fd9200fdd92dc7d")
  9. add_configs("backtrace", {description = "Enable stack backtraces", default = false, type = "boolean"})
  10. add_configs("custom_handler", {description = "Override the default panic behaviour by implementing a custom panic handler. The default behavior is to print the panic report and abort the program. (You can read the docs for more details)", default = false, type = "boolean"})
  11. add_configs("shared", {description = "Build shared binaries", default = false, type = "boolean", readonly = true})
  12. if is_plat("linux", "bsd") then
  13. add_syslinks("pthread")
  14. end
  15. add_deps("cmake")
  16. on_install("windows", "linux", "macosx", "bsd", "mingw", "msys", "iphoneos", "cross", function (package)
  17. local configs = {}
  18. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  19. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  20. table.insert(configs, "-DSTX_ENABLE_BACKTRACE=" .. (package:config("backtrace") and "ON" or "OFF"))
  21. table.insert(configs, "-DSTX_CUSTOM_PANIC_HANDLER=" .. (package:config("custom_handler") and "ON" or "OFF"))
  22. import("package.tools.cmake").install(package, configs)
  23. end)
  24. on_test(function (package)
  25. assert(package:check_cxxsnippets({test = [[
  26. #include <stx/option.h>
  27. using stx::Option, stx::Some, stx::None;
  28. auto safe_divide(double numerator, double denominator) -> Option<double> {
  29. if (denominator == 0.0) return None;
  30. return Some(numerator / denominator);
  31. }
  32. void test() {
  33. safe_divide(5.0, 2.0).match(
  34. [](auto value){},
  35. [](){});
  36. }
  37. ]]}, {configs = {languages = "c++17"}}))
  38. end)