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