build --enable_platform_specific_config

# Build with C++17 and clang, enable absl for gtest to have stack traces.
build --config=clang --cxxopt=-std=c++17 --define absl=1

# For coverage builds, don't include tests tagged with "nocoverage"
coverage --config=coverage --test_tag_filters=-nocoverage
build:coverage --cxxopt=-DNDEBUG
build:coverage --action_env=BAZEL_USE_LLVM_NATIVE_COVERAGE=1
build:coverage --action_env=GCOV=llvm-profdata
build:coverage --action_env=BAZEL_LLVM_COV=llvm-cov
build:coverage --experimental_generate_llvm_lcov
build:coverage --collect_code_coverage
build:coverage --combined_report=lcov
build:coverage --instrumentation_filter="//src[:/]"

# Optionally build with C++20.
build:cpp20 --cxxopt=-std=c++20

# Fixes symbols when debugging on mac.
build:macos --features=oso_prefix_is_pwd

# Flags for libc++
build:libc++ --action_env=CXXFLAGS=-stdlib=libc++
build:libc++ --action_env=LDFLAGS=-stdlib=libc++
build:libc++ --action_env=BAZEL_CXXOPTS=-stdlib=libc++
build:libc++ --action_env=BAZEL_LINKLIBS=-lc++abi:-lc++
build:libc++ --define force_libcpp=enabled

# Common flags for Clang
build:clang --action_env=CC=clang
build:clang --action_env=CXX=clang++
build:clang --action_env=BAZEL_COMPILER=clang
build:clang --config=libc++

# Basic ASAN/UBSAN that works for gcc
build:asan --linkopt -ldl
build:asan --copt -fsanitize=address,undefined
build:asan --linkopt -fsanitize=address,undefined
build:asan --test_env=ASAN_SYMBOLIZER_PATH
# These require libubsan, which is not linked properly by bazel, so disable.
# See https://github.com/google/oss-fuzz/issues/713
build:asan --copt -fno-sanitize=vptr,function
build:asan --linkopt -fno-sanitize=vptr,function

# Define the --config=asan-libfuzzer configuration.
build:asan-libfuzzer --config=clang --config=cpp20
build:asan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine=@rules_fuzzing//fuzzing/engines:libfuzzer
build:asan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine_instrumentation=libfuzzer
build:asan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine_sanitizer=asan
