# use `MODULE.bazel`
build --enable_bzlmod

# generic_clang from @llvm-raw//utils/bazel, but c++20 to match Google
build:generic_clang --repo_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1
build:generic_clang --cxxopt=-std=c++20 --host_cxxopt=-std=c++20 --repo_env=BAZEL_CXXOPTS=-std=c++20
build:generic_clang --copt=-Wall --host_copt=-Wall # not -Werror due to spurious warnings differences in Clang <16
build:generic_clang --cxxopt=-Wno-range-loop-analysis --host_cxxopt=-Wno-range-loop-analysis
build:generic_clang --copt=-Wno-deprecated --host_copt=-Wno-deprecated
# https://buildkite.com/bazel/crubit-presubmit/builds/289#018b0116-2039-4c89-b211-c0b25b7432f2/445-473
build:generic_clang --copt=-Wno-missing-braces --host_copt=-Wno-missing-braces

# enable linking against prebuilt LLVM with no RTTI
build:generic_clang --copt=-fno-rtti --host_copt=-fno-rtti

# Extra warnings for compatibility with strict clients (like Chromium),
# restricted to support/ libraries to avoid breaking other Crubit targets:
# TODO(lukasza): Also apply these warnings to the generated bindings.
# LINT.IfChange(extra_warnings)
build:generic_clang --per_file_copt=^support/.*@-Wenum-compare-conditional,-Wexit-time-destructors,-Wextra-semi,-Wglobal-constructors,-Wgnu,-Wheader-hygiene,-Wimplicit-int-conversion,-Wloop-analysis,-Wnullability-completeness,-Wshorten-64-to-32,-Wsign-compare,-Wsign-conversion,-Wtautological-unsigned-zero-compare,-Wunguarded-availability,-Wunique-object-duplication,-Wunreachable-code-aggressive
build:generic_clang --host_per_file_copt=^support/.*@-Wenum-compare-conditional,-Wexit-time-destructors,-Wextra-semi,-Wglobal-constructors,-Wgnu,-Wheader-hygiene,-Wimplicit-int-conversion,-Wloop-analysis,-Wnullability-completeness,-Wshorten-64-to-32,-Wsign-compare,-Wsign-conversion,-Wtautological-unsigned-zero-compare,-Wunguarded-availability,-Wunique-object-duplication,-Wunreachable-code-aggressive
# LINT.ThenChange(//depot/METADATA:extra_warnings)

build --config=generic_clang
build --@rules_rust//rust/toolchain/channel=nightly
build --@llvm-project//third-party:llvm_enable_lzma=false
build --@llvm-project//third-party:llvm_enable_zlib=false
build --@llvm-project//third-party:llvm_enable_zstd=false

# Directly invoke the Crubit aspects by name when running `build`, and get the generated files.
build:crubit-genfiles --aspects=//rs_bindings_from_cc/bazel_support:rust_bindings_from_cc_aspect.bzl%rust_bindings_from_cc_aspect,//cc_bindings_from_rs/bazel_support:cc_bindings_from_rust_rule.bzl%cc_bindings_from_rust_aspect --output_groups=out
