Godot version
4.5.stable
godot-cpp version
godot-4.5-stable
System information
macOS 15.7.4
Issue description
Currently SCons does not provide a built-in command-line variable to customize the minimum macOS version compatibility when compiling Godot or building GDExtensions via godot-cpp. I suggest adding a custom SCons argument (e.g. macos_version=13.0) that automatically maps to the compiler and linker flags.
Steps to reproduce
if env.get("platform") == "macos" or ARGUMENTS.get("platform") == "macos" or env["PLATFORM"] == "darwin":
target_ver = env.get("macos_version", "13.0")
env["ENV"]["MACOSX_DEPLOYMENT_TARGET"] = target_ver
env.Append(CCFLAGS=[f"-mmacosx-version-min={target_ver}"])
env.Append(LINKFLAGS=[f"-mmacosx-version-min={target_ver}"])
Minimal reproduction project
Full SConstruct code:
#!/usr/bin/env python
import os
import sys
Add godot-cpp folder to sys.path, so that we can import local modules.
sys.path.append(Dir(".").srcnode().abspath)
EnsureSConsVersion(4, 0)
EnsurePythonVersion(3, 8)
try:
Import("env")
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="")
env.PrependENVPath("PATH", os.getenv("PATH"))
Custom options and profile flags.
customs = ["custom.py"]
try:
customs += Import("customs")
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)
opts.Add(
"macos_version",
"Minimum macOS deployment target version",
"13.0",
)
cpp_tool = Tool("godotcpp", toolpath=[Dir("tools").srcnode().abspath])
cpp_tool.options(opts, env)
opts.Update(env)
if env.get("platform") == "macos" or ARGUMENTS.get("platform") == "macos" or env["PLATFORM"] == "darwin":
target_ver = env.get("macos_version", "13.0")
env["ENV"]["MACOSX_DEPLOYMENT_TARGET"] = target_ver
env.Append(CCFLAGS=[f"-mmacosx-version-min={target_ver}"])
env.Append(LINKFLAGS=[f"-mmacosx-version-min={target_ver}"])
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")
Godot version
4.5.stable
godot-cpp version
godot-4.5-stable
System information
macOS 15.7.4
Issue description
Currently SCons does not provide a built-in command-line variable to customize the minimum macOS version compatibility when compiling Godot or building GDExtensions via godot-cpp. I suggest adding a custom SCons argument (e.g. macos_version=13.0) that automatically maps to the compiler and linker flags.
Steps to reproduce
if env.get("platform") == "macos" or ARGUMENTS.get("platform") == "macos" or env["PLATFORM"] == "darwin":
target_ver = env.get("macos_version", "13.0")
env["ENV"]["MACOSX_DEPLOYMENT_TARGET"] = target_ver
env.Append(CCFLAGS=[f"-mmacosx-version-min={target_ver}"])
env.Append(LINKFLAGS=[f"-mmacosx-version-min={target_ver}"])
Minimal reproduction project
Full SConstruct code:
#!/usr/bin/env python
import os
import sys
Add godot-cpp folder to sys.path, so that we can import local modules.
sys.path.append(Dir(".").srcnode().abspath)
EnsureSConsVersion(4, 0)
EnsurePythonVersion(3, 8)
try:
Import("env")
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="")
env.PrependENVPath("PATH", os.getenv("PATH"))
Custom options and profile flags.
customs = ["custom.py"]
try:
customs += Import("customs")
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)
opts.Add(
"macos_version",
"Minimum macOS deployment target version",
"13.0",
)
cpp_tool = Tool("godotcpp", toolpath=[Dir("tools").srcnode().abspath])
cpp_tool.options(opts, env)
opts.Update(env)
if env.get("platform") == "macos" or ARGUMENTS.get("platform") == "macos" or env["PLATFORM"] == "darwin":
target_ver = env.get("macos_version", "13.0")
env["ENV"]["MACOSX_DEPLOYMENT_TARGET"] = target_ver
env.Append(CCFLAGS=[f"-mmacosx-version-min={target_ver}"])
env.Append(LINKFLAGS=[f"-mmacosx-version-min={target_ver}"])
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")