bazelbuild / bazelbuild/bazel

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

Open
#15,470 6 comments 24 reactions 0 assignees View on GitHub
P3 team-Rules-API type: feature request
Dominant language
Java
Stars
25.8k
Forks
4.6k
Avg merge
2d 20h
Merged PRs (30d)
72

Description

### 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.

Contributor guide

Open the contributing guide

Research direction

Start by tracing how actions expose environment variables and how ctx.var and BINDIR are handled for js_binary and ctx.actions.run. Confirm the behavior against existing genrule handling; done means every action can access BINDIR without callers explicitly adding it or causing new action cache invalidations.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, javascript
Domain
build-system
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.