# See https://bazel.build/reference/command-line-reference for an explanation
# of flags, or ask zbarsky :)

common --test_output=errors

# Tell @apple_support and @rules_cc modules that we are not interested in
# their automatic non-hermetic toolchains. We use a fully hermetic @llvm
# toolchain.
common --repo_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1
common --repo_env=BAZEL_NO_APPLE_CPP_TOOLCHAIN=1

# Saner output naming when using platform transitions (like for release builds)
common --experimental_platform_in_output_dir

# Automatically apply `--config=windows` on Windows hosts.
common --enable_platform_specific_config

# Explicit choice of ABI is needed because rules_rs supports msvc/gnu/gnullvm.
# Rustc ships with msvc ABI and we must match it when compiling proc macros.
common:windows --host_platform=//platforms:local_windows_msvc

# Standard rust configuration to avoid passing libtool to build scripts that
# use cc-rs and expect ar.
# Can be removed once https://github.com/hermeticbuild/rules_rust/pull/24 lands.
common --@rules_cc//cc/toolchains/args/archiver_flags:use_libtool_on_macos=False

common --@llvm-project//llvm:enable_abi_breaking_checks

# Default opt flags undef NDEBUG, force it on so release builds have assertions.
common --copt=-DNDEBUG

common:release --compilation_mode=opt
common:release --copt=-g
common:release --features=thin_lto
common:release --strip=never
common:release --@rules_rust//rust/settings:codegen_units=1
common:release --@rules_rust//rust/settings:extra_rustc_flag=-Cdebuginfo=2
common:release --@rules_rust//rust/settings:extra_rustc_flag=-Cdwarf-version=5
common:release --@rules_rust//rust/settings:extra_rustc_flag=-Cstrip=none

# Bit of rules_rust magic that is required when the C linker drives the link.
# This should be smoothed over, see
# https://github.com/hermeticbuild/rules_rust/issues/27
common:release --@rules_rust//rust/settings:experimental_use_allocator_libraries_with_mangled_symbols

# Keep remote connections healthy.
common:remote --grpc_keepalive_time=10s
common:remote --remote_timeout=30
common:remote --experimental_remote_execution_keepalive

# Use BuildBuddy for all remote APIs.
common:remote --bes_results_url=https://app.buildbuddy.io/invocation/
common:remote --bes_backend=grpcs://remote.buildbuddy.io
common:remote --experimental_remote_downloader=grpcs://remote.buildbuddy.io
common:remote --remote_cache=grpcs://remote.buildbuddy.io
common:remote --remote_executor=grpcs://remote.buildbuddy.io

# Remote tests execute on Linux even when the Bazel client runs on Windows.
common:remote --action_env=PATH=/bin:/usr/bin

# Minimize network traffic
common:remote --remote_cache_compression
common:remote --remote_download_toplevel

# Keep remote backends fed
common:remote --noexperimental_throttle_remote_action_building
common:remote --jobs=800

# Tell Bazel how to build for our remote platform. Note that `--platforms`
# defaults to the host platform, so the 2nd line is needed to make sure that
# `bazel test` builds the right test binaries when host != exec.
common:remote --extra_execution_platforms=//bazel/toolchains:rbe_x86_64_linux
common:remote --platforms=@rules_rs//rs/platforms:x86_64-unknown-linux-gnu

# Allow users to specify repo-specific personal settings.
try-import %workspace%/.bazelrc.user
