Merge pull request #86964 from akien-mga/scons-fix-CCFLAGS-cmdline-overrides

SCons: Fix `CCFLAGS`, `LINKFLAGS`, etc. command line overrides
This commit is contained in:
Rémi Verschelde 2024-02-21 15:22:50 +01:00
commit 5502a82824
No known key found for this signature in database
GPG key ID: C3336907360768E1

View file

@ -259,13 +259,16 @@ opts.Add(BoolVariable("builtin_zlib", "Use the built-in zlib library", True))
opts.Add(BoolVariable("builtin_zstd", "Use the built-in Zstd library", True)) opts.Add(BoolVariable("builtin_zstd", "Use the built-in Zstd library", True))
# Compilation environment setup # Compilation environment setup
opts.Add("CXX", "C++ compiler") # CXX, CC, and LINK directly set the equivalent `env` values (which may still
opts.Add("CC", "C compiler") # be overridden for a specific platform), the lowercase ones are appended.
opts.Add("LINK", "Linker") opts.Add("CXX", "C++ compiler binary")
opts.Add("CCFLAGS", "Custom flags for both the C and C++ compilers") opts.Add("CC", "C compiler binary")
opts.Add("CFLAGS", "Custom flags for the C compiler") opts.Add("LINK", "Linker binary")
opts.Add("CXXFLAGS", "Custom flags for the C++ compiler") opts.Add("cppdefines", "Custom defines for the pre-processor")
opts.Add("LINKFLAGS", "Custom flags for the linker") 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")
# Update the environment to have all above options defined # Update the environment to have all above options defined
# in following code (especially platform and custom_modules). # in following code (especially platform and custom_modules).
@ -507,21 +510,11 @@ if selected_platform in platform_list:
env.extra_suffix += "." + env["extra_suffix"] env.extra_suffix += "." + env["extra_suffix"]
# Environment flags # Environment flags
CCFLAGS = env.get("CCFLAGS", "") env.Append(CPPDEFINES=env.get("cppdefines", "").split())
env["CCFLAGS"] = "" env.Append(CCFLAGS=env.get("ccflags", "").split())
env.Append(CCFLAGS=str(CCFLAGS).split()) env.Append(CXXFLAGS=env.get("cxxflags", "").split())
env.Append(CFLAGS=env.get("cflags", "").split())
CFLAGS = env.get("CFLAGS", "") env.Append(LINKFLAGS=env.get("linkflags", "").split())
env["CFLAGS"] = ""
env.Append(CFLAGS=str(CFLAGS).split())
CXXFLAGS = env.get("CXXFLAGS", "")
env["CXXFLAGS"] = ""
env.Append(CXXFLAGS=str(CXXFLAGS).split())
LINKFLAGS = env.get("LINKFLAGS", "")
env["LINKFLAGS"] = ""
env.Append(LINKFLAGS=str(LINKFLAGS).split())
# Feature build profile # Feature build profile
disabled_classes = [] disabled_classes = []