xref: /aosp_15_r20/external/bazel-skylib/docs/common_settings_doc.md (revision bcb5dc7965af6ee42bf2f21341a2ec00233a8c8a)
1*bcb5dc79SHONG Yifan<!-- Generated with Stardoc: http://skydoc.bazel.build -->
2*bcb5dc79SHONG Yifan
3*bcb5dc79SHONG YifanCommon build setting rules
4*bcb5dc79SHONG Yifan
5*bcb5dc79SHONG YifanThese rules return a BuildSettingInfo with the value of the build setting.
6*bcb5dc79SHONG YifanFor label-typed settings, use the native label_flag and label_setting rules.
7*bcb5dc79SHONG Yifan
8*bcb5dc79SHONG YifanMore documentation on how to use build settings at
9*bcb5dc79SHONG Yifanhttps://bazel.build/extending/config#user-defined-build-settings
10*bcb5dc79SHONG Yifan
11*bcb5dc79SHONG Yifan<a id="bool_flag"></a>
12*bcb5dc79SHONG Yifan
13*bcb5dc79SHONG Yifan## bool_flag
14*bcb5dc79SHONG Yifan
15*bcb5dc79SHONG Yifan<pre>
16*bcb5dc79SHONG Yifanbool_flag(<a href="#bool_flag-name">name</a>)
17*bcb5dc79SHONG Yifan</pre>
18*bcb5dc79SHONG Yifan
19*bcb5dc79SHONG YifanA bool-typed build setting that can be set on the command line
20*bcb5dc79SHONG Yifan
21*bcb5dc79SHONG Yifan**ATTRIBUTES**
22*bcb5dc79SHONG Yifan
23*bcb5dc79SHONG Yifan
24*bcb5dc79SHONG Yifan| Name  | Description | Type | Mandatory | Default |
25*bcb5dc79SHONG Yifan| :------------- | :------------- | :------------- | :------------- | :------------- |
26*bcb5dc79SHONG Yifan| <a id="bool_flag-name"></a>name |  A unique name for this target.   | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required |  |
27*bcb5dc79SHONG Yifan
28*bcb5dc79SHONG Yifan
29*bcb5dc79SHONG Yifan<a id="bool_setting"></a>
30*bcb5dc79SHONG Yifan
31*bcb5dc79SHONG Yifan## bool_setting
32*bcb5dc79SHONG Yifan
33*bcb5dc79SHONG Yifan<pre>
34*bcb5dc79SHONG Yifanbool_setting(<a href="#bool_setting-name">name</a>)
35*bcb5dc79SHONG Yifan</pre>
36*bcb5dc79SHONG Yifan
37*bcb5dc79SHONG YifanA bool-typed build setting that cannot be set on the command line
38*bcb5dc79SHONG Yifan
39*bcb5dc79SHONG Yifan**ATTRIBUTES**
40*bcb5dc79SHONG Yifan
41*bcb5dc79SHONG Yifan
42*bcb5dc79SHONG Yifan| Name  | Description | Type | Mandatory | Default |
43*bcb5dc79SHONG Yifan| :------------- | :------------- | :------------- | :------------- | :------------- |
44*bcb5dc79SHONG Yifan| <a id="bool_setting-name"></a>name |  A unique name for this target.   | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required |  |
45*bcb5dc79SHONG Yifan
46*bcb5dc79SHONG Yifan
47*bcb5dc79SHONG Yifan<a id="int_flag"></a>
48*bcb5dc79SHONG Yifan
49*bcb5dc79SHONG Yifan## int_flag
50*bcb5dc79SHONG Yifan
51*bcb5dc79SHONG Yifan<pre>
52*bcb5dc79SHONG Yifanint_flag(<a href="#int_flag-name">name</a>, <a href="#int_flag-make_variable">make_variable</a>)
53*bcb5dc79SHONG Yifan</pre>
54*bcb5dc79SHONG Yifan
55*bcb5dc79SHONG YifanAn int-typed build setting that can be set on the command line
56*bcb5dc79SHONG Yifan
57*bcb5dc79SHONG Yifan**ATTRIBUTES**
58*bcb5dc79SHONG Yifan
59*bcb5dc79SHONG Yifan
60*bcb5dc79SHONG Yifan| Name  | Description | Type | Mandatory | Default |
61*bcb5dc79SHONG Yifan| :------------- | :------------- | :------------- | :------------- | :------------- |
62*bcb5dc79SHONG Yifan| <a id="int_flag-name"></a>name |  A unique name for this target.   | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required |  |
63*bcb5dc79SHONG Yifan| <a id="int_flag-make_variable"></a>make_variable |  If set, the build setting's value will be available as a Make variable with this name in the attributes of rules that list this build setting in their 'toolchains' attribute.   | String | optional |  `""`  |
64*bcb5dc79SHONG Yifan
65*bcb5dc79SHONG Yifan
66*bcb5dc79SHONG Yifan<a id="int_setting"></a>
67*bcb5dc79SHONG Yifan
68*bcb5dc79SHONG Yifan## int_setting
69*bcb5dc79SHONG Yifan
70*bcb5dc79SHONG Yifan<pre>
71*bcb5dc79SHONG Yifanint_setting(<a href="#int_setting-name">name</a>, <a href="#int_setting-make_variable">make_variable</a>)
72*bcb5dc79SHONG Yifan</pre>
73*bcb5dc79SHONG Yifan
74*bcb5dc79SHONG YifanAn int-typed build setting that cannot be set on the command line
75*bcb5dc79SHONG Yifan
76*bcb5dc79SHONG Yifan**ATTRIBUTES**
77*bcb5dc79SHONG Yifan
78*bcb5dc79SHONG Yifan
79*bcb5dc79SHONG Yifan| Name  | Description | Type | Mandatory | Default |
80*bcb5dc79SHONG Yifan| :------------- | :------------- | :------------- | :------------- | :------------- |
81*bcb5dc79SHONG Yifan| <a id="int_setting-name"></a>name |  A unique name for this target.   | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required |  |
82*bcb5dc79SHONG Yifan| <a id="int_setting-make_variable"></a>make_variable |  If set, the build setting's value will be available as a Make variable with this name in the attributes of rules that list this build setting in their 'toolchains' attribute.   | String | optional |  `""`  |
83*bcb5dc79SHONG Yifan
84*bcb5dc79SHONG Yifan
85*bcb5dc79SHONG Yifan<a id="string_flag"></a>
86*bcb5dc79SHONG Yifan
87*bcb5dc79SHONG Yifan## string_flag
88*bcb5dc79SHONG Yifan
89*bcb5dc79SHONG Yifan<pre>
90*bcb5dc79SHONG Yifanstring_flag(<a href="#string_flag-name">name</a>, <a href="#string_flag-make_variable">make_variable</a>, <a href="#string_flag-values">values</a>)
91*bcb5dc79SHONG Yifan</pre>
92*bcb5dc79SHONG Yifan
93*bcb5dc79SHONG YifanA string-typed build setting that can be set on the command line
94*bcb5dc79SHONG Yifan
95*bcb5dc79SHONG Yifan**ATTRIBUTES**
96*bcb5dc79SHONG Yifan
97*bcb5dc79SHONG Yifan
98*bcb5dc79SHONG Yifan| Name  | Description | Type | Mandatory | Default |
99*bcb5dc79SHONG Yifan| :------------- | :------------- | :------------- | :------------- | :------------- |
100*bcb5dc79SHONG Yifan| <a id="string_flag-name"></a>name |  A unique name for this target.   | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required |  |
101*bcb5dc79SHONG Yifan| <a id="string_flag-make_variable"></a>make_variable |  If set, the build setting's value will be available as a Make variable with this name in the attributes of rules that list this build setting in their 'toolchains' attribute.   | String | optional |  `""`  |
102*bcb5dc79SHONG Yifan| <a id="string_flag-values"></a>values |  The list of allowed values for this setting. An error is raised if any other value is given.   | List of strings | optional |  `[]`  |
103*bcb5dc79SHONG Yifan
104*bcb5dc79SHONG Yifan
105*bcb5dc79SHONG Yifan<a id="string_list_flag"></a>
106*bcb5dc79SHONG Yifan
107*bcb5dc79SHONG Yifan## string_list_flag
108*bcb5dc79SHONG Yifan
109*bcb5dc79SHONG Yifan<pre>
110*bcb5dc79SHONG Yifanstring_list_flag(<a href="#string_list_flag-name">name</a>)
111*bcb5dc79SHONG Yifan</pre>
112*bcb5dc79SHONG Yifan
113*bcb5dc79SHONG YifanA string list-typed build setting that can be set on the command line
114*bcb5dc79SHONG Yifan
115*bcb5dc79SHONG Yifan**ATTRIBUTES**
116*bcb5dc79SHONG Yifan
117*bcb5dc79SHONG Yifan
118*bcb5dc79SHONG Yifan| Name  | Description | Type | Mandatory | Default |
119*bcb5dc79SHONG Yifan| :------------- | :------------- | :------------- | :------------- | :------------- |
120*bcb5dc79SHONG Yifan| <a id="string_list_flag-name"></a>name |  A unique name for this target.   | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required |  |
121*bcb5dc79SHONG Yifan
122*bcb5dc79SHONG Yifan
123*bcb5dc79SHONG Yifan<a id="string_list_setting"></a>
124*bcb5dc79SHONG Yifan
125*bcb5dc79SHONG Yifan## string_list_setting
126*bcb5dc79SHONG Yifan
127*bcb5dc79SHONG Yifan<pre>
128*bcb5dc79SHONG Yifanstring_list_setting(<a href="#string_list_setting-name">name</a>)
129*bcb5dc79SHONG Yifan</pre>
130*bcb5dc79SHONG Yifan
131*bcb5dc79SHONG YifanA string list-typed build setting that cannot be set on the command line
132*bcb5dc79SHONG Yifan
133*bcb5dc79SHONG Yifan**ATTRIBUTES**
134*bcb5dc79SHONG Yifan
135*bcb5dc79SHONG Yifan
136*bcb5dc79SHONG Yifan| Name  | Description | Type | Mandatory | Default |
137*bcb5dc79SHONG Yifan| :------------- | :------------- | :------------- | :------------- | :------------- |
138*bcb5dc79SHONG Yifan| <a id="string_list_setting-name"></a>name |  A unique name for this target.   | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required |  |
139*bcb5dc79SHONG Yifan
140*bcb5dc79SHONG Yifan
141*bcb5dc79SHONG Yifan<a id="string_setting"></a>
142*bcb5dc79SHONG Yifan
143*bcb5dc79SHONG Yifan## string_setting
144*bcb5dc79SHONG Yifan
145*bcb5dc79SHONG Yifan<pre>
146*bcb5dc79SHONG Yifanstring_setting(<a href="#string_setting-name">name</a>, <a href="#string_setting-make_variable">make_variable</a>, <a href="#string_setting-values">values</a>)
147*bcb5dc79SHONG Yifan</pre>
148*bcb5dc79SHONG Yifan
149*bcb5dc79SHONG YifanA string-typed build setting that cannot be set on the command line
150*bcb5dc79SHONG Yifan
151*bcb5dc79SHONG Yifan**ATTRIBUTES**
152*bcb5dc79SHONG Yifan
153*bcb5dc79SHONG Yifan
154*bcb5dc79SHONG Yifan| Name  | Description | Type | Mandatory | Default |
155*bcb5dc79SHONG Yifan| :------------- | :------------- | :------------- | :------------- | :------------- |
156*bcb5dc79SHONG Yifan| <a id="string_setting-name"></a>name |  A unique name for this target.   | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required |  |
157*bcb5dc79SHONG Yifan| <a id="string_setting-make_variable"></a>make_variable |  If set, the build setting's value will be available as a Make variable with this name in the attributes of rules that list this build setting in their 'toolchains' attribute.   | String | optional |  `""`  |
158*bcb5dc79SHONG Yifan| <a id="string_setting-values"></a>values |  The list of allowed values for this setting. An error is raised if any other value is given.   | List of strings | optional |  `[]`  |
159*bcb5dc79SHONG Yifan
160*bcb5dc79SHONG Yifan
161*bcb5dc79SHONG Yifan<a id="BuildSettingInfo"></a>
162*bcb5dc79SHONG Yifan
163*bcb5dc79SHONG Yifan## BuildSettingInfo
164*bcb5dc79SHONG Yifan
165*bcb5dc79SHONG Yifan<pre>
166*bcb5dc79SHONG YifanBuildSettingInfo(<a href="#BuildSettingInfo-value">value</a>)
167*bcb5dc79SHONG Yifan</pre>
168*bcb5dc79SHONG Yifan
169*bcb5dc79SHONG YifanA singleton provider that contains the raw value of a build setting
170*bcb5dc79SHONG Yifan
171*bcb5dc79SHONG Yifan**FIELDS**
172*bcb5dc79SHONG Yifan
173*bcb5dc79SHONG Yifan
174*bcb5dc79SHONG Yifan| Name  | Description |
175*bcb5dc79SHONG Yifan| :------------- | :------------- |
176*bcb5dc79SHONG Yifan| <a id="BuildSettingInfo-value"></a>value |  The value of the build setting in the current configuration. This value may come from the command line or an upstream transition, or else it will be the build setting's default.    |
177*bcb5dc79SHONG Yifan
178*bcb5dc79SHONG Yifan
179