fork/rules_rust
git clone https://git.julia.blue/fork/rules_rust
c3d71edd
main
1load ( "//rust:defs.bzl" , "rust_binary" , "rust_clippy" , "rust_library" ) 2load ( "//tools:tool_utils.bzl" , "aspect_repository" ) 3 4exports_files ( 5[ 6"rustfmt.toml" , 7"rustfmt_utils.bzl" , 8], 9visibility = [ "//visibility:public" ], 10) 11 12rust_library ( 13name = "rustfmt_lib" , 14srcs = glob ( 15include = [ "src/**/*.rs" ], 16exclude = [ 17"src/**/*main.rs" , 18"src/bin/**" , 19], 20), 21data = [ 22"//rust/settings:rustfmt.toml" , 23"//rust/toolchain:current_rustfmt_toolchain_for_target" , 24], 25edition = "2018" , 26rustc_env = { 27"RUSTFMT" : "$(rlocationpath //rust/toolchain:current_rustfmt_toolchain_for_target)" , 28"RUSTFMT_CONFIG" : "$(rlocationpath //rust/settings:rustfmt.toml)" , 29}, 30deps = [ 31"//tools/runfiles" , 32], 33) 34 35# Deprecated but present for compatibility. 36alias ( 37name = "rustfmt" , 38actual = ":target_aware_rustfmt" , 39deprecation = "Prefer //tools/upstream_wrapper:rustfmt" , 40visibility = [ "//visibility:public" ], 41) 42 43# This is a wrapper around the upstream rustfmt binary which is aware of targets, 44# and will try to do things like set the correct edition for files when formatting them based on their owning targets. 45rust_binary ( 46name = "target_aware_rustfmt" , 47srcs = [ 48"src/main.rs" , 49], 50data = [ 51"//rust/settings:rustfmt.toml" , 52], 53edition = "2018" , 54rustc_env = { 55"ASPECT_REPOSITORY" : aspect_repository (), 56"RUST_DEFAULT_EDITION" : "$(RUST_DEFAULT_EDITION)" , 57}, 58toolchains = [ "@rules_rust//rust/toolchain:current_rust_toolchain" ], 59visibility = [ "//visibility:public" ], 60deps = [ 61":rustfmt_lib" , 62"//util/label" , 63], 64) 65 66rust_binary ( 67name = "rustfmt_test" , 68srcs = [ 69"src/bin/test_main.rs" , 70], 71edition = "2018" , 72visibility = [ "//visibility:public" ], 73deps = [ 74":rustfmt_lib" , 75"//tools/runfiles" , 76], 77) 78 79rust_clippy ( 80name = "rustfmt_clippy" , 81testonly = True , 82visibility = [ "//visibility:private" ], 83deps = [ 84":target_aware_rustfmt" , 85], 86) 87 88# Deprecated but present for compatibility. 89alias ( 90name = "upstream_rustfmt" , 91actual = "//tools/upstream_wrapper:rustfmt" , 92deprecation = "Prefer //tools/upstream_wrapper:rustfmt" , 93visibility = [ "//visibility:public" ], 94)