Providing a default target_compatible_with from rules

116 views
Skip to first unread message

carpen...@gmail.com

unread,
Oct 7, 2022, 6:01:40 AM10/7/22
to bazel-discuss
HI, 

We have several rules which only make sense on on our windows build environment, and not on our linux build environment. For example compiling a .rc file into a .res file. I want `build ...` to work on our linux environment so I want a low effort way to skip out these targets by marking them as not compatible with the build. 

If I use exec_compatible_with I get an error: Unable to find an execution platform for target platform @local_config_platform//:host from available execution platforms []

I cannot seem to set defaults for the rules with any other system than macros. WHich I have successfully used a macro to wrap the rule and inject in target_compatible_with.

I also need to ensure I explicitly remove the exec_compatible_with from the rules, because I don't have remote execution providers registered with Bazel. 

Is there a better system so that I can tell bazel to skip not error if there is not an execution environment available? 

Thanks in advance

Konstantin

unread,
Nov 12, 2022, 3:44:05 PM11/12/22
to bazel-discuss
It may not be direct answer to your question but just be aware that `target_compatible_with` skipping behavior is very limited. It is designed to skip incompatible targets from the wildcards, such as `:all` or `...` but it does not help if for instance you have a filegroup which has a list of targets in `srcs` and some of those targets are incompatible. It cannot skip incompatible targets and just fail the build. To my knowledge there is no workaround for that - any time the target depends on incompatible target the build fails. For that reason we had to abandon using `targets_compatible_with` for our project altogether because we really need skipping of incompatible dependencies.

Konstantin

Reply all
Reply to author
Forward
0 new messages