chore: add TDD workflow, behavioral guidelines, and ASan support

Add deps/Sanitizers.cmake for AddressSanitizer support (ENABLE_ASAN).
Add TDD workflow and behavioral guidelines to AGENTS.md.
This commit is contained in:
2026-06-14 19:35:26 +02:00
parent 6227ddf5df
commit e9bdd3bff5
3 changed files with 113 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
# ==============================================================================
# Sanitizers
# ==============================================================================
# AddressSanitizer (ASan) support.
# Works with GCC/Clang on Linux and macOS, Clang on Windows (requires
# compiler-rt with sanitizers), and MSVC on Windows (/fsanitize=address).
#
# Usage: cmake -DENABLE_ASAN=ON ...
# ==============================================================================
option(ENABLE_ASAN "Build with AddressSanitizer" OFF)
if (ENABLE_ASAN)
if (ENABLE_COVERAGE)
message(FATAL_ERROR "ENABLE_ASAN and ENABLE_COVERAGE cannot be used together")
endif()
if (MSVC)
add_compile_options(/fsanitize=address)
message(STATUS "ASan: enabled (MSVC)")
elseif (CMAKE_C_COMPILER_ID MATCHES "GNU|Clang")
add_compile_options(-fsanitize=address -fno-omit-frame-pointer)
add_link_options(-fsanitize=address)
message(STATUS "ASan: enabled (${CMAKE_C_COMPILER_ID})")
else()
message(FATAL_ERROR "ENABLE_ASAN: unsupported compiler ${CMAKE_C_COMPILER_ID}")
endif()
endif()