Unfortunately, this leads to poor error messages when attempting to build with an incompatible platform:
➜ pigweed git:(34b64d0b9) bazelisk test //pw_async2/examples:coro_blinky_loop
Target //pw_async2/examples:coro_blinky_loop failed to build
ERROR: Analysis of target '//pw_async2/examples:coro_blinky_loop' failed; build aborted: Target //pw_async2/examples:coro_blinky_loop is incompatible and cannot be built, but was explicitly requested.
Dependency chain:
//pw_async2/examples:coro_blinky_loop (8bf521)
//pw_async2:coro (2ccb10) <-- target platform (@@platforms//host:host) didn't satisfy constraint @@platforms//:incompatible
INFO: Elapsed time: 0.215s, Critical Path: 0.03s
INFO: 1 process: 1 internal.
ERROR: Build did NOT complete successfully
ERROR: No test targets were found, yet testing was requested
What I would like to be able to create is an error like the following:
➜ pigweed git:(34b64d0b9) bazelisk test //pw_async2/examples:coro_blinky_loop
Target //pw_async2/examples:coro_blinky_loop failed to build
ERROR: Analysis of target '//pw_async2/examples:coro_blinky_loop' failed; build aborted: Target //pw_async2/examples:coro_blinky_loop is incompatible and cannot be built, but was explicitly requested.
Dependency chain:
//pw_async2/examples:coro_blinky_loop (8bf521)
//pw_async2:coro (2ccb10) <-- (@@platforms//host:host) is incompatible:
Target requires C++20 or greater. Consider rebuilding with `--config=cxx20`.
INFO: Elapsed time: 0.215s, Critical Path: 0.03s
INFO: 1 process: 1 internal.
ERROR: Build did NOT complete successfully
ERROR: No test targets were found, yet testing was requested
Description of the feature request:
Add a
no_match_compatible_error
toselect
or a similar mechanism to provide a custom error message when//platforms:incompatible
is selected.What underlying problem are you trying to solve with this feature?
It's common for targets to express a dependency on a particular platform feature using
target_compatible_with
+select
+//platforms:incompatible
, as demonstrated in the "More expressive constraints" section of the Platforms documentation.Unfortunately, this leads to poor error messages when attempting to build with an incompatible platform:
What I would like to be able to create is an error like the following:
select
does actually have some support for custom error messages in the form ofno_match_error
today, but this is not usable withtarget_compatible_with
, as it will create a hard error when performing a wildcard build rather than skipping incompatible targets.There should be some way to unify these features, possibly with a
no_match_incompatible_error
or similar arg.