theoremlp / rules_multitool

Bazel rules for ergonomic tool definitions
Apache License 2.0
24 stars 6 forks source link

feat: add rule to run tool in BUILD_WORKSPACE_DIRECTORY #60

Closed thomasquinn closed 3 weeks ago

thomasquinn commented 3 weeks ago

This PR adds a rule which is identical to cwd, except that it runs the tool in BUILD_WORKSPACE_DIRECTORY instead of BUILD_WORKING_DIRECTORY. There are some tools which should always be run from the module/workspace root and I think it would be useful to add a convenience rule for this.

The code is largely copied from the cwd implementation, so there may be some opportunity to deduplicate some of it. You may also have a better name in mind than bwd 😄

mark-thm commented 3 weeks ago

yeah I think we could adapt the cwd rule to substitute the two env vars in here rather than duplicating it entirely. I think I might want to call the alternative setup here workspace_root or workspace rather than bwd -- cwd has a standard meaning on *nix systems which is why I abbreviated.

thomasquinn commented 3 weeks ago

Sounds good, I'll update the PR with those changes.

thomasquinn commented 3 weeks ago

Let me know if this is closer to what you had in mind.