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