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