Open ParkMyCar opened 2 weeks ago
Thanks for the review @illicitonion! Didn't get a chance to add tests (although I did test manually by using this in my project), will follow up with that!
Looks good, thanks! If we can get those tests in, let's get this merged! 🎉
Chatted about this previously in Slack. The goal with this PR is to make it easier to define and share lint configurations for your build.
Description
The PR adds two new rules,
rust_lint_group
andcargo_lints
. It also adds a "lints" attr torust_library
andrust_binary
rules that expects a newLintsInfo
provider.rust_lint_group
allows you to define Rust, Clippy, and Rustdoc lints in aBUILD
file.cargo_lints
automatically generates a set of lints by reading a crate'sCargo.toml
, and optionally the workspace's Cargo.toml for workspace inheritance.Then the rustc, clippy, and rustdoc actions are all updated to check for the
LintsInfo
provider and appends the correct arguments so the lints take effect.Design
Honestly this is my first large change to a set of Bazel rules, so I definitely could have done something wrong here!
The change is split into two commits, the first introduces
rust_lint_group
which IMO is relatively straight forward. Some attributes are defined on a rule which are then formatted into command line flags and passed around with a provider.The second commit adds
cargo_lints
and is much larger, a few things worth considering:repository_rule
or a regularrule
. While therepository_rule
maps well to a Cargo Workspace and you'd only need to define it once, not everyone uses workspaces and so I figured a regularrule
was more general.Cargo.toml
is done via a new Rust binary calledcargo_toml_info
. I tried to keep the external dependencies on this binary to a minimum, it only has one at the moment which iscargo_toml
and I based this change largely off of https://github.com/bazelbuild/rules_rust/pull/2772. I tried to make the tool general though so other Cargo metadata rules could use it in the future.Tests
There aren't any! I wasn't sure where the best place to start was, any guidance here is appreciated!