• Stars
    star
    137
  • Rank 266,121 (Top 6 %)
  • Language Starlark
  • License
    Apache License 2.0
  • Created about 3 years ago
  • Updated about 1 month ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Common useful functions for writing BUILD files and Starlark macros/rules

Aspect's Bazel helpers library

Base Starlark libraries and basic Bazel rules which are useful for constructing rulesets and BUILD files.

This module depends on bazel-skylib. In theory all these utilities could be upstreamed to bazel-skylib, but the declared scope of that project is narrow and it's very difficult to get anyone's attention to review PRs there.

bazel-lib is just a part of what Aspect provides:

Installation

Installation instructions are included on each release: https://github.com/aspect-build/bazel-lib/releases

To use a commit rather than a release, you can point at any SHA of the repo.

For example to use commit abc123:

  1. Replace url = "https://github.com/aspect-build/bazel-lib/releases/download/v0.1.0/bazel-lib-v0.1.0.tar.gz" with a GitHub-provided source archive like url = "https://github.com/aspect-build/bazel-lib/archive/abc123.tar.gz"
  2. Replace strip_prefix = "bazel-lib-0.1.0" with strip_prefix = "bazel-lib-abc123"
  3. Update the sha256. The easiest way to do this is to comment out the line, then Bazel will print a message with the correct value.

Note that GitHub source archives don't have a strong guarantee on the sha256 stability, see https://github.blog/2023-02-21-update-on-the-future-stability-of-source-code-archives-and-hashes

Public API

Copying files

  • copy_directory Copies directories to another package.
  • copy_file Copies files to another package.
  • copy_to_bin Copies a source file to output tree at the same workspace-relative path.
  • copy_to_directory Copies and arranges files and directories into a new directory.
  • write_source_files Write to one or more files or folders in the source tree. Stamp out tests that ensure the sources exist and are up to date.

Transforming files

  • jq A toolchain and custom rule for running jq, a tool that is "like sed for json".
  • yq A toolchain and custom rule for running yq, a "YAML, JSON and XML processor".

Manipulating paths

  • directory_path Provide a label to reference some path within a directory, via DirectoryPathInfo.
  • output_files Forwards a subset of the files (via the DefaultInfo provider) from a given target's DefaultInfo or OutputGroupInfo.

Writing rules

  • expand_make_vars Perform make variable and location substitions in strings..
  • expand_template Substitute templates with make variables, location resolves, stamp variables, and arbitrary strings.
  • paths Useful path resolution methods.
  • transitions Transition sources to a provided platform.
  • lists Functional-style helpers for working with list data structures.
  • utils Various utils for labels and globs.
  • params_file Generate encoded params file from a list of arguments.
  • repo_utils Useful methods for repository rule implementations.
  • run_binary Like skylib's run_binary but adds directory output support.
  • stamping Support version stamping in custom rules.
  • base64 Starlark Base64 encoder & decoder.

Generating documentation

  • docs Rules for generating docs and stamping tests to ensure they are up to date.

More Repositories

1

rules_nodejs

NodeJS toolchain for Bazel.
Starlark
727
star
2

rules_foreign_cc

Build rules for interfacing with "foreign" (non-Bazel) build systems (CMake, configure-make, GNU Make, boost, ninja, Meson)
Starlark
662
star
3

rules_jvm_external

Bazel rules to resolve, fetch and export Maven artifacts
Starlark
324
star
4

toolchains_llvm

LLVM toolchain for bazel
Starlark
294
star
5

rules_oci

Bazel rules for building OCI containers
Starlark
265
star
6

vscode-bazel

Bazel support for Visual Studio Code
TypeScript
241
star
7

rules_dotnet

.NET rules for Bazel
Starlark
190
star
8

target-determinator

Determines which Bazel targets were affected between two git commits.
Go
131
star
9

bazel-mypy-integration

πŸπŸŒΏπŸ’š Integrate MyPy type-checking into your Python Bazel builds
Starlark
119
star
10

rules_fuzzing

Bazel Starlark extensions for defining fuzz tests in Bazel projects
Starlark
87
star
11

rules_cuda

Starlark implementation of bazel rules for CUDA.
Starlark
83
star
12

rules_jsonnet

Jsonnet rules for Bazel
Starlark
69
star
13

rules_jvm

Contributed Bazel rules that make working with java projects more pleasant
Java
46
star
14

rules-template

A template for creating a new Bazel ruleset
Starlark
45
star
15

rules_bazel_integration_test

Rules and macros for executing integration tests that use Bazel. Supports running integration tests with multiple versions of Bazel.
Starlark
40
star
16

rules_debian_packages

Rules for installing debian-packages into Docker-Images with bazel
Starlark
23
star
17

SIG-rules-authors

Governance and admin for the rules authors Special Interest Group
Shell
22
star
18

publish-to-bcr

A GitHub app that mirrors releases of your Bazel ruleset to the Central Registry
TypeScript
21
star
19

Bazel-learning-paths

Bazel training materials and codelabs focused on beginner, advanced and contributor learning paths
Java
19
star
20

bazel_features

Support Bazel "feature detection" from starlark
Starlark
17
star
21

musl-toolchain

Python
14
star
22

unused-jvm-deps

Tool to remove unused deps entries for Java
Java
14
star
23

bcr-ui

Website for the Bazel Central Registry
TypeScript
10
star
24

bazel-catalog

Catalog of Bazel rules. http://awesomebazel.com meets https://bazel.build/rules plus live stats.
Shell
3
star
25

target-determinator-testdata

Sample commits used to test implementations of target determinators.
1
star
26

.github

GitHub metadata for the org
1
star