bazelbuild/bazel

Always expose ctx.var["BINDIR"] to actions

alexeagle opened this issue · 3 comments

Description of the feature request:

At aspect we're working on a new ruleset where every action spawn of a js_binary needs to know the BINDIR variable.

Every Bazel action implicitly knows the bindir, as the paths for output files have it as a prefix. Thus adding it shouldn't cause any new action cache invalidations.

Today users can already do this, such as in genrule by referencing BINDIR=$(BINDIR) or in ctx.actions.run with env = { "BINDIR": ctx.bin_dir.path}. However, this makes an extra burden for users of rules there is no standard name for this environment variable, and the tool which needs this in the environment ought to be an abstraction which doesn't leak to the callsites.

I only marginally understand the issue here, but I believe this is getting in the way of using a Typescript binary target to implement a protobuf plugin (aspect-build/rules_js#397).

Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 1+ years. It will be closed in the next 90 days unless any other activity occurs. If you think this issue is still relevant and should stay open, please post any comment here and the issue will no longer be marked as stale.

We could send a PR for this