-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add convenience target for running in the current working directory #29
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - consider the nit, but not blocking
exports_files( | ||
["multitool.lock.json"], | ||
) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
turns out this wasn't necessary
execdir="$PWD" | ||
|
||
pushd "$BUILD_WORKING_DIRECTORY" > /dev/null | ||
"$execdir/$tool" "$@" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is wrong, it leaves a bash process as the parent of the tool process, interfering with signals and leaving a messy pstree. I think you want exec
here to replace the current process.
(Also I don't see the point of popd
since the shell exits at that point and whatever directory it was running in is lost)
It's common for users of multitool to want to run tools in the current working directory. In #26, @alexeagle documented a technique we've used for a while with creating a script and symlinking to it. Our internal copy of this script is a bit more complicated to help avoid expensive calls to Bazel that simple
bazel run
calls don't really need. More refinements have been proposed in #27. All of these things are fundamentally workarounds for bazelbuild/bazel#3325.To help simplify things, this PR adds a convenience wrapper that captures the execpath, switches to $BUILD_WORKING_DIRECTORY, and then runs the desired tool. The resulting shell script gets to use a very simple
bazel run
, should be compatible across any slew of Bazel options, and cache as well as any typical run target.