Skip to content

Files

Latest commit

dc5d3e1 Β· Feb 20, 2025

History

History

rules

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Apr 19, 2022
Aug 16, 2021
Oct 4, 2023
Sep 25, 2023
Aug 30, 2024
Oct 3, 2023
Sep 25, 2023
Oct 2, 2023
Apr 19, 2022
Oct 4, 2023
Sep 25, 2023
Aug 30, 2024
Oct 3, 2023
Oct 3, 2023
Oct 2, 2023
Feb 20, 2025
Oct 22, 2019
May 22, 2018
Oct 2, 2023
Jun 17, 2024
Sep 11, 2024
Oct 4, 2023
Oct 2, 2023

Bazel Rules

This directory contains examples of Bazel rules. For additional information, please refer to the documentation.

Getting started

These examples cover the most basic features: creating a rule, creating actions, passing information from a dependency to a target.

  • empty: Minimal example to show the creation of a rule.

  • attributes: Example of a rule with attributes.

  • actions.run: Example where a binary target is used as implicit dependency and executed by the rule.

  • actions.write: Example where a file is generated.

  • expand_template: Example where a file is generated based on a template.

  • shell command: Example where a shell command is executed to do simple text file processing.

  • mandatory provider: Example with a mandatory provider, to access information from a dependency.

  • optional provider: Example with an optional provider, to access information from a dependency.

  • depsets: Example of a using a depset to gather transitive information. Each target collects data from its dependencies.

Additional examples

These examples explore more specific scenarios. They allow you to have more control on the behavior of the rules.

  • executable: Example of an executable rule.

  • test rule: Example of a test rule.

  • runfiles: Example of an executable rule with runfiles (files required at runtime).

  • computed dependencies: Example with computed dependencies. The set of implicit dependencies depends on the rule attributes.

  • predeclared outputs: Example with attr.output_list and outputs.

  • implicit output: Example with implicit outputs. Some outputs are available only when explicitly requested.

  • aspect: Example of using an aspect to collect information from other rules.