diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7ed4f839..d2005568 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,6 +21,8 @@ jobs: sudo apt-get update -qq sudo apt-get install -qqq build-essential pkg-config python -m pip install scons + curl -LO https://downloads.tuxfamily.org/godotengine/3.2.3/Godot_v3.2.3-stable_linux_server.64.zip + unzip Godot_v3.2.3-stable_linux_server.64.zip - name: Build godot-cpp run: | @@ -35,7 +37,11 @@ jobs: - name: Build test GDNative library run: | - scons target=release platform=linux bits=64 -j $(nproc) -C test; + scons target=release platform=linux bits=64 -j $(nproc) -C test + + - name: Run test GDNative library + run: | + ./Godot_v3.2.3-stable_linux_server.64 --path test -s script.gd windows-msvc: name: Build (Windows, MSVC) @@ -117,6 +123,8 @@ jobs: - name: Install dependencies run: | python -m pip install scons + curl -LO https://downloads.tuxfamily.org/godotengine/3.2.3/Godot_v3.2.3-stable_osx.64.zip + unzip Godot_v3.2.3-stable_osx.64.zip - name: Build godot-cpp run: | @@ -131,7 +139,11 @@ jobs: - name: Build test GDNative library run: | - scons target=release platform=osx bits=64 -j $(sysctl -n hw.logicalcpu) -C test; + scons target=release platform=osx bits=64 -j $(sysctl -n hw.logicalcpu) -C test + + - name: Run test GDNative library + run: | + ./Godot.app/Contents/MacOS/Godot --path test -s script.gd static-checks: name: Static Checks (clang-format) diff --git a/test/SConstruct b/test/SConstruct index 62cabd21..2dd85d5a 100644 --- a/test/SConstruct +++ b/test/SConstruct @@ -26,7 +26,7 @@ opts.Add(EnumVariable('platform', "Compilation platform", host_platform, ['', 'w opts.Add(EnumVariable('p', "Compilation target, alias for 'platform'", host_platform, ['', 'windows', 'x11', 'linux', 'osx'])) opts.Add(EnumVariable('bits', 'Target platform bits', '64', ('32', '64'))) opts.Add(BoolVariable('use_llvm', "Use the LLVM / Clang compiler", 'no')) -opts.Add(PathVariable('target_path', 'The path where the lib is installed.', 'demo/bin/', PathVariable.PathAccept)) +opts.Add(PathVariable('target_path', 'The path where the lib is installed.', 'bin/', PathVariable.PathAccept)) opts.Add(PathVariable('target_name', 'The library name.', 'libgdexample', PathVariable.PathAccept)) # Local dependency paths, adapt them to your setup diff --git a/test/demo/.gitignore b/test/demo/.gitignore deleted file mode 100644 index d6b7ef32..00000000 --- a/test/demo/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/test/gdexample.gdnlib b/test/gdexample.gdnlib new file mode 100644 index 00000000..260b4eab --- /dev/null +++ b/test/gdexample.gdnlib @@ -0,0 +1,20 @@ +[general] + +singleton=false +load_once=true +symbol_prefix="godot_" +reloadable=false + +[entry] + +X11.64="res://bin/x11/libgdexample.so" +Server.64="res://bin/x11/libgdexample.so" +Windows.64="res://bin/win64/libgdexample.dll" +OSX.64="res://bin/osx/libgdexample.dylib" + +[dependencies] + +X11.64=[] +Server.64=[] +Windows.64=[] +OSX.64=[] diff --git a/test/gdexample.gdns b/test/gdexample.gdns new file mode 100644 index 00000000..a9d02d35 --- /dev/null +++ b/test/gdexample.gdns @@ -0,0 +1,9 @@ +[gd_resource type="NativeScript" load_steps=2 format=2] + +[ext_resource path="res://gdexample.gdnlib" type="GDNativeLibrary" id=1] + +[resource] + +resource_name = "gdexample" +class_name = "SimpleClass" +library = ExtResource( 1 ) diff --git a/test/project.godot b/test/project.godot new file mode 100644 index 00000000..c9e426ae --- /dev/null +++ b/test/project.godot @@ -0,0 +1,19 @@ +; Engine configuration file. +; It's best edited using the editor UI and not directly, +; since the parameters that go here are not all obvious. +; +; Format: +; [section] ; section goes between [] +; param=value ; assign values to parameters + +config_version=4 + +_global_script_classes=[ ] +_global_script_class_icons={ + +} + +[application] + +config/name="Test CI project" + diff --git a/test/script.gd b/test/script.gd new file mode 100644 index 00000000..d9b0fe10 --- /dev/null +++ b/test/script.gd @@ -0,0 +1,30 @@ + +extends MainLoop + +func _initialize(): + OS.exit_code = 1 + var native_script = load("res://gdexample.gdns") + print("Native Script ", native_script) + if native_script == null || !is_instance_valid(native_script): + return + print("Library ", native_script.library) + if native_script.library == null || !is_instance_valid(native_script.library): + return + var ref = native_script.new() + print("Reference ", ref) + if ref == null || !is_instance_valid(ref): + return + print("Reference name ", ref.name) + if ref.name != "SimpleClass": + return + print("Reference value ", ref.value) + if ref.value != 0: + return + print("Call method ", ref.method(1)) + if ref.method(1) != 1: + return + OS.exit_code = 0 + +func _idle(_delta): + return true + diff --git a/test/src/init.cpp b/test/src/init.cpp index 47d4fda3..3eedb056 100644 --- a/test/src/init.cpp +++ b/test/src/init.cpp @@ -10,7 +10,10 @@ public: SimpleClass() {} /** `_init` must exist as it is called by Godot. */ - void _init() {} + void _init() { + _name = String("SimpleClass"); + _value = 0; + } void test_void_method() { Godot::print("This is test"); @@ -30,10 +33,10 @@ public: * The line below is equivalent to the following GDScript export: * export var _name = "SimpleClass" **/ - register_property("base/name", &SimpleClass::_name, String("SimpleClass")); + register_property("name", &SimpleClass::_name, String("SimpleClass")); /** Alternatively, with getter and setter methods: */ - register_property("base/value", &SimpleClass::set_value, &SimpleClass::get_value, 0); + register_property("value", &SimpleClass::set_value, &SimpleClass::get_value, 0); /** Registering a signal: **/ register_signal("signal_name0"); // windows: error C2668: 'godot::register_signal': ambiguous call to overloaded function