From 51c6e64a43444dff6e6842fd518e86dc08d00e59 Mon Sep 17 00:00:00 2001 From: Andrew Luchuk Date: Sun, 22 Mar 2026 21:28:44 -0400 Subject: [PATCH] Configure SConstruct to download redot-cpp repo in gdextension mode --- SConstruct | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/SConstruct b/SConstruct index f1a2929..206385d 100644 --- a/SConstruct +++ b/SConstruct @@ -2,8 +2,30 @@ import os import sys +import pathlib -env = SConscript("godot-cpp/SConstruct") + +redot_cpp_git = "https://github.com/speratus/redot-cpp" +redot_target_version = '26.1' +artifact_name = "libgdextension" + +p = pathlib.Path("redot-cpp") + +if not p.exists(): + print("Directory redot-cpp/ is missing. Cloning repository...") + import subprocess + result = subprocess.run( + ["git", "clone", "-b", redot_target_version, redot_cpp_git], + check=True + ) + if result.returncode != 0: + print("Cloning redot-cpp repository failed.") + Exit(1) + else: + print("Finished cloning redot-cpp repository.") + + +env = SConscript("redot-cpp/SConstruct") # For reference: # - CCFLAGS are compilation flags shared between C and C++ @@ -14,19 +36,19 @@ env = SConscript("godot-cpp/SConstruct") # - 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(CPPPATH=["src/"]) # Context-specific define for GDExtension env.Append(CPPDEFINES=["GD_EXTENSION_BUILD"]) -sources = Glob("src/*.cpp") +sources = Glob("*.cpp") if env["platform"] == "macos": library = env.SharedLibrary( "demo/bin/{}.{}.{}.framework/{}.{}.{}".format( - project_config.lib_name(), + artifact_name, env["platform"], env["target"], - project_config.lib_name(), + artifact_name, env["platform"], env["target"] ), @@ -35,17 +57,17 @@ if env["platform"] == "macos": elif env["platform"] == "ios": if env["ios_simulator"]: library = env.StaticLibrary( - "demo/bin/{}.{}.{}.simulator.a".format(project_config.lib_name(), env["platform"], env["target"]), + "demo/bin/{}.{}.{}.simulator.a".format(artifact_name, env["platform"], env["target"]), source=sources, ) else: library = env.StaticLibrary( - "demo/bin/{}.{}.{}.a".format(project_config.lib_name(), env["platform"], env["target"]), + "demo/bin/{}.{}.{}.a".format(artifact_name, env["platform"], env["target"]), source=sources, ) else: library = env.SharedLibrary( - "demo/bin/{}{}{}".format(project_config.lib_name(), env["suffix"], env["SHLIBSUFFIX"]), + "demo/bin/{}{}{}".format(artifact_name, env["suffix"], env["SHLIBSUFFIX"]), source=sources, )