Configure SConstruct to download redot-cpp repo in gdextension mode

This commit is contained in:
2026-03-22 21:28:44 -04:00
parent 495bfaaed9
commit 51c6e64a43

View File

@@ -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,
)