Add use_asan build option

This commit is contained in:
Pedro J. Estébanez
2024-06-14 10:48:56 +02:00
parent 0af9607ba4
commit d61034bda2

View File

@@ -119,6 +119,7 @@ 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))
# Targets flags tool (optimizations, debug symbols)
target_tool = Tool("targets", toolpath=["godot-tools"])
@@ -191,6 +192,12 @@ if env["platform"] == "macos":
elif env["platform"] == "windows":
env.AppendUnique(CPPDEFINES=["WINVER=0x0603", "_WIN32_WINNT=0x0603"])
# Sanitizers.
if env.get("use_asan", False) and env.get("is_msvc", False):
env["extra_suffix"] += ".san"
env.Append(LINKFLAGS=["/INFERASANLIBS"])
env.Append(CCFLAGS=["/fsanitize=address"])
scons_cache_path = os.environ.get("SCONS_CACHE")
if scons_cache_path is not None: