@@ -169,25 +169,16 @@ FAILED: Build did NOT complete successfully
169169
170170### More expressive constraints
171171
172- For more flexibility in expressing constraints, create a user-defined
172+ For more flexibility in expressing constraints, use the
173+ ` @platforms//:incompatible `
173174[ ` 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.
176176
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".
191182
192183``` python
193184cc_library(
@@ -196,18 +187,18 @@ cc_library(
196187 target_compatible_with = select({
197188 " @platforms//os:osx" : [],
198189 " @platforms//os:linux" : [],
199- " //conditions:default" : [" //:not_compatible " ],
190+ " //conditions:default" : [" @platforms //:incompatible " ],
200191 ],
201192)
202193```
203194
204195The above can be interpreted as follows:
205196
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.
211202
212203To make your constraints more readable, use
213204[skylib](https:// github.com/ bazelbuild/ bazel- skylib)' s
@@ -221,7 +212,7 @@ cc_library(
221212 name = " non_arm_lib" ,
222213 srcs = " non_arm_lib.cc" ,
223214 target_compatible_with = select({
224- " @platforms//cpu:arm" : [" //:not_compatible " ],
215+ " @platforms//cpu:arm" : [" @platforms //:incompatible " ],
225216 " //conditions:default" : [],
226217 ],
227218)
0 commit comments