xmake.lua 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. package("asbind20")
  2. set_homepage("https://asbind20.readthedocs.io/")
  3. set_description("C++20 AngelScript binding library")
  4. set_license("MIT")
  5. add_urls("https://github.com/HenryAWE/asbind20/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/HenryAWE/asbind20.git")
  7. add_versions("1.6.0", "e936b5c1c89d7e66165f34ba4f536faab9fea397c36172b3e455436d525da461")
  8. add_deps("cmake")
  9. add_deps("angelscript >= 2.37.0")
  10. -- Shared library is not supported by current release (1.6) --
  11. add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
  12. add_configs("ext", {description = "Build the extensions.", default = true, type = "boolean"})
  13. on_check(function (package)
  14. if package:is_plat("mingw") then
  15. if is_host("macosx") and package:is_arch("i386") then
  16. assert(false, "package(asbind20): Unsupported on mingw|i386")
  17. end
  18. end
  19. assert(package:check_cxxsnippets({test = [[
  20. #include <concepts>
  21. void test(std::signed_integral auto x) {
  22. static_assert(std::integral<int>);
  23. static_assert(std::floating_point<double>);
  24. static_assert(std::same_as<int, signed>);
  25. static_assert(std::convertible_to<int, long>);
  26. }
  27. ]]}, {configs = {languages = "c++20"}}), "package(asbind20): need std::convertible_to from <concepts> header.")
  28. end)
  29. on_load(function (package)
  30. -- The core library is header-only --
  31. if not package:config("ext") then
  32. package:set("kind", "library", {headeronly = true})
  33. end
  34. end)
  35. on_install("windows", "linux", "android", "msys", "mingw", function (package)
  36. if package:is_plat("windows") and package:is_arch("arm64") then
  37. -- Exported target namespace starts with capital letter, but XMake auto-generated CMakeConfig defines it as angelscript::angelscript
  38. io.replace("CMakeLists.txt", "Angelscript::angelscript", "angelscript::angelscript", {plain = true})
  39. end
  40. local configs = {}
  41. table.insert(configs, "-Dasbind_build_ext=" .. (package:config("ext") and "ON" or "OFF"))
  42. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  43. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  44. import("package.tools.cmake").install(package, configs)
  45. end)
  46. on_test(function (package)
  47. if package:config("ext") then
  48. assert(package:check_cxxsnippets({test = [[
  49. #include <asbind20/ext/stdstring.hpp>
  50. void test() {
  51. auto engine = asbind20::make_script_engine();
  52. asbind20::ext::configure_engine_for_ext_string(engine);
  53. }
  54. ]]}, {configs = {languages = "c++20"}}))
  55. end
  56. assert(package:check_cxxsnippets({test = [[
  57. #include <asbind20/asbind.hpp>
  58. void test() {
  59. auto engine = asbind20::make_script_engine();
  60. }
  61. ]]}, {configs = {languages = "c++20"}}))
  62. end)