@@ -169,25 +169,16 @@ FAILED: Build did NOT complete successfully
169
169
170
170
### More expressive constraints
171
171
172
- For more flexibility in expressing constraints, create a user-defined
172
+ For more flexibility in expressing constraints, use the
173
+ ` @platforms//:incompatible `
173
174
[ ` constraint_value ` ] ( platform.html#constraint_value ) that no platform
174
- satisfies. For example, Put the following somewhere in your project and change
175
- ` //:not_compatible ` in the subsequent examples to match your location.
175
+ satisfies.
176
176
177
- ``` python
178
- constraint_setting(name = " not_compatible_setting" )
179
-
180
- constraint_value(
181
- name = " not_compatible" ,
182
- constraint_setting = " :not_compatible_setting" ,
183
- )
184
- ```
185
-
186
- Use [ ` select() ` ] ( functions.html#select ) in combination with ` :not_compatible `
187
- to express more complicated restrictions. For example, use it to implement
188
- basic OR logic. The following marks a library compatible with macOS and Linux,
189
- but no other platforms. Note that an empty constraints list is equivalent to
190
- "compatible with everything".
177
+ Use [ ` select() ` ] ( functions.html#select ) in combination with
178
+ ` @platforms//:incompatible ` to express more complicated restrictions. For
179
+ example, use it to implement basic OR logic. The following marks a library
180
+ compatible with macOS and Linux, but no other platforms. Note that an empty
181
+ constraints list is equivalent to "compatible with everything".
191
182
192
183
``` python
193
184
cc_library(
@@ -196,18 +187,18 @@ cc_library(
196
187
target_compatible_with = select({
197
188
" @platforms//os:osx" : [],
198
189
" @platforms//os:linux" : [],
199
- " //conditions:default" : [" //:not_compatible " ],
190
+ " //conditions:default" : [" @platforms //:incompatible " ],
200
191
],
201
192
)
202
193
```
203
194
204
195
The above can be interpreted as follows:
205
196
206
- 1 . If we are targeting macOS, then this target has no constraints.
207
- 2 . If we are targeting Linux, then this target has no constraints.
208
- 3 . Otherwise the target has the `:not_compatible ` constraint. Because
209
- `:not_compatible ` is not part of any platforms , the target is deemed
210
- incompatible.
197
+ 1 . When targeting macOS, the target has no constraints.
198
+ 2 . When targeting Linux, the target has no constraints.
199
+ 3 . Otherwise, the target has the `@ platforms // :incompatible ` constraint. Because
200
+ `@ platforms // :incompatible ` is not part of any platform , the target is
201
+ deemed incompatible.
211
202
212
203
To make your constraints more readable, use
213
204
[skylib](https:// github.com/ bazelbuild/ bazel- skylib)' s
@@ -221,7 +212,7 @@ cc_library(
221
212
name = " non_arm_lib" ,
222
213
srcs = " non_arm_lib.cc" ,
223
214
target_compatible_with = select({
224
- " @platforms//cpu:arm" : [" //:not_compatible " ],
215
+ " @platforms//cpu:arm" : [" @platforms //:incompatible " ],
225
216
" //conditions:default" : [],
226
217
],
227
218
)
0 commit comments