1load("@bazel_skylib//:bzl_library.bzl", "bzl_library") 2load("@bazel_skylib//rules:common_settings.bzl", "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) 17 18exports_files([ 19 "LICENSE", 20 "MODULE.bazel", 21]) 22 23bzl_library( 24 name = "bzl_lib", 25 srcs = [ 26 ":version.bzl", 27 ], 28 visibility = ["//visibility:public"], 29) 30 31# This setting may be changed from the command line to generate machine readable errors. 32error_format( 33 name = "error_format", 34 build_setting_default = "human", 35 visibility = ["//visibility:public"], 36) 37 38# This setting may be changed from the command line to generate rustc diagnostics. 39rustc_output_diagnostics( 40 name = "rustc_output_diagnostics", 41 build_setting_default = False, 42 visibility = ["//visibility:public"], 43) 44 45# This setting may be used to pass extra options to clippy from the command line. 46# It applies across all targets. 47clippy_flags( 48 name = "clippy_flags", 49 build_setting_default = [], 50 visibility = ["//visibility:public"], 51) 52 53clippy_flag( 54 name = "clippy_flag", 55 build_setting_default = "", 56 visibility = ["//visibility:public"], 57) 58 59# This setting may be used to pass extra options to rustc from the command line 60# in non-exec configuration. 61# It applies across all targets whereas the rustc_flags option on targets applies only 62# to that target. This can be useful for passing build-wide options such as LTO. 63extra_rustc_flags( 64 name = "extra_rustc_flags", 65 build_setting_default = [], 66 visibility = ["//visibility:public"], 67) 68 69extra_rustc_flag( 70 name = "extra_rustc_flag", 71 build_setting_default = "", 72 visibility = ["//visibility:public"], 73) 74 75# This setting may be used to pass extra options to rustc from the command line 76# in exec configuration. 77# It applies across all targets whereas the rustc_flags option on targets applies only 78# to that target. This can be useful for passing build-wide options such as LTO. 79extra_exec_rustc_flags( 80 name = "extra_exec_rustc_flags", 81 build_setting_default = [], 82 visibility = ["//visibility:public"], 83) 84 85extra_exec_rustc_flag( 86 name = "extra_exec_rustc_flag", 87 build_setting_default = "", 88 visibility = ["//visibility:public"], 89) 90 91per_crate_rustc_flag( 92 name = "experimental_per_crate_rustc_flag", 93 build_setting_default = "", 94 visibility = ["//visibility:public"], 95) 96 97# This setting is used by the clippy rules. See https://bazelbuild.github.io/rules_rust/rust_clippy.html 98label_flag( 99 name = "clippy.toml", 100 build_setting_default = "//tools/clippy:clippy.toml", 101 visibility = ["//visibility:public"], 102) 103 104# This setting is used by the rustfmt rules. See https://bazelbuild.github.io/rules_rust/rust_fmt.html 105label_flag( 106 name = "rustfmt.toml", 107 build_setting_default = "//tools/rustfmt:rustfmt.toml", 108 visibility = ["//visibility:public"], 109) 110 111alias( 112 name = "rustfmt", 113 actual = "//tools/rustfmt:target_aware_rustfmt", 114 visibility = ["//visibility:public"], 115) 116 117capture_clippy_output( 118 name = "capture_clippy_output", 119 build_setting_default = False, 120 visibility = ["//visibility:public"], 121) 122 123# This setting may be used to enable builds without the standard library. 124# Currently only no_std + alloc is supported, which can be enabled with setting the value to "alloc". 125# In the future we could add support for additional modes, e.g "core", "alloc,collections". 126string_flag( 127 name = "no_std", 128 build_setting_default = "off", 129 values = [ 130 "alloc", 131 "off", 132 ], 133 visibility = ["//visibility:public"], 134) 135 136# A hack target to allow as to only apply the no_std mode in target config. 137no_std( 138 name = "build_target_in_no_std", 139) 140 141# A config setting for setting conditional `cargo_features`, `deps`, based on the `:no_std` value. 142config_setting( 143 name = "is_no_std", 144 flag_values = { 145 ":build_target_in_no_std": "alloc", 146 }, 147 visibility = ["//visibility:public"], 148) 149