bazelbuild / bazelbuild/bazel

Support workspace_status_rule in addition to workspace_status_command

Open
#11,161 4 comments 8 reactions 0 assignees View on GitHub
not stale P3 team-ExternalDeps type: feature request
Dominant language
Java
Stars
25.8k
Forks
4.6k
Avg merge
2d 20h
Merged PRs (30d)
72

Description

### Description of the problem / feature request:

`--workspace_status_command` can be used to gain e.g. repository information - a git commit, UTC timestamp, ...

We would much prefer to have a `--workspace_status_rule` that is run before the regular build phase in the workspace directory.

### Feature requests: what underlying problem are you trying to solve with this feature?

The target called by `--workspace_status_command` is OS specific and there is no "nice" way to get around it. A colleague posted #5958 and we iterated with Bash/Powershell polyglot scripts and python, but even python seems to be phasing out as a requirement for running Bazel (which I consider a good thing, keep the requirements minimal).
Also, it's rather wild to get Python to write `\n` line endings under Windows...

We do not see a sound required common language we can use, here. Relying on Bazel itself would provide a solid foundation, though. This would probably require a "prebuild" phase. If that is too much, we can _probably_ also get by with a way load and run a starlark function.

But a rule is much more desirable and flexible than a command executed in a shell...

Aside: thank you so much for your work. We love Bazel!

Contributor guide

Open the contributing guide

Research direction

Start by tracing the existing --workspace_status_command handling and how it runs in the workspace directory before the build phase. Define the rule interface and lifecycle needed to provide equivalent workspace status without an OS-specific command; done means the proposed rule works across platforms and its behavior is covered by appropriate tests and documentation.

Written by the indexing model from the issue text.

Assessment

Tech stack
bash, powershell, python
Domain
build-system
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.