diff --git a/.gitignore b/.gitignore index e42dbe1..8d5aef9 100644 --- a/.gitignore +++ b/.gitignore @@ -11,8 +11,6 @@ !build.sh !CHANGELOG !configure.ac -!dub.sdl -!dub.selections.json !extension_api.json !LICENSE !Makefile.am @@ -21,6 +19,21 @@ !/bin/main.gdextension +# /bld +!/bld/ +/bld/* + +# /bld/src +!/bld/src/ +/bld/src/* + +# /bld/src/d +!/bld/src/d/ +/bld/src/d/* + +!/bld/src/d/dub.sdl +!/bld/src/d/dub.selections.json + # /docs !/docs/ /docs/* @@ -64,19 +77,17 @@ !/src/init /src/init/* -!/src/init/bind.d - # /src/init/cpp -!/src/init/cpp +!/src/init/cpp/ /src/init/cpp/* !/src/init/cpp/bind.cpp # /src/init/d -!/src/init/d +!/src/init/d/ /src/init/d/* -/src/init/d/bind.d +!/src/init/d/bind.d !/src/init/d diff --git a/README b/README index f7354d2..0d58f4e 100755 --- a/README +++ b/README @@ -43,6 +43,17 @@ Build operating systems and WebAssembly, which can be useful for transpiling and new platform testing. +Quick Setup +----------- + + In a terminal run Godot with the "--dump-extension-api" flag; this will +generate the "extension_api.json" required by your installation. + Following this, run the following command: + + dub run godot-dlang:generator -- -j extension_api.json -o + + Refer to documentation for more information. + Project organized in conformance to the Straightforward C Project Standard 5 (SCPS5). diff --git a/dub.sdl b/bld/src/d/dub.sdl similarity index 78% rename from dub.sdl rename to bld/src/d/dub.sdl index 2e0149d..f69ba99 100644 --- a/dub.sdl +++ b/bld/src/d/dub.sdl @@ -7,6 +7,6 @@ dependency "godot-dlang" version="~master" configuration "spruce-basin" { targetType "dynamicLibrary" dflags "-dllimport=defaultLibsOnly" platform="windows-ldc2" - targetName "bld/out/spruce-basin" - mainSourceFile "src/init/bind.d" + targetName "../../obj/spruce-basin" + mainSourceFile "../../../src/init/bind.d" } diff --git a/dub.selections.json b/bld/src/d/dub.selections.json similarity index 100% rename from dub.selections.json rename to bld/src/d/dub.selections.json diff --git a/build.sh b/build.sh index f2544b7..b42c5c6 100644 --- a/build.sh +++ b/build.sh @@ -5,7 +5,7 @@ # Prepare to Build Project mkdir ./bld -mkdir ./bld/out +mkdir ./bld/obj # Run Autotools libtoolize diff --git a/engine/bin/librtr.gdextension b/engine/bin/librtr.gdextension deleted file mode 100644 index bedf954..0000000 --- a/engine/bin/librtr.gdextension +++ /dev/null @@ -1,8 +0,0 @@ -[configuration] -entry_symbol = "librtr_extension_init" -compatibility_minimum = "4.2" - -[libraries] -windows.x86_64 = "res://../src/.libs/librtr.dll" -macos = "res://../src/.libs/librtr.dylib" -linux.debug.x86_64 = "res://../src/.libs/librtr.so" diff --git a/engine/bin/libsb.gdextension b/engine/bin/libsb.gdextension index e788d61..2038d17 100644 --- a/engine/bin/libsb.gdextension +++ b/engine/bin/libsb.gdextension @@ -1,10 +1,13 @@ [configuration] -entry_symbol = "Godot-DLang" +entry_symbol = "libsb_init" compatibility_minimum = "4.4" [libraries] -linux.64 = "bind.so" -darwin.64 = "bind.dylib" -windows.64 = "bind.dll" +linux.amd64 = "res://../bld/obj/.libs/libbind.so" +linux.amd64 = "res://../bld/obj/.libs/libsb.so" +darwin.amd64 = "res://../bld/obj/.libs/libbind.dylib" +darwin.amd64 = "res://../bld/obj/.libs/libsb.dylib" +windows.amd64 = "res://../bld/obj/.libs/libbind.dll" +windows.amd64 = "res://../bld/obj/.libs/libsb.dll" diff --git a/src/init/bind.d b/src/init/bind.d deleted file mode 100644 index 7835b7e..0000000 --- a/src/init/bind.d +++ /dev/null @@ -1,6 +0,0 @@ -import std; - -void main() -{ - printf("Start."); -} diff --git a/src/init/d/bind.d b/src/init/d/bind.d new file mode 100644 index 0000000..33f4614 --- /dev/null +++ b/src/init/d/bind.d @@ -0,0 +1,30 @@ +import godot; +// import godot.api.script; // for GodotScript! +// import godot.api.register; // for GodotNativeLibrary +// import godot.string; // for gs! + +import godot.node; + +// minimal class example with _ready method that will be invoked on creation +class Greeter : GodotScript!Node { + @Property String name; + + // this method is a special godot entry point when object is added to the scene + @Method + void _ready() { + // 'gs' is a string wrapper that converts D string to godot string + // usually there is helper functions that takes regular D strings and do this for you + print(gs!"Hello ", name); + } +} + +// register classes, initialize and terminate D runtime, only one per plugin +mixin GodotNativeLibrary!( + // this is a name prefix of the plugin to be acessible inside godot + // it must match the prefix in .gdextension file: + // entry_symbol = "mydplugin_gdextension_entry" + "mydplugin", + + // here goes the list of classes you would like to expose in godot + Greeter, +);