Files
redot-dual-module-gdextensi…/SConstruct

75 lines
2.1 KiB
Python

#!/usr/bin/env python
import os
import sys
import pathlib
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++
# - 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/"])
# Context-specific define for GDExtension
env.Append(CPPDEFINES=["GD_EXTENSION_BUILD"])
sources = Glob("*.cpp")
if env["platform"] == "macos":
library = env.SharedLibrary(
"demo/bin/{}.{}.{}.framework/{}.{}.{}".format(
artifact_name,
env["platform"],
env["target"],
artifact_name,
env["platform"],
env["target"]
),
source=sources,
)
elif env["platform"] == "ios":
if env["ios_simulator"]:
library = env.StaticLibrary(
"demo/bin/{}.{}.{}.simulator.a".format(artifact_name, env["platform"], env["target"]),
source=sources,
)
else:
library = env.StaticLibrary(
"demo/bin/{}.{}.{}.a".format(artifact_name, env["platform"], env["target"]),
source=sources,
)
else:
library = env.SharedLibrary(
"demo/bin/{}{}{}".format(artifact_name, env["suffix"], env["SHLIBSUFFIX"]),
source=sources,
)
Default(library)