blob: 1721301553b7a92991be10d5827f2cf88dbc6ad5 [file] [log] [blame]
load("//rust:defs.bzl", "rust_binary", "rust_clippy", "rust_library")
load("//tools:tool_utils.bzl", "aspect_repository")
package(default_visibility = ["//visibility:public"])
exports_files([
"rustfmt.toml",
"rustfmt_utils.bzl",
])
rust_library(
name = "rustfmt_lib",
srcs = glob(
include = ["src/**/*.rs"],
exclude = [
"src/**/*main.rs",
"src/bin/**",
],
),
data = [
"//:rustfmt.toml",
"//rust/toolchain:current_rustfmt_files",
],
edition = "2018",
rustc_env = {
"RUSTFMT": "$(rootpath //rust/toolchain:current_rustfmt_files)",
"RUSTFMT_CONFIG": "$(rootpath //:rustfmt.toml)",
},
rustc_env_files = [
"@rules_rust//rust/private:rustfmt_workspace_name",
],
deps = [
"//tools/runfiles",
],
)
rust_binary(
name = "rustfmt",
srcs = [
"src/main.rs",
],
data = [
"//:rustfmt.toml",
],
edition = "2018",
rustc_env = {
"ASPECT_REPOSITORY": aspect_repository(),
"RUST_DEFAULT_EDITION": "$(RUST_DEFAULT_EDITION)",
},
toolchains = [
"@rules_rust//rust/toolchain:current_rust_toolchain",
],
deps = [
":rustfmt_lib",
"//util/label",
],
)
rust_binary(
name = "rustfmt_test",
srcs = [
"src/bin/test_main.rs",
],
edition = "2018",
deps = [
":rustfmt_lib",
"//tools/runfiles",
],
)
rust_clippy(
name = "rustfmt_clippy",
testonly = True,
visibility = ["//visibility:private"],
deps = [
":rustfmt",
],
)