commit | a31490d9a832b955410fd00b66c9b98f96e292df | [log] [tgz] |
---|---|---|
author | David Tolnay <dtolnay@gmail.com> | Thu Jan 05 03:08:45 2023 -0800 |
committer | GitHub <noreply@github.com> | Thu Jan 05 11:08:45 2023 +0000 |
tree | b5d71136b9c86a661ef6ccc96ccb5d103acec265 | |
parent | 7ebad4d501e9a5873befcbf762349b1870ad44ed [diff] |
Make loads from @rules_rust//rust:defs.bzl come out on one line (#1753) At first I was confused why some of the generated files were coming out with loads formatted like this: https://github.com/bazelbuild/rules_rust/blob/4ef3d4aaa27569616d9d085b0b01b4f155c09675/crate_universe/3rdparty/crates/BUILD.anyhow-1.0.68.bazel#L9-L13 Surely this should be as follows? The wrapped line is even shorter than the unwrapped line. ```bzl load("@rules_rust//cargo:defs.bzl", "cargo_build_script") load("@rules_rust//rust:defs.bzl", "rust_library") ``` It turned out to be because crate_universe unconditionally generates _all_ the loads that might be needed: ```bzl load("@rules_rust//cargo:defs.bzl", "cargo_build_script") load( "@rules_rust//rust:defs.bzl", "rust_library", "rust_binary", "rust_proc_macro", ) ``` and then Buildifier deletes any that are unused, but without rewrapping any lines: ```bzl load("@rules_rust//cargo:defs.bzl", "cargo_build_script") load( "@rules_rust//rust:defs.bzl", "rust_library", ) ``` This PR tweaks crate_universe to generate only loads that are used, so that we retain control over how they are wrapped. After this PR, single loads get put on one line while multiple loads get put on multiple lines. https://github.com/bazelbuild/rules_rust/blob/e987f2041df8abed1897ab3684a7af3158adee34/crate_universe/3rdparty/crates/BUILD.anyhow-1.0.68.bazel#L9-L10 https://github.com/bazelbuild/rules_rust/blob/e987f2041df8abed1897ab3684a7af3158adee34/bindgen/3rdparty/crates/BUILD.bindgen-0.60.1.bazel#L9-L14
This repository provides rules for building Rust projects with Bazel.
General discussions and announcements take place in the GitHub Discussions, but there are additional places where community members gather to discuss rules_rust
.
Please refer to the full documentation.