godot-cpp/SConstruct

61 lines
1.5 KiB
Python
Raw Normal View History

#!/usr/bin/env python
import os
EnsureSConsVersion(4, 0)
try:
Import("env")
2024-06-24 17:20:55 +00:00
except Exception:
# Default tools with no platform defaults to gnu toolchain.
# We apply platform specific toolchains via our custom tools.
env = Environment(tools=["default"], PLATFORM="")
2023-06-14 15:30:24 +00:00
env.PrependENVPath("PATH", os.getenv("PATH"))
# Custom options and profile flags.
customs = ["custom.py"]
try:
customs += Import("customs")
2024-06-24 17:20:55 +00:00
except Exception:
pass
profile = ARGUMENTS.get("profile", "")
if profile:
if os.path.isfile(profile):
customs.append(profile)
elif os.path.isfile(profile + ".py"):
customs.append(profile + ".py")
opts = Variables(customs, ARGUMENTS)
# Some environments do not have setdefault yet.
if "toolpath" not in env:
env["toolpath"] = []
# Needed because if we're called as SConscript, our site_tools are not automatically appended to toolpath.
env["toolpath"].append("site_scons/site_tools")
cpp_tool = Tool("godotcpp", toolpath=env["toolpath"])
cpp_tool.options(opts, env)
opts.Update(env)
Help(opts.GenerateHelpText(env))
# Detect and print a warning listing unknown SCons variables to ease troubleshooting.
unknown = opts.UnknownVariables()
if unknown:
print("WARNING: Unknown SCons variables were passed and will be ignored:")
for item in unknown.items():
print(" " + item[0] + "=" + item[1])
scons_cache_path = os.environ.get("SCONS_CACHE")
if scons_cache_path is not None:
CacheDir(scons_cache_path)
Decider("MD5")
cpp_tool.generate(env)
library = env.GodotCPP()
Return("env")