diff --git a/.gitignore b/.gitignore index 483de3d..849d389 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,48 @@ -.venv -.idea +# Compiled Object files +*.slo +*.lo +*.o +*.obj + +# Precompiled Headers +*.gch +*.pch + +# Compiled Dynamic libraries +*.so +*.dylib +*.dll + +# Fortran module files +*.mod +*.smod + +# Compiled Static libraries +*.lai +*.la +*.a +*.lib + +# Executables +*.exe +*.out +*.app + +# SCons +.sconsign.dblite +.sconf_temp/ +*.sconsign + +# IDEs +.idea/ +.vscode/ +*.swp +*.swo + +# Godot-specific +bin/ +gen/ +godot-cpp/ +demo/bin/ +demo/.godot/ +.venv/ diff --git a/SConstruct b/SConstruct index b8cdc85..5505a83 100644 --- a/SConstruct +++ b/SConstruct @@ -19,6 +19,8 @@ env = SConscript("godot-cpp/SConstruct") # tweak this if you want to use different folders, or more folders, to store your source code in. env.Append(CPPPATH=["src/"]) +# Context-specific define for GDExtension +env.Append(CPPDEFINES=["GD_EXTENSION_BUILD"]) env.Append(CPPDEFINES=[f"{constant_prefix}_GDEXTENSION"]) sources = Glob("src/*.cpp") diff --git a/SCsub b/SCsub new file mode 100644 index 0000000..30543b1 --- /dev/null +++ b/SCsub @@ -0,0 +1,16 @@ +#!/usr/bin/env python +import os + +Import("env") + +# Define the context constant for module build +env.Append(CPPDEFINES=["GODOT_MODULE_BUILD"]) + +# Sources to include in the module +module_sources = Glob("src/*.cpp") +module_sources += Glob("*.cpp") + +env.add_source_files(env.modules_sources, module_sources) + +# Include paths for the module +env.Append(CPPPATH=[Dir("."), Dir("src")]) diff --git a/register_types.cpp b/register_types.cpp index 68a3ff0..c6652d8 100644 --- a/register_types.cpp +++ b/register_types.cpp @@ -1,5 +1,46 @@ -// -// Created by andrew on 3/17/26. -// +#include "register_types.h" -#include "register_types.h" \ No newline at end of file +#ifdef GD_EXTENSION_BUILD +#include +#include +#include + +using namespace godot; + +void initialize_module(ModuleInitializationLevel p_level) { + if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) { + return; + } + + // Register classes here +} + +void uninitialize_module(ModuleInitializationLevel p_level) { + if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) { + return; + } +} + +extern "C" { +// Initialization. +GDExtensionBool GDE_EXPORT extension_init(GDExtensionInterfaceGetProcAddress p_get_proc_address, const GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization) { + godot::GDExtensionBinding::InitObject init_obj(p_get_proc_address, p_library, r_initialization); + + init_obj.register_initializer(initialize_module); + init_obj.register_terminator(uninitialize_module); + init_obj.set_minimum_library_initialization_level(MODULE_INITIALIZATION_LEVEL_SCENE); + + return init_obj.init(); +} +} + +#elif defined(GODOT_MODULE_BUILD) +#include "register_types.h" + +void register_types() { + // Register classes here +} + +void unregister_types() { +} +#endif diff --git a/register_types.h b/register_types.h index 409bc11..a8e62cf 100644 --- a/register_types.h +++ b/register_types.h @@ -1,10 +1,14 @@ -// -// Created by andrew on 3/17/26. -// +#ifndef REGISTER_TYPES_H +#define REGISTER_TYPES_H -#ifndef DUAL_GDEXTENSION_MODULE_TEMPLATE_REGISTER_TYPES_H -#define DUAL_GDEXTENSION_MODULE_TEMPLATE_REGISTER_TYPES_H +#ifdef GD_EXTENSION_BUILD +#include +using namespace godot; +#elif defined(GODOT_MODULE_BUILD) +#include "core/object/class_db.h" +#endif -#ifdef +void register_types(); +void unregister_types(); -#endif //DUAL_GDEXTENSION_MODULE_TEMPLATE_REGISTER_TYPES_H \ No newline at end of file +#endif // REGISTER_TYPES_H