From dd8e9d429668f98e0f3537c09b241fdeadaeafbb Mon Sep 17 00:00:00 2001 From: "Aidan C. Mullen" Date: Wed, 5 Mar 2025 00:10:19 -0500 Subject: [PATCH] Add base files for bindings Add base files for C++ and D that will interface with the existing C integration. --- .gitignore | 24 ++++++++++++++++++++++++ README | 8 ++++++++ build.sh | 5 +++++ dub.sdl | 12 ++++++++++++ dub.selections.json | 7 +++++++ engine/bin/libsb.gdextension | 10 ++++++++++ engine/title.tscn | 2 +- src/init/bind.d | 6 ++++++ src/init/cpp/bind.cpp | 1 + 9 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 dub.sdl create mode 100644 dub.selections.json create mode 100644 engine/bin/libsb.gdextension create mode 100644 src/init/bind.d create mode 100644 src/init/cpp/bind.cpp diff --git a/.gitignore b/.gitignore index 7594d75..e42dbe1 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,9 @@ !build.sh !CHANGELOG !configure.ac +!dub.sdl +!dub.selections.json +!extension_api.json !LICENSE !Makefile.am !README @@ -39,6 +42,7 @@ /engine/bin/* !/engine/bin/librtr.gdextension +!/engine/bin/libsb.gdextension # /engine/img !/engine/img/ @@ -56,6 +60,26 @@ !/src/main.gdextension !/src/main.h +# /src/init +!/src/init +/src/init/* + +!/src/init/bind.d + +# /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/bind.d + +!/src/init/d + # /res !/res/ /res/* diff --git a/README b/README index 603071a..f7354d2 100755 --- a/README +++ b/README @@ -24,6 +24,10 @@ Build - Git - GNU Autotools - UNIX Shell + - GCC (with G++) + - LDC + - DUB + - Tubolent W2C2 (optional; testing only) 1.) Install the dependencies listed above. @@ -35,6 +39,10 @@ Build 3.) Run "build.sh" within a UNIX shell. + Using this configuration, the project will be compatible with all major +operating systems and WebAssembly, which can be useful for transpiling and +new platform testing. + Project organized in conformance to the Straightforward C Project Standard 5 (SCPS5). diff --git a/build.sh b/build.sh index 70066d6..f2544b7 100644 --- a/build.sh +++ b/build.sh @@ -2,6 +2,11 @@ # Build Script +# Prepare to Build Project + +mkdir ./bld +mkdir ./bld/out + # Run Autotools libtoolize aclocal diff --git a/dub.sdl b/dub.sdl new file mode 100644 index 0000000..2e0149d --- /dev/null +++ b/dub.sdl @@ -0,0 +1,12 @@ +name "spruce-basin" +description "Source material." +authors "AUTHORS" +copyright "Copyright © 2025, AUTHORS" +license "proprietary" +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" +} diff --git a/dub.selections.json b/dub.selections.json new file mode 100644 index 0000000..8c8874a --- /dev/null +++ b/dub.selections.json @@ -0,0 +1,7 @@ +{ + "fileVersion": 1, + "versions": { + "godot-dlang": "~master", + "utf_bc": "0.2.1" + } +} diff --git a/engine/bin/libsb.gdextension b/engine/bin/libsb.gdextension new file mode 100644 index 0000000..e788d61 --- /dev/null +++ b/engine/bin/libsb.gdextension @@ -0,0 +1,10 @@ +[configuration] + +entry_symbol = "Godot-DLang" +compatibility_minimum = "4.4" + +[libraries] + +linux.64 = "bind.so" +darwin.64 = "bind.dylib" +windows.64 = "bind.dll" diff --git a/engine/title.tscn b/engine/title.tscn index 4ec2a36..f31edbf 100644 --- a/engine/title.tscn +++ b/engine/title.tscn @@ -106,7 +106,7 @@ text = "To-Do: - Use C API to implement interactive interface; this API is available via GDExtension, which has bindings available for an extended selection of languages, which may all interact with each other via this API. - Components that require speed, such as procedural generation and most core logic, should be implemented in C99/C++11; these libraries may then -be called from a more expressive language, such as Tim Apple's Swift. +be called from a more expressive language, such as D or a WASM object. - These issues will be migrated to the Forgejo instance. - Button for copyright notices in bottom-left corner." diff --git a/src/init/bind.d b/src/init/bind.d new file mode 100644 index 0000000..7835b7e --- /dev/null +++ b/src/init/bind.d @@ -0,0 +1,6 @@ +import std; + +void main() +{ + printf("Start."); +} diff --git a/src/init/cpp/bind.cpp b/src/init/cpp/bind.cpp new file mode 100644 index 0000000..8d1c8b6 --- /dev/null +++ b/src/init/cpp/bind.cpp @@ -0,0 +1 @@ +