|
| 1 | +############################################################################### |
| 2 | +## Bazel Configuration Flags |
| 3 | +## |
| 4 | +## `.bazelrc` is a Bazel configuration file. |
| 5 | +## https://bazel.build/docs/best-practices#bazelrc-file |
| 6 | +############################################################################### |
| 7 | + |
| 8 | +# https://bazel.build/reference/command-line-reference#flag--enable_platform_specific_config |
| 9 | +common --enable_platform_specific_config |
| 10 | + |
| 11 | +# Enable the only currently supported report type |
| 12 | +# https://bazel.build/reference/command-line-reference#flag--combined_report |
| 13 | +coverage --combined_report=lcov |
| 14 | + |
| 15 | +# Avoid fully cached builds reporting no coverage and failing CI |
| 16 | +# https://bazel.build/reference/command-line-reference#flag--experimental_fetch_all_coverage_outputs |
| 17 | +coverage --experimental_fetch_all_coverage_outputs |
| 18 | + |
| 19 | +# Disable network access in the sandbox by default. |
| 20 | +build --sandbox_default_allow_network=false |
| 21 | + |
| 22 | +# Do not use the host detected python toolchain. Always use one explicitly |
| 23 | +# registered in the WORKSPACE. |
| 24 | +common --repo_env=BAZEL_DO_NOT_DETECT_PYTHON_TOOLCHAIN=1 |
| 25 | + |
| 26 | +# # Enable rustfmt for all targets in the workspace |
| 27 | +build --aspects=@rules_rust//rust:defs.bzl%rustfmt_aspect |
| 28 | +build:rustfmt --output_groups=+rustfmt_checks |
| 29 | +build:no_rustfmt --output_groups=-rustfmt_checks |
| 30 | + |
| 31 | +# Enable clippy for all targets in the workspace |
| 32 | +build --aspects=@rules_rust//rust:defs.bzl%rust_clippy_aspect |
| 33 | +build:clippy --output_groups=+clippy_checks |
| 34 | +build:no_clippy --output_groups=-clippy_checks |
| 35 | + |
| 36 | +# Enable unpretty for all targets in the workspace |
| 37 | +build:unpretty --aspects=@rules_rust//rust:defs.bzl%rust_unpretty_aspect |
| 38 | +build:unpretty --output_groups=+rust_unpretty |
| 39 | + |
| 40 | +# `unpretty` requires the nightly toolchain. See tracking issue: |
| 41 | +# https://github.com/rust-lang/rust/issues/43364 |
| 42 | +build:unpretty --config=nightly |
| 43 | + |
| 44 | +# Convenience configs for enabling linting and formatting |
| 45 | +build:strict --config=rustfmt |
| 46 | +build:strict --config=clippy |
| 47 | +build:no_strict --config=no_rustfmt |
| 48 | +build:no_strict --config=no_clippy |
| 49 | + |
| 50 | +# When running test enable all linters and formatters |
| 51 | +test --config=strict |
| 52 | + |
| 53 | +############################################################################### |
| 54 | +## Incompatibility flags |
| 55 | +############################################################################### |
| 56 | + |
| 57 | +# https://github.com/bazelbuild/bazel/issues/8195 |
| 58 | +build --incompatible_disallow_empty_glob=true |
| 59 | + |
| 60 | +# https://github.com/bazelbuild/bazel/issues/12821 |
| 61 | +build --nolegacy_external_runfiles |
| 62 | + |
| 63 | +# Required for cargo_build_script support before Bazel 7 |
| 64 | +build --incompatible_merge_fixed_and_default_shell_env |
| 65 | + |
| 66 | +# Disable legacy __init__.py behavior which is known to conflict with |
| 67 | +# modern python versions (3.9+) |
| 68 | +build --incompatible_default_to_explicit_init_py |
| 69 | + |
| 70 | +############################################################################### |
| 71 | +## Bzlmod |
| 72 | +############################################################################### |
| 73 | + |
| 74 | +# A configuration for disabling bzlmod. |
| 75 | +common:no-bzlmod --noenable_bzlmod --enable_workspace |
| 76 | + |
| 77 | +# Disable the bzlmod lockfile, so we don't accidentally commit MODULE.bazel.lock |
| 78 | +common --lockfile_mode=off |
| 79 | + |
| 80 | +# Allow bazel configuration flags to locate the core rules to avoid adding local |
| 81 | +# override paths to the `MODULE.bazel` file and breaking downstream consumers. |
| 82 | +common --override_module=rules_rust=../../ |
| 83 | + |
| 84 | +############################################################################### |
| 85 | +## Custom user flags |
| 86 | +## |
| 87 | +## This should always be the last thing in the `.bazelrc` file to ensure |
| 88 | +## consistent behavior when setting flags in that file as `.bazelrc` files are |
| 89 | +## evaluated top to bottom. |
| 90 | +############################################################################### |
| 91 | + |
| 92 | +try-import %workspace%/user.bazelrc |
0 commit comments