SCons: Add CPPEXTPATH for external includes

This commit is contained in:
Thaddeus Crews
2025-04-01 13:57:43 -05:00
parent d52b84e472
commit f25fc34439
55 changed files with 141 additions and 290 deletions

View File

@@ -15,6 +15,7 @@ from types import ModuleType
from SCons import __version__ as scons_raw_version
from SCons.Builder import ListEmitter
from SCons.Util import CLVar
# Explicitly resolve the helper modules, this is done to avoid clash with
# modules of the same name that might be randomly added (e.g. someone adding
@@ -443,10 +444,19 @@ for tool in custom_tools:
env.Tool(tool)
# add default include paths
# Add default include paths.
env.Prepend(CPPPATH=["#"])
# Allow marking includes as external/system to avoid raising warnings.
env["_CCCOMCOM"] += " $_CPPEXTINCFLAGS"
env["CPPEXTPATH"] = CLVar("")
if env.scons_version < (4, 2):
env["_CPPEXTINCFLAGS"] = "${_concat(EXTINCPREFIX, CPPEXTPATH, EXTINCSUFFIX, __env__, RDirs, TARGET, SOURCE)}"
else:
env["_CPPEXTINCFLAGS"] = (
"${_concat(EXTINCPREFIX, CPPEXTPATH, EXTINCSUFFIX, __env__, RDirs, TARGET, SOURCE, affect_signature=False)}"
)
# configure ENV for platform
env.platform_exporters = platform_exporters
env.platform_apis = platform_apis
@@ -910,6 +920,17 @@ else: # GCC, Clang
if env["werror"]:
env.Append(CCFLAGS=["-Werror"])
# Configure external includes.
if env.msvc:
if cc_version_major < 16 or (cc_version_major == 16 and cc_version_minor < 10):
env.AppendUnique(CCFLAGS=["/experimental:external"])
env.AppendUnique(CCFLAGS=["/external:W0"])
env["EXTINCPREFIX"] = "/external:I"
env["EXTINCSUFFIX"] = ""
else:
env["EXTINCPREFIX"] = "-isystem "
env["EXTINCSUFFIX"] = ""
if hasattr(detect, "get_program_suffix"):
suffix = "." + detect.get_program_suffix()
else: