From 0ff9bfaea7e23ab00cd7677312ff0136f829e860 Mon Sep 17 00:00:00 2001 From: Andrew Luchuk Date: Tue, 17 Mar 2026 21:57:46 -0400 Subject: [PATCH] Add initial files for dual gdextension-module setup --- .gitignore | 2 ++ SConstruct | 54 ++++++++++++++++++++++++++++++++++++++++++++++ project_config.py | 12 +++++++++++ register_types.cpp | 5 +++++ register_types.h | 10 +++++++++ 5 files changed, 83 insertions(+) create mode 100644 .gitignore create mode 100644 SConstruct create mode 100644 project_config.py create mode 100644 register_types.cpp create mode 100644 register_types.h diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..483de3d --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.venv +.idea diff --git a/SConstruct b/SConstruct new file mode 100644 index 0000000..b8cdc85 --- /dev/null +++ b/SConstruct @@ -0,0 +1,54 @@ +#!/usr/bin/env python +import os +import sys + +import project_config + +constant_prefix = project_config.get_defines_friendly_name() + +env = SConscript("godot-cpp/SConstruct") + +# For reference: +# - CCFLAGS are compilation flags shared between C and C++ +# - CFLAGS are for C-specific compilation flags +# - CXXFLAGS are for C++-specific compilation flags +# - CPPFLAGS are for pre-processor flags +# - CPPDEFINES are for pre-processor defines +# - LINKFLAGS are for linking flags + +# tweak this if you want to use different folders, or more folders, to store your source code in. +env.Append(CPPPATH=["src/"]) + +env.Append(CPPDEFINES=[f"{constant_prefix}_GDEXTENSION"]) +sources = Glob("src/*.cpp") + +if env["platform"] == "macos": + library = env.SharedLibrary( + "demo/bin/{}.{}.{}.framework/libgdexample.{}.{}".format( + project_config.lib_name(), + env["platform"], + env["target"], + project_config.lib_name(), + env["platform"], + env["target"] + ), + source=sources, + ) +elif env["platform"] == "ios": + if env["ios_simulator"]: + library = env.StaticLibrary( + "demo/bin/{}.{}.{}.simulator.a".format(project_config.lib_name(), env["platform"], env["target"]), + source=sources, + ) + else: + library = env.StaticLibrary( + "demo/bin/{}.{}.{}.a".format(project_config.lib_name(), env["platform"], env["target"]), + source=sources, + ) +else: + library = env.SharedLibrary( + "demo/bin/{}{}{}".format(project_config.lib_name(), env["suffix"], env["SHLIBSUFFIX"]), + source=sources, + ) + +Default(library) diff --git a/project_config.py b/project_config.py new file mode 100644 index 0000000..ce6da69 --- /dev/null +++ b/project_config.py @@ -0,0 +1,12 @@ +PROJECT_NAME = "dual-gdextension-module" +PROJECT_VERSION = "0.1.0" + +def get_defines_friendly_name(): + global PROJECT_NAME + + friendly_name = PROJECT_NAME.replace("-", "_").upper() + + return friendly_name + +def lib_name(): + return "lib" + PROJECT_NAME.replace("-", "").lower() \ No newline at end of file diff --git a/register_types.cpp b/register_types.cpp new file mode 100644 index 0000000..68a3ff0 --- /dev/null +++ b/register_types.cpp @@ -0,0 +1,5 @@ +// +// Created by andrew on 3/17/26. +// + +#include "register_types.h" \ No newline at end of file diff --git a/register_types.h b/register_types.h new file mode 100644 index 0000000..409bc11 --- /dev/null +++ b/register_types.h @@ -0,0 +1,10 @@ +// +// Created by andrew on 3/17/26. +// + +#ifndef DUAL_GDEXTENSION_MODULE_TEMPLATE_REGISTER_TYPES_H +#define DUAL_GDEXTENSION_MODULE_TEMPLATE_REGISTER_TYPES_H + +#ifdef + +#endif //DUAL_GDEXTENSION_MODULE_TEMPLATE_REGISTER_TYPES_H \ No newline at end of file