2
0

xmake.lua 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. package("godotcpp4")
  2. set_homepage("https://godotengine.org/")
  3. set_description("C++ bindings for the Godot 4 script API")
  4. set_license("MIT")
  5. set_urls("https://github.com/godotengine/godot-cpp.git")
  6. add_versions("4.2", "d6e5286cc19bbd5b2c626207d3b01a8f145c0f76")
  7. add_versions("4.1", "32becf6a13681119ad63b6d7cc4e816c9a0cc86b")
  8. add_versions("4.0", "9d1c396c54fc3bdfcc7da4f3abcb52b14f6cce8f")
  9. add_deps("scons")
  10. add_includedirs("gen/include", "include")
  11. on_check("android", function (package)
  12. if package:version():ge("4.1") then
  13. raise("package(godotcpp4 >=4.1): only support ndk version 23.2.8568313")
  14. end
  15. end)
  16. on_load(function(package)
  17. assert(not package:is_arch(
  18. "mips",
  19. "mip64",
  20. "mips64",
  21. "mipsel",
  22. "mips64el",
  23. "s390x",
  24. "sh4"),
  25. "architecture " .. package:arch() .. " is not supported")
  26. if package:is_plat("windows") then
  27. package:add("defines", "TYPED_METHOD_BIND", "NOMINMAX")
  28. end
  29. if package:is_debug() then
  30. package:add("defines", "DEBUG_ENABLED", "DEBUG_METHODS_ENABLED")
  31. end
  32. end)
  33. on_install("linux", "windows|x64", "windows|x86", "macosx", "iphoneos", "android", function(package)
  34. if package:is_plat("windows") and package:version():eq("4.0.0") then
  35. io.replace("tools/targets.py", "/MD", "/" .. package:config("vs_runtime"), {plain = true})
  36. end
  37. local platform = package:plat()
  38. if package:is_plat("mingw") then
  39. platform = "windows"
  40. elseif package:is_plat("macosx") then
  41. platform = "macos"
  42. elseif package:is_plat("iphoneos") then
  43. platform = "ios"
  44. end
  45. local arch = package:arch()
  46. if package:is_arch("x86", "i386") then
  47. arch = "x86_32"
  48. elseif package:is_arch("arm64-v8a") then
  49. arch = "arm64"
  50. elseif package:is_arch("arm", "armeabi", "armeabi-v7a", "armv7s", "armv7k") then
  51. arch = "arm32"
  52. end
  53. local configs = {
  54. "target=" .. (package:is_debug() and "template_debug" or "template_release"),
  55. "platform=" .. platform,
  56. "arch=" .. arch,
  57. "debug_symbols=" .. (package:is_debug() and "yes" or "no")
  58. }
  59. if package:is_plat("windows") then
  60. table.insert(configs, "use_static_cpp=" .. (package:has_runtime("MT") and "yes" or "no"))
  61. end
  62. import("package.tools.scons").build(package, configs)
  63. os.vcp("bin/*." .. (package:is_plat("windows") and "lib" or "a"), package:installdir("lib"))
  64. os.vcp("include/godot_cpp", package:installdir("include"))
  65. os.vcp("gen/include/godot_cpp", path.join(package:installdir("gen"), "include", "godot_cpp"))
  66. os.vcp("gdextension/gdextension_interface.h", package:installdir("include"))
  67. end)
  68. on_test(function (package)
  69. local file = (package:version():eq("4.0") and "4.0.cpp" or "4.x.cpp")
  70. local code = io.readfile(path.join(os.scriptdir(), "test", file))
  71. assert(package:check_cxxsnippets({test = code}, {configs = {languages = "cxx17"}}))
  72. end)