xmake.lua 3.3 KB

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