bazel-skylib
bazel-skylib copied to clipboard
Add `lib/compatibility.bzl`
This patch adds new helper macros for dealing with incompatible target
skipping. Specifically, the macros help make the target_compatible_with
more readable and easier to understand.
Without these helpers you are left to write verbose select() statements.
For example, you might write the following to express a target that is incompatible with QNX and bare-bones systems.
cc_library(
name = "lib",
srcs = ["lib.cc"],
target_compatible_with = select({
"@platforms//os:qnx": ["@platforms//:incompatible"],
"@platforms//os:none": ["@platforms//:incompatible"],
"//conditions:default": [],
}),
)
WIth one of the helpers from this patch you can instead rewrite this as:
cc_library(
name = "lib",
srcs = ["lib.cc"],
target_compatible_with = compatibility.none_of(
"@platforms//os:qnx",
"@platforms//os:none",
),
)
That is now easier to understand. Especially for folks new to incompatible target skipping.
This patch is based on @trybka's trybka/bazel-skylib#1. The implementation is his. I cleaned up the tests and added documentation.
Oh hey -- thanks for picking this up!
If anyone has an idea why bazel is segfaulting on shutdown in one of the Windows tests, I'd appreciate it.
Any of the 5 code owners interested in taking a look at this PR?
@brandjon , @tetromino , @comius , @hvadehra , @c-mita , any thoughts? I am not sure what to make of the complete lack of feedback here.
Ups, wrong button.
any thoughts? I am not sure what to make of the complete lack of feedback here.
Too many reviewers - each one of them has time to review, but all of them together don't have it :)
@comius , any thoughts?
@comius , any thoughts?
I did a quick pass. Looks nice and looks ok, thanks. I'll do another more thorough pass and let you know.