You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is honestly probably a doc suggestion, I think, though I'm not quite sure how to phrase it. If you want to use the multitool binary as a tool, i.e. as part of the build, it seems like:
If you want it to be safe under cross-compilation, you must use the :cwd target to ensure that there is a transition to cfg=exec (otherwise, when you run with --platforms <incompatible>, it'll download the wrong binary)
If you want it to work on windows, you have to use a file extension that matches the original one (in other words, .bat).
I think this means that this is exactly what you need to invoke (for, let's say, using ruff as a test):
load("@bazel_skylib//rules:native_binary.bzl", "native_test")
native_test(
name="ruff_lint",
# use cwd to run the binary through a cfg=exec label, so things don't break when target != execsrc="@multitool//tools/ruff:cwd",
# use .bat because unix doesn't care about the extension, but windows won't work otherwiseout="ruff_lint.bat",
args= [
"--version",
],
data= [
"@multitool//tools/ruff:cwd",
]
)
I'm curious if you know if a better way to handle this.
The text was updated successfully, but these errors were encountered:
When using multitool binaries in our builds we typically make a custom rule where we can specify the configuration.
Our ruff wrapper is an aspect that sets cfg=“exec”, for instance. The specifics around producing a .bat file is generally true of windows and not something specific to the executables we make here.
Absent a custom rule, I think you need a transition, but frankly I’m not quite literate enough to give you an example.
I was largely trying to avoid needing a custom rule to handle it, instead trying to make it work with just a custom macro to avoid needing to reimplement stuff like native_test. I mostly mention this as a doc fix because it took me a few (distracted) hours to figure out what was happening in our windows build.
No additional transition is needed if you use the :cwd target, because the transition is built into that target already. (The thing I put into the description is a complete, working example if all you want to do is invoke ruff --version. Obviously, if you want to run ruff check with a custom config, you need a few more things)
This is honestly probably a doc suggestion, I think, though I'm not quite sure how to phrase it. If you want to use the multitool binary as a tool, i.e. as part of the build, it seems like:
:cwd
target to ensure that there is a transition tocfg=exec
(otherwise, when you run with--platforms <incompatible>
, it'll download the wrong binary).bat
).I think this means that this is exactly what you need to invoke (for, let's say, using ruff as a test):
I'm curious if you know if a better way to handle this.
The text was updated successfully, but these errors were encountered: