Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manually specify build tools #21

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,32 @@ opts.Add(
map=architecture_aliases,
)
)
opts.Add(
BoolVariable(
key="platform_tools",
help="If true, auto detect platform build tools and override ones passed in via CC, CXX, RC, etc.",
default=False,
)
)

opts.Add("CXX", "C++ compiler binary")
opts.Add("CC", "C compiler binary")
opts.Add("LINK", "Linker binary")
opts.Add("AS", "Assembler binary")
opts.Add("AR", "Archiver binary")
opts.Add("RANLIB", "Ranlib binary")
opts.Add("RC", "Resource compiler binary")
# Set this to something like "${TEMPFILE('$AR rcs $TARGET $SOURCES','$ARCOMSTR')}" if you get errors related to a command being too long.
# This is a common error on Windows machines.
opts.Add("ARCOM", "Custom command used to generate an object file from an assembly-language source file.")
opts.Add("cppdefines", "Custom defines for the pre-processor")
opts.Add("ccflags", "Custom flags for both the C and C++ compilers")
opts.Add("cxxflags", "Custom flags for the C++ compiler")
opts.Add("cflags", "Custom flags for the C compiler")
opts.Add("linkflags", "Custom flags for the linker")
opts.Add("extra_suffix", "Custom extra suffix added to the base filename of all generated binary files.", "")
opts.Add(BoolVariable("use_asan", "Use address sanitizer (ASAN) in MSVC", False))
opts.Add("import_env_vars", "A comma-separated list of environment variables to copy from the outer environment.", "")

# Targets flags tool (optimizations, debug symbols)
target_tool = Tool("targets", toolpath=["godot-tools"])
Expand All @@ -126,6 +144,12 @@ target_tool.options(opts)
opts.Update(env)
Help(opts.GenerateHelpText(env))

# Copy custom environment variables if set.
if env["import_env_vars"]:
for env_var in str(env["import_env_vars"]).split(","):
if env_var in os.environ:
env["ENV"][env_var] = os.environ[env_var]

# Process CPU architecture argument.
if env["arch"] == "":
# No architecture specified. Default to arm64 if building for Android,
Expand Down
15 changes: 8 additions & 7 deletions godot-tools/macos.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ def generate(env):
print("Only universal, arm64, and x86_64 are supported on macOS. Exiting.")
Exit()

if sys.platform == "darwin":
# Use clang on macOS by default
env["CXX"] = "clang++"
env["CC"] = "clang"
else:
# Use osxcross
macos_osxcross.generate(env)
if env["platform_tools"]:
if sys.platform == "darwin":
# Use clang on macOS by default
env["CXX"] = "clang++"
env["CC"] = "clang"
else:
# Use osxcross
macos_osxcross.generate(env)

if env["arch"] == "universal":
env.Append(LINKFLAGS=["-arch", "x86_64", "-arch", "arm64"])
Expand Down
41 changes: 22 additions & 19 deletions godot-tools/windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,12 @@ def generate(env):

env["is_msvc"] = True

# MSVC, linker, and archiver.
msvc.generate(env)
env.Tool("msvc")
env.Tool("mslib")
env.Tool("mslink")
if env["platform_tools"]:
# MSVC, linker, and archiver.
msvc.generate(env)
env.Tool("msvc")
env.Tool("mslib")
env.Tool("mslink")

env.Append(CPPDEFINES=["TYPED_METHOD_BIND", "NOMINMAX"])
env.Append(CCFLAGS=["/EHsc", "/utf-8"])
Expand All @@ -58,13 +59,14 @@ def generate(env):
env.AppendUnique(CCFLAGS=["/MD"])
env.Append(LINKFLAGS=["/WX"])

if env["use_clang_cl"]:
if env["platform_tools"] and env["use_clang_cl"]:
env["CC"] = "clang-cl"
env["CXX"] = "clang-cl"

elif (sys.platform == "win32" or sys.platform == "msys") and not env["mingw_prefix"]:
env["use_mingw"] = True
mingw.generate(env)
if env["platform_tools"]:
mingw.generate(env)
env.Append(CPPDEFINES=["MINGW_ENABLED"])
# Don't want lib prefixes
env["IMPLIBPREFIX"] = ""
Expand All @@ -90,18 +92,19 @@ def generate(env):
elif env["arch"] == "x86_32":
prefix += "i686"

if env["use_llvm"]:
env["CXX"] = prefix + "-w64-mingw32-clang++"
env["CC"] = prefix + "-w64-mingw32-clang"
env["AR"] = prefix + "-w64-mingw32-ar"
env["RANLIB"] = prefix + "-w64-mingw32-ranlib"
env["LINK"] = prefix + "-w64-mingw32-clang"
else:
env["CXX"] = prefix + "-w64-mingw32-g++"
env["CC"] = prefix + "-w64-mingw32-gcc"
env["AR"] = prefix + "-w64-mingw32-gcc-ar"
env["RANLIB"] = prefix + "-w64-mingw32-ranlib"
env["LINK"] = prefix + "-w64-mingw32-g++"
if env["platform_tools"]:
if env["use_llvm"]:
env["CXX"] = prefix + "-w64-mingw32-clang++"
env["CC"] = prefix + "-w64-mingw32-clang"
env["AR"] = prefix + "-w64-mingw32-ar"
env["RANLIB"] = prefix + "-w64-mingw32-ranlib"
env["LINK"] = prefix + "-w64-mingw32-clang"
else:
env["CXX"] = prefix + "-w64-mingw32-g++"
env["CC"] = prefix + "-w64-mingw32-gcc"
env["AR"] = prefix + "-w64-mingw32-gcc-ar"
env["RANLIB"] = prefix + "-w64-mingw32-ranlib"
env["LINK"] = prefix + "-w64-mingw32-g++"

env.Append(CPPDEFINES=["MINGW_ENABLED"])
env.Append(CCFLAGS=["-O3", "-Wwrite-strings"])
Expand Down
Loading