xmake.lua 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. package("godotcpp")
  2. set_homepage("https://godotengine.org/")
  3. set_description("C++ bindings for the Godot script API")
  4. set_urls("https://github.com/godotengine/godot-cpp.git")
  5. add_versions("3.2", "77d41fa179e40560f1e264ed483638bf51713779")
  6. add_versions("3.3", "dfee6f0ca41863eacdd47bd3c1c4afa46cc97fa4")
  7. add_versions("3.4.0", "4efceefe138b2494e3c691e1dead1c60efb621b1")
  8. add_versions("3.4.3", "ced274fbe62c07dd9bb6791a77392f4bdc625152")
  9. add_versions("3.4.4", "f4f6fac4c784da8c973ade0dbc64a9d8400ee247")
  10. add_deps("scons")
  11. add_includedirs("include", "include/core", "include/gen")
  12. on_install("linux", "windows", "macosx", "mingw", "cygwin", "iphoneos", "android", "msys", function (package)
  13. local configs = {"generate_bindings=yes"}
  14. table.insert(configs, "bits=" .. ((package:is_arch("x64") or package:is_arch("x86_64")) and "64" or "32"))
  15. if package:is_plat("windows") then
  16. io.replace("SConstruct", "/MD", "/" .. package:config("vs_runtime"), {plain = true})
  17. end
  18. -- this fixes an error on ios and osx (https://godotengine.org/qa/65616/problems-compiling-gdnative-c-example-on-osx)
  19. if package:is_plat("macosx", "iphoneos") then
  20. io.replace("SConstruct", "-std=c++14", "-std=c++17", {plain = true})
  21. end
  22. -- fix to use correct ranlib, @see https://github.com/godotengine/godot-cpp/issues/510
  23. if package:is_plat("android") then
  24. io.replace("SConstruct",
  25. [[env['AR'] = toolchain + "/bin/" + arch_info['tool_path'] + "-ar"]],
  26. [[env['AR'] = toolchain + "/bin/" + arch_info['tool_path'] + "-ar"
  27. env['RANLIB'] = toolchain + "/bin/" + arch_info['tool_path'] + "-ranlib"]], {plain = true})
  28. end
  29. import("package.tools.scons").build(package, configs)
  30. os.cp("bin/*." .. (package:is_plat("windows") and "lib" or "a"), package:installdir("lib"))
  31. os.cp("include/core/*.hpp", package:installdir("include/core"))
  32. os.cp("include/gen/*.hpp", package:installdir("include/gen"))
  33. os.cp("godot-headers/android", package:installdir("include"))
  34. os.cp("godot-headers/arvr", package:installdir("include"))
  35. os.cp("godot-headers/gdnative", package:installdir("include"))
  36. os.cp("godot-headers/nativescript", package:installdir("include"))
  37. os.cp("godot-headers/net", package:installdir("include"))
  38. os.cp("godot-headers/pluginscript", package:installdir("include"))
  39. os.cp("godot-headers/videodecoder", package:installdir("include"))
  40. os.cp("godot-headers/*.h", package:installdir("include"))
  41. end)
  42. on_test(function (package)
  43. assert(package:check_cxxsnippets({test = [[
  44. #include <Godot.hpp>
  45. #include <Reference.hpp>
  46. using namespace godot;
  47. class SimpleClass : public Reference {
  48. GODOT_CLASS(SimpleClass, Reference);
  49. public:
  50. SimpleClass() { }
  51. void _init() { }
  52. Variant method(Variant arg) {
  53. Variant ret; ret = arg; return ret;
  54. }
  55. static void _register_methods() {
  56. register_method("method", &SimpleClass::method);
  57. }
  58. };
  59. extern "C" void GDN_EXPORT godot_gdnative_init(godot_gdnative_init_options *o) { godot::Godot::gdnative_init(o); }
  60. extern "C" void GDN_EXPORT godot_gdnative_terminate(godot_gdnative_terminate_options *o) { godot::Godot::gdnative_terminate(o); }
  61. extern "C" void GDN_EXPORT godot_nativescript_init(void *handle) {
  62. godot::Godot::nativescript_init(handle);
  63. godot::register_class<SimpleClass>();
  64. }
  65. ]]}, {configs = {languages = "cxx17"}}))
  66. end)