Explorar o código

Add godotcpp (#335)

* Add godotcpp

* Install scons when installing godotcpp

* Remove godotheaders

* Correctly set platform in godotcpp

* Add scons as dep for godotcpp

* Remove bsd support from godotcpp

* Only change arch of android and ios when needed

* Handle vs_runtime and android arch

* Fix for ios and osx platforms

* Do osx and ios fix only on those platforms

* Remove android support from godotcpp

* Remove platform handling code from godotcpp

* Use io.replace instead of io.gsub in godotcpp

* Add bits config to godotcpp
PucklaMotzer09 %!s(int64=4) %!d(string=hai) anos
pai
achega
a9982418fd
Modificáronse 2 ficheiros con 62 adicións e 22 borrados
  1. 62 0
      packages/g/godotcpp/xmake.lua
  2. 0 22
      packages/g/godotheaders/xmake.lua

+ 62 - 0
packages/g/godotcpp/xmake.lua

@@ -0,0 +1,62 @@
+package("godotcpp")
+
+    set_homepage("https://godotengine.org/")
+    set_description("C++ bindings for the Godot script API")
+
+    set_urls("https://github.com/godotengine/godot-cpp.git")
+    add_versions("3.2", "77d41fa179e40560f1e264ed483638bf51713779")
+
+    add_deps("scons")
+
+    add_includedirs("include", "include/core", "include/gen")
+
+    on_install("linux", "windows", "macosx", "mingw", "cygwin", "iphoneos", "msys", function (package)
+        local configs = {"generate_bindings=yes"}
+        table.insert(configs, "bits=" .. ((package:is_arch("x64") or package:is_arch("x86_64")) and "64" or "32"))
+        if package:is_plat("windows") then
+            io.replace("SConstruct", "/MD", "/" .. package:config("vs_runtime"), {plain = true})
+        end
+        -- this fixes an error on ios and osx (https://godotengine.org/qa/65616/problems-compiling-gdnative-c-example-on-osx)
+        if package:is_plat("macosx", "iphoneos") then
+            io.replace("SConstruct", "-std=c++14", "-std=c++17", {plain = true})
+        end
+
+        import("package.tools.scons").build(package, configs)
+        os.cp("bin/*." .. (package:is_plat("windows") and "lib" or "a"), package:installdir("lib"))
+        os.cp("include/core/*.hpp", package:installdir("include/core"))
+        os.cp("include/gen/*.hpp",  package:installdir("include/gen"))
+        os.cp("godot-headers/android",            package:installdir("include"))
+        os.cp("godot-headers/arvr",               package:installdir("include"))
+        os.cp("godot-headers/gdnative",           package:installdir("include"))
+        os.cp("godot-headers/nativescript",       package:installdir("include"))
+        os.cp("godot-headers/net",                package:installdir("include"))
+        os.cp("godot-headers/pluginscript",       package:installdir("include"))
+        os.cp("godot-headers/videodecoder",       package:installdir("include"))
+        os.cp("godot-headers/*.h",                package:installdir("include"))
+    end)
+
+    on_test(function (package)
+        assert(package:check_cxxsnippets({test = [[
+        #include <Godot.hpp>
+        #include <Reference.hpp>
+        using namespace godot;
+        class SimpleClass : public Reference {
+            GODOT_CLASS(SimpleClass, Reference);
+        public:
+            SimpleClass() { }
+            void _init() { }
+            Variant method(Variant arg) {
+                Variant ret; ret = arg; return ret;
+            }
+            static void _register_methods() {
+                register_method("method", &SimpleClass::method);
+            }
+        };
+        extern "C" void GDN_EXPORT godot_gdnative_init(godot_gdnative_init_options *o) { godot::Godot::gdnative_init(o); }
+        extern "C" void GDN_EXPORT godot_gdnative_terminate(godot_gdnative_terminate_options *o) { godot::Godot::gdnative_terminate(o); }
+        extern "C" void GDN_EXPORT godot_nativescript_init(void *handle) {
+            godot::Godot::nativescript_init(handle);
+            godot::register_class<SimpleClass>();
+        }
+        ]]}, {configs = {languages = "cxx17"}}))
+    end)

+ 0 - 22
packages/g/godotheaders/xmake.lua

@@ -1,22 +0,0 @@
-package("godotheaders")
-
-    set_homepage("https://godotengine.org")
-    set_description("Headers for the Godot API supplied by the GDNative module")
-
-    set_urls("https://github.com/godotengine/godot-headers/archive/godot-$(version)-stable.zip")
-    add_versions("3.2.3", "91815415a134ec061e1126a78d773bb13b28417f6dff34e02d54a38bf1b7e27d")
-
-    on_install(function (package)
-        os.cp("android",      package:installdir("include"))
-        os.cp("arvr",         package:installdir("include"))
-        os.cp("gdnative",     package:installdir("include"))
-        os.cp("nativescript", package:installdir("include"))
-        os.cp("net",          package:installdir("include"))
-        os.cp("pluginscript", package:installdir("include"))
-        os.cp("videodecoder", package:installdir("include"))
-    end)
-
-    on_test(function (package)
-        assert(package:has_cfuncs("godot_nativescript_register_class", {includes = "nativescript/godot_nativescript.h"}))
-        assert(package:has_cfuncs("godot_print",                       {includes = "gdnative/gdnative.h"}))
-    end)