bazelbuild / bazelbuild/bazel

[feature request] Consider moving `bzl_library.bzl` into `@bazel_tools`

Open
#18,391 13 comments 2 reactions 0 assignees View on GitHub
P4 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:

Skylib's [`bzl_library.bzl`](https://github.com/bazelbuild/bazel-skylib/blob/1.4.1/bzl_library.bzl) provides a `StarlarkLibraryInfo` provider and `bzl_library` rule, which are used for aggregating `.bzl` rules files for use by other analysis tools.

The definition of that provider and rule are quite stable (basically unchanged since 2018), and it has no dependencies on any other part of skylib.

The natural way to use that file is to `load` it from every `BUILD` file in a ruleset, like this:

```python
# rules_example/example/BUILD
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")

bzl_library(
name = "bzl_srcs",
srcs = ["defs.bzl", "repository.bzl", "toolchain.bzl"],
deps = ["//example/internal:bzl_srcs"],
)
```

However, since the `load` needs to fetch skylib before evaluation continues, this means that skylib becomes a hard dependency for _every client of the ruleset_.

Given that the `bzl_library.bzl` file is generic, broadly useful, and very stable, could it be bundled into `@bazel_tools` instead?

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the linked Skylib bzl_library.bzl file and how Bazel currently exposes @bazel_tools. Trace how rulesets load this file and identify the compatibility and packaging implications of bundling it with Bazel. Done means a decided, validated approach for providing the provider and rule without requiring Skylib.

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
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.