fork/rules_rust
git clone https://git.julia.blue/fork/rules_rust
e61e6e12
cleanup
1load ( "@bazel_skylib//:bzl_library.bzl" , "bzl_library" ) 2load ( "@bazel_skylib//rules:common_settings.bzl" , "bool_flag" , "string_flag" ) 3load ( 4"//rust:defs.bzl" , 5"capture_clippy_output" , 6"clippy_flag" , 7"clippy_flags" , 8"error_format" , 9"extra_exec_rustc_flag" , 10"extra_exec_rustc_flags" , 11"extra_rustc_flag" , 12"extra_rustc_flags" , 13"no_std" , 14"per_crate_rustc_flag" , 15"rustc_output_diagnostics" , 16) 17load ( "//rust/private:unpretty.bzl" , "rust_unpretty_flag" ) 18load ( ":incompatible.bzl" , "incompatible_flag" ) 19 20exports_files ([ 21".clippy.toml" , 22".rustfmt.toml" , 23]) 24 25bzl_library ( 26name = "bzl_lib" , 27srcs = glob ([ "**/*.bzl" ]), 28visibility = [ "//visibility:public" ], 29) 30 31rust_unpretty_flag ( 32name = "unpretty" , 33build_setting_default = [ 34"ast-tree,expanded" , 35"ast-tree" , 36"expanded,hygiene" , 37"expanded,identified" , 38"expanded" , 39"hir-tree" , 40"hir,identified" , 41"hir,typed" , 42"hir" , 43"identified" , 44"mir-cfg" , 45"mir" , 46"normal" , 47], 48visibility = [ "//visibility:public" ], 49) 50 51# A flag controlling whether to rename first-party crates such that their names 52# encode the Bazel package and target name, instead of just the target name. 53# 54# First-party vs. third-party crates are identified using the value of 55# //settings:third_party_dir. 56bool_flag ( 57name = "rename_first_party_crates" , 58build_setting_default = False , 59visibility = [ "//visibility:public" ], 60) 61 62# A flag specifying the location of vendored third-party rust crates within this 63# repository that must not be renamed when `rename_first_party_crates` is enabled. 64# 65# Must be specified as a Bazel package, e.g. "//some/location/in/repo". 66string_flag ( 67name = "third_party_dir" , 68build_setting_default = "//third_party/rust" , 69visibility = [ "//visibility:public" ], 70) 71 72# A flag to control whether rust_library and rust_binary targets should 73# implicitly depend on the *real* import macro, or on a no-op target. 74bool_flag ( 75name = "use_real_import_macro" , 76build_setting_default = False , 77visibility = [ "//visibility:public" ], 78) 79 80# When set, this flag causes rustc to emit .rmeta files and use them for rlib -> rlib dependencies. 81# While this involves one extra (short) rustc invocation to build the rmeta file, 82# it allows library dependencies to be unlocked much sooner, increasing parallelism during compilation. 83bool_flag ( 84name = "pipelined_compilation" , 85build_setting_default = False , 86visibility = [ "//visibility:public" ], 87) 88 89# A flag to control whether to link rust_binary and rust_test targets using 90# cc_common.link instead of rustc. 91bool_flag ( 92name = "experimental_use_cc_common_link" , 93build_setting_default = False , 94visibility = [ "//visibility:public" ], 95) 96 97# A flag to indicate that a global allocator is in use when using --@rules_rust//rust/settings:experimental_use_cc_common_link 98# Users need to specify this flag because rustc generates different set of symbols at link time when a global allocator is in use. 99# When the linking is not done by rustc, the `rust_toolchain` itself provides the appropriate set of symbols. 100bool_flag ( 101name = "experimental_use_global_allocator" , 102build_setting_default = False , 103visibility = [ "//visibility:public" ], 104) 105 106# A flag to have coverage tooling added as `coverage_common.instrumented_files_info.metadata_files` instead of 107# reporting tools like `llvm-cov` and `llvm-profdata` as runfiles to each test. 108bool_flag ( 109name = "experimental_use_coverage_metadata_files" , 110build_setting_default = True , 111visibility = [ "//visibility:public" ], 112) 113 114# A flag to set rustc --sysroot flag to the sysroot generated by rust_toolchain. 115bool_flag ( 116name = "toolchain_generated_sysroot" , 117build_setting_default = True , 118visibility = [ "//visibility:public" ], 119) 120 121# A flag to put rust_test compilation outputs in the same directory as the rust_library compilation outputs. 122incompatible_flag ( 123name = "incompatible_change_rust_test_compilation_output_directory" , 124build_setting_default = False , 125issue = "https://github.com/bazelbuild/rules_rust/issues/2827" , 126visibility = [ "//visibility:public" ], 127) 128 129# A flag to control whether to link libstd dynamically. 130bool_flag ( 131name = "experimental_link_std_dylib" , 132build_setting_default = False , 133visibility = [ "//visibility:public" ], 134) 135 136# A flag to control whether the shell path from a shell toolchain (`@bazel_tools//tools/sh:toolchain_type`) 137# is embedded into the bootstrap process wrapper for the `.sh` file. 138bool_flag ( 139name = "experimental_use_sh_toolchain_for_bootstrap_process_wrapper" , 140build_setting_default = False , 141visibility = [ "//visibility:public" ], 142) 143 144# This setting is used by the clippy rules. See https://bazelbuild.github.io/rules_rust/rust_clippy.html 145label_flag ( 146name = "clippy.toml" , 147build_setting_default = ".clippy.toml" , 148visibility = [ "//visibility:public" ], 149) 150 151# This setting is used by the rustfmt rules. See https://bazelbuild.github.io/rules_rust/rust_fmt.html 152label_flag ( 153name = "rustfmt.toml" , 154build_setting_default = ".rustfmt.toml" , 155visibility = [ "//visibility:public" ], 156) 157 158capture_clippy_output ( 159name = "capture_clippy_output" , 160build_setting_default = False , 161visibility = [ "//visibility:public" ], 162) 163 164# This setting may be used to enable builds without the standard library. 165# Currently only no_std + alloc is supported, which can be enabled with setting the value to "alloc". 166# In the future we could add support for additional modes, e.g "core", "alloc,collections". 167string_flag ( 168name = "no_std" , 169build_setting_default = "off" , 170values = [ 171"alloc" , 172"off" , 173], 174visibility = [ "//visibility:public" ], 175) 176 177# A hack target to allow as to only apply the no_std mode in target config. 178no_std ( 179name = "build_target_in_no_std" , 180) 181 182# A config setting for setting conditional `cargo_features`, `deps`, based on the `:no_std` value. 183config_setting ( 184name = "is_no_std" , 185flag_values = { 186":build_target_in_no_std" : "alloc" , 187}, 188visibility = [ "//visibility:public" ], 189) 190 191# This setting may be changed from the command line to generate machine readable errors. 192error_format ( 193name = "error_format" , 194build_setting_default = "human" , 195visibility = [ "//visibility:public" ], 196) 197 198# This setting may be changed from the command line to generate rustc diagnostics. 199rustc_output_diagnostics ( 200name = "rustc_output_diagnostics" , 201build_setting_default = False , 202visibility = [ "//visibility:public" ], 203) 204 205# This setting may be used to pass extra options to clippy from the command line. 206# It applies across all targets. 207clippy_flags ( 208name = "clippy_flags" , 209build_setting_default = [], 210visibility = [ "//visibility:public" ], 211) 212 213clippy_flag ( 214name = "clippy_flag" , 215build_setting_default = [], 216visibility = [ "//visibility:public" ], 217) 218 219# This setting may be used to pass extra options to rustc from the command line 220# in non-exec configuration. 221# It applies across all targets whereas the rustc_flags option on targets applies only 222# to that target. This can be useful for passing build-wide options such as LTO. 223extra_rustc_flags ( 224name = "extra_rustc_flags" , 225build_setting_default = [], 226visibility = [ "//visibility:public" ], 227) 228 229extra_rustc_flag ( 230name = "extra_rustc_flag" , 231build_setting_default = [], 232visibility = [ "//visibility:public" ], 233) 234 235# This setting may be used to pass extra options to rustc from the command line 236# in exec configuration. 237# It applies across all targets whereas the rustc_flags option on targets applies only 238# to that target. This can be useful for passing build-wide options such as LTO. 239extra_exec_rustc_flags ( 240name = "extra_exec_rustc_flags" , 241build_setting_default = [], 242visibility = [ "//visibility:public" ], 243) 244 245extra_exec_rustc_flag ( 246name = "extra_exec_rustc_flag" , 247build_setting_default = [], 248visibility = [ "//visibility:public" ], 249) 250 251per_crate_rustc_flag ( 252name = "experimental_per_crate_rustc_flag" , 253build_setting_default = [], 254visibility = [ "//visibility:public" ], 255) 256 257# A flag to control whether to include data files in compile_data. 258incompatible_flag ( 259name = "incompatible_do_not_include_data_in_compile_data" , 260build_setting_default = True , 261issue = "https://github.com/bazelbuild/rules_rust/issues/2977" , 262visibility = [ "//visibility:public" ], 263)