diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index 9560bb114b..f2efed5cb8 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -690,6 +690,13 @@ tasks: working_directory: examples/bzlmod/hello_world_no_cargo build_targets: - "//..." + compile_one_dependency: + name: --compile_one_dependency flag + platform: ubuntu2004 + build_flags: + - "--compile_one_dependency" + build_targets: + - "tools/rust_analyzer/main.rs" buildifier: version: latest diff --git a/rust/private/rust.bzl b/rust/private/rust.bzl index f77098e1ae..8a23228f7a 100644 --- a/rust/private/rust.bzl +++ b/rust/private/rust.bzl @@ -679,6 +679,10 @@ _common_attrs = { is the root of the crate to be passed to rustc to build this crate. """), allow_files = [".rs"], + # Allow use of --compile_one_dependency with rust targets. Support for this feature for + # non-builtin rulesets is undocumented outside of the bazel source: + # https://github.com/bazelbuild/bazel/blob/7.1.1/src/main/java/com/google/devtools/build/lib/packages/Attribute.java#L102 + flags = ["DIRECT_COMPILE_TIME_INPUT"], ), "stamp": _stamp_attribute( default_value = 0,