bazelbuild / bazelbuild/bazel

FR: BXL style extensions for better tool integration.

Open
#26,466 2 comments 2 reactions 0 assignees View on GitHub
team-Core type: feature request untriaged
Dominant language
Java
Stars
25.8k
Forks
4.6k
Avg merge
2d 20h
Merged PRs (30d)
72

Description

### Description of the feature request:

Buck2 has an extension system that allows querying and analyzing the dependency graph in a safe and controlled manner with the starlark language.

This feature request is starting a discussion on feasibility and interest in such feature brought to Bazel.

This would allow additional use cases such as

- better IDE integration, eg running aquery across the whole workspace to generate clangd compatible compatible compilation database
- build an LSP for [insert a language here] that resolves imports without using hacks such as symlinking or writing back to source tree to satisfy imports.
- run additional `aspects`, BXL calls them dynamic outputs, and/or inspect content of file and register more actions.

Today this is not trivial with any of the Bazel extension points, be `repository rules` or `[ac]query` and often needs a wrapper tool to actually do anything meaningful.

- aquery/cquery: needs a multiple round trip to the Bazel server to extract information, need to parse the information, slow.
- repository rules: can declare targets and is tailored towards external dependencies, but not additional actions. It can't augment the build in a way that BXL could.
- BES/BEP, Execlog: does provide information about what Bazel has done, but doesn't give you the full list of actions.

Most important of all, accessing anything about the BUILD graph usually requires a CLI call, fetching of the information, and serialization of it.

Here's some important bullet points from BXL Why page.

- Use/inspect resolved attributes that are not exposed/accessible to users via normal Buck2 operations
- Reduce/eliminate the need to make several Buck2 calls within your program, such as running several subprocesses to call cquery several times
- Reduce/eliminate the need to manually parse Buck2 output format within your program, and any bugs that may come with manual parsing

Here some tools that would have been a BXL style extension if Bazel had such concept.

https://github.com/hedronvision/bazel-compile-commands-extractor
https://github.com/fzakaria/vscode.bzl
https://github.com/Tinder/bazel-diff

### Which category does this issue belong to?

Core

### What underlying problem are you trying to solve with this feature?

See above.

### Which operating system are you running Bazel on?

_No response_

### What is the output of `bazel info release`?

_No response_

### If `bazel info release` returns `development version` or `(@non-git)`, tell us how you built Bazel.

_No response_

### What's the output of `git remote get-url origin; git rev-parse HEAD` ?

```text

```

### Have you found anything relevant by searching the web?

_No response_

### Any other information, logs, or outputs that you want to share?

_No response_

Contributor guide

Open the contributing guide

Research direction

No repository files, tests, or implementation entry points are identified. Start by reviewing Bazel's existing extension points and the linked BXL-related use cases; the issue would need a defined scope, feasibility decision, and acceptance criteria before implementation can begin.

Written by the indexing model from the issue text.

Assessment

Domain
build-system
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
15/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.