# Bazel configuration for DDS project

# Skip Playwright browser tests on `bazel test //...` (network, Chromium, no-sandbox).
# Run e2e explicitly: bazel test --test_tag_filters=e2e //web:web_e2e_tests
# Run every test: bazel test --test_tag_filters= /...
test --test_tag_filters=-e2e

common --enable_platform_specific_config

# Platform-specific C++ standard flags
build:macos --cxxopt=-std=c++20
build:macos --host_cxxopt=-std=c++20
build:linux --cxxopt=-std=c++20
build:linux --host_cxxopt=-std=c++20
# Keep Windows C++ standard selection in CPPVARIABLES.bzl selects.
# Avoid global /std flags here so wasm transitions on Windows don't inherit MSVC opts.

# Performance optimization flags
build:opt --compilation_mode=opt

# AddressSanitizer configuration
# Usage:
#   Linux: bazel test --config=asan //path:target
#   macOS: bazel test --config=asan --config=asan_macos //path:target
build:asan --copt=-fsanitize=address
build:asan --linkopt=-fsanitize=address
build:asan --strip=never
build:asan --features=dbg
build:asan --compilation_mode=dbg
test:asan --test_timeout=120,300,900,3600

# GoogleTest headers can trigger conversion warnings on Clang; suppress them.
# Scoped to `build` (not `test`) so the suppression also applies to plain
# `bazel build` of test targets and tooling that compiles GoogleTest, not just
# `bazel test`. The `build` config is inherited by `test`, `run`, etc.
# On Linux, use -Wno-conversion for portability when the system compiler is GCC.
build:macos --cxxopt=-Wno-character-conversion
build:linux --cxxopt=-Wno-conversion
# macOS-specific AddressSanitizer runtime lookup configuration.
# The LLVM toolchain bundles the ASAN runtime. On macOS tests run from the
# runfiles tree, so use @loader_path-based rpaths that walk back to execroot
# and then into external/toolchains_llvm...
# Keep the clang major version in these paths aligned with darwin-aarch64
# in MODULE.bazel.
# Bazel test binaries live at different depths under bazel-out/.../bin.
# Provide a small set of distinct @loader_path traversals to reach
# execroot/_main/external from common test binary depths.
build:asan_macos --linkopt=-Wl,-rpath,@loader_path/../../../../../external/toolchains_llvm++llvm+llvm_toolchain_llvm/lib/clang/20/lib/darwin
build:asan_macos --linkopt=-Wl,-rpath,@loader_path/../../../../../../external/toolchains_llvm++llvm+llvm_toolchain_llvm/lib/clang/20/lib/darwin
build:asan_macos --linkopt=-Wl,-rpath,@loader_path/../../../../../../../external/toolchains_llvm++llvm+llvm_toolchain_llvm/lib/clang/20/lib/darwin
build:asan_macos --linkopt=-Wl,-rpath,@loader_path/../../../../../../../../external/toolchains_llvm++llvm+llvm_toolchain_llvm/lib/clang/20/lib/darwin

# ThreadSanitizer configuration
# Usage: bazel test --config=tsan //path:target
build:tsan --copt=-fsanitize=thread
build:tsan --linkopt=-fsanitize=thread
build:tsan --strip=never
build:tsan --features=dbg
build:tsan --compilation_mode=dbg
