common --noenable_bzlmod

# --- C++ Toolchain & Compilation ---
# Force C++17 for Protobuf 31 / gRPC 1.74 compatibility
build --cxxopt='-std=c++17'
build --host_cxxopt='-std=c++17'
build --action_env=BAZEL_CXXOPTS="-std=c++17"

# --- Java Toolchain & Runtime (JDK 21) ---
build --java_language_version=21
build --java_runtime_version=remotejdk_21
build --javacopt="-Xep:ImpossibleNullComparison:OFF"

# --- Protobuf & gRPC ---
build --proto_toolchain_for_java="@com_google_protobuf//:java_toolchain"
build --define=grpc_no_ares=true
# To make proto_library rules to include source info in the descriptor
build --protocopt=--include_source_info
build --protocopt=--experimental_allow_proto3_optional

# --- Test Environment Fixes ---
test --jvmopt="-Djava.security.manager=allow"
test --jvmopt="--add-opens=java.base/java.lang=ALL-UNNAMED"
build --remote_download_toplevel

# --- Linux Specific Config ---
build:linux --sandbox_tmpfs_path=/tmp
common:linux --experimental_convenience_symlinks=ignore

# --- Performance & Analysis ---
# Bazel 6.4+: 'common' applies to all commands that support the flag
common --@aspect_rules_ts//ts:skipLibCheck=honor_tsconfig
