Skip to content

Latest commit

 

History

History

rules

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.