xref: /aosp_15_r20/external/bazelbuild-rules_rust/.bazelrc (revision d4726bddaa87cc4778e7472feed243fa4b6c267f)
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
9common --enable_platform_specific_config
10
11# https://bazel.build/docs/windows#symlink
12startup --windows_enable_symlinks
13build:windows --enable_runfiles
14
15# Enable the only currently supported report type
16# https://bazel.build/reference/command-line-reference#flag--combined_report
17coverage --combined_report=lcov
18
19# Avoid fully cached builds reporting no coverage and failing CI
20# https://bazel.build/reference/command-line-reference#flag--experimental_fetch_all_coverage_outputs
21coverage --experimental_fetch_all_coverage_outputs
22
23# Required for some of the tests
24# https://bazel.build/reference/command-line-reference#flag--experimental_cc_shared_library
25common --experimental_cc_shared_library
26
27###############################################################################
28## Unique configuration groups
29###############################################################################
30
31# Enable use of the nightly toolchains.
32build:nightly --//rust/toolchain/channel=nightly
33
34# Enable rustfmt for all targets in the workspace
35build:rustfmt --aspects=//rust:defs.bzl%rustfmt_aspect
36build:rustfmt --output_groups=+rustfmt_checks
37
38# Enable clippy for all targets in the workspace
39build:clippy --aspects=//rust:defs.bzl%rust_clippy_aspect
40build:clippy --output_groups=+clippy_checks
41
42# Enable unpretty for all targets in the workspace
43build:unpretty --aspects=//rust:defs.bzl%rust_unpretty_aspect
44build:unpretty --output_groups=+rust_unpretty
45
46# `unpretty` requires the nightly toolchain. See tracking issue:
47# https://github.com/rust-lang/rust/issues/43364
48build:unpretty --config=nightly
49
50###############################################################################
51## Incompatibility flags
52###############################################################################
53
54# https://github.com/bazelbuild/bazel/issues/8195
55build --incompatible_disallow_empty_glob=true
56
57# https://github.com/bazelbuild/bazel/issues/12821
58build --nolegacy_external_runfiles
59
60# Required for cargo_build_script support before Bazel 7
61build --incompatible_merge_fixed_and_default_shell_env
62
63###############################################################################
64## Bzlmod
65###############################################################################
66
67# TODO: migrate all dependencies from WORKSPACE to MODULE.bazel
68# https://github.com/bazelbuild/rules_rust/issues/2181
69common --noenable_bzlmod
70
71# Disable the bzlmod lockfile, so we don't accidentally commit MODULE.bazel.lock
72common --lockfile_mode=off
73
74###############################################################################
75## Custom user flags
76##
77## This should always be the last thing in the `.bazelrc` file to ensure
78## consistent behavior when setting flags in that file as `.bazelrc` files are
79## evaluated top to bottom.
80###############################################################################
81
82try-import %workspace%/user.bazelrc
83