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
The basic use case is to allow easily using the same bazel that the user uses to run their builds. The main use case I have in mind for this is when you're using a custom build of bazel specified using USE_BAZEL_VERSION. e.g. if one does:
USE_BAZEL_VERSION=/tmp/bazel-dev bazel //my:test
Then the version of bazel at /tmp/bazel-dev will be used, without having to go into the MODULE.bazel config (or elsewhere) to reconfigure this. Having to do that is a hassle and changes the name of generated targets.
I think the bazel_binaries.local() tag class can be easily adopted for this purpose:
Add an attribute, shell_command, which takes a single word, e.g. "bazel", "mybazel", "bazel-dev", etc.
In _local_bazel_binary_repo, call repository_ctx.which(shell_command) to get the actual path
Add USE_BAZEL_VERSION and PATH to the repo rule's environment variables that affect it.
I was able to emulate this by using a local path to a script that just re-execs using the command "bazel", but it'd be nicer if I didn't have to plumb through a wrapper to achieve that.
The text was updated successfully, but these errors were encountered:
This sounds reasonable to me. Do you have an implementation that you want to share? The updates as you describe them sound about right. Below are some additional thoughts on the implementation:
Add an integration test to exercise the local(shell_command="...").
Inside the handler for the local tag class, we should error if a client specified shell_command and path.
The basic use case is to allow easily using the same bazel that the user uses to run their builds. The main use case I have in mind for this is when you're using a custom build of bazel specified using
USE_BAZEL_VERSION
. e.g. if one does:Then the version of bazel at /tmp/bazel-dev will be used, without having to go into the MODULE.bazel config (or elsewhere) to reconfigure this. Having to do that is a hassle and changes the name of generated targets.
I think the
bazel_binaries.local()
tag class can be easily adopted for this purpose:shell_command
, which takes a single word, e.g. "bazel", "mybazel", "bazel-dev", etc._local_bazel_binary_repo
, callrepository_ctx.which(shell_command)
to get the actual pathUSE_BAZEL_VERSION
andPATH
to the repo rule's environment variables that affect it.The end result looks something like:
I was able to emulate this by using a local path to a script that just re-execs using the command "bazel", but it'd be nicer if I didn't have to plumb through a wrapper to achieve that.
The text was updated successfully, but these errors were encountered: