bazelbuild / platforms

Constraint values for specifying platforms and toolchains
Apache License 2.0
108 stars 71 forks source link

Add an "incompatible" constraint value #20

Closed philsc closed 3 years ago

philsc commented 3 years ago

The bazel docs 1 currently recommend users to create an incompatible constraint in their own code base. This constraint is useful in expressing more advanced target compatibilities.

Currently every project has to create their own definition for this constraint. That is unnecessary proliferation of something that can be easily centralized here.

This patch makes it so users will be able to use the following pattern in their BUILD files:

cc_library(
    name = "unixish_lib",
    srcs = "unixish_lib.cc",
    target_compatible_with = select({
        "@platforms//os:osx": [],
        "@platforms//os:linux": [],
        "//conditions:default": ["@platforms//:incompatible"],
    ],
)
philsc commented 3 years ago

As an example, bazelbuild/rules_pkg#254 is adding a copy of this definition in their pkg/BUILD.

philsc commented 3 years ago

I also changed the name from not_compatible to incompatible.