xmake.lua 3.3 KB

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