turn into addon

main
Nathan Franke 4 years ago
parent 0f08efac2d
commit 4102ba4eb9
No known key found for this signature in database
GPG Key ID: 082B90CF10A5B648

8
.gitignore vendored

@ -1,5 +1,5 @@
# Binaries. # Binaries.
bin/ addons/example/bin/
# Objects. # Objects.
*.os *.os
@ -11,3 +11,9 @@ bin/
# MacOS # MacOS
.DS_Store/ .DS_Store/
# Editors
.vscode/
# Godot 4+ specific ignores
.godot/

@ -1 +1,3 @@
# gdextension example # gdextension
Self-contained gdextension template for Godot Engine 4.x

@ -9,14 +9,14 @@ sources = Glob("src/*.cpp")
if env["platform"] == "osx": if env["platform"] == "osx":
library = env.SharedLibrary( library = env.SharedLibrary(
"bin/libgdexample.{}.{}.framework/libgdexample.{}.{}".format( "addons/example/bin/libgdexample.{}.{}.framework/libgdexample.{}.{}".format(
env["platform"], env["target"], env["platform"], env["target"] env["platform"], env["target"], env["platform"], env["target"]
), ),
source=sources, source=sources,
) )
else: else:
library = env.SharedLibrary( library = env.SharedLibrary(
"bin/libgdexample.{}.{}.{}{}".format( "addons/example/bin/libgdexample.{}.{}.{}{}".format(
env["platform"], env["target"], env["arch_suffix"], env["SHLIBSUFFIX"] env["platform"], env["target"], env["arch_suffix"], env["SHLIBSUFFIX"]
), ),
source=sources, source=sources,

@ -0,0 +1,16 @@
[configuration]
entry_symbol = "example_library_init"
[libraries]
macos.debug = "bin/libgdexample.osx.debug.framework"
macos.release = "bin/libgdexample.osx.release.framework"
windows.debug.x86_64 = "bin/libgdexample.windows.debug.x86_64.dll"
windows.release.x86_64 = "bin/libgdexample.windows.release.x86_64.dll"
linux.debug.x86_64 = "bin/libgdexample.linux.debug.x86_64.so"
linux.release.x86_64 = "bin/libgdexample.linux.release.x86_64.so"
linux.debug.arm64 = "bin/libgdexample.linux.debug.arm64.so"
linux.release.arm64 = "bin/libgdexample.linux.release.arm64.so"
linux.debug.rv64 = "bin/libgdexample.linux.debug.rv64.so"
linux.release.rv64 = "bin/libgdexample.linux.release.rv64.so"

@ -0,0 +1,6 @@
extends Node
func _ready() -> void:
print("Hello GDScript!")
# TODO: Static https://github.com/godotengine/godot/issues/61963
Example.new().hello_extension()

@ -0,0 +1,6 @@
[gd_scene load_steps=2 format=3 uid="uid://p4prpbgep4um"]
[ext_resource type="Script" path="res://demo/demo.gd" id="1_6gvlp"]
[node name="Demo" type="Node"]
script = ExtResource( "1_6gvlp" )

@ -0,0 +1,15 @@
; 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=5
[application]
config/name="example"
run/main_scene="res://demo/demo.tscn"
config/features=PackedStringArray("4.0", "Vulkan Clustered")

@ -10,6 +10,7 @@ using namespace godot;
void Example::_bind_methods() void Example::_bind_methods()
{ {
// TODO: Static https://github.com/godotengine/godot/issues/61963
ClassDB::bind_method(D_METHOD("hello_extension"), &Example::hello_extension); ClassDB::bind_method(D_METHOD("hello_extension"), &Example::hello_extension);
} }

@ -27,3 +27,17 @@ void uninitialize_example_module(ModuleInitializationLevel p_level)
return; return;
} }
} }
extern "C"
{
GDNativeBool GDN_EXPORT example_library_init(const GDNativeInterface *p_interface, const GDNativeExtensionClassLibraryPtr p_library, GDNativeInitialization *r_initialization)
{
godot::GDExtensionBinding::InitObject init_obj(p_interface, p_library, r_initialization);
init_obj.register_initializer(initialize_example_module);
init_obj.register_terminator(uninitialize_example_module);
init_obj.set_minimum_library_initialization_level(MODULE_INITIALIZATION_LEVEL_SCENE);
return init_obj.init();
}
}

Loading…
Cancel
Save