Practical Bazel: Isolating Ruleset’s Public Interface
Practical Bazel bazel
When writing a custom Bazel ruleset, it is important to carefully separate its public interface from its private implementation and be deliberate and careful about changes to the public interface. Here’s the pattern I use when I’m writing rulesets to handle this.
Consider a ruleset named
rules_foo. I will define the public
endpoints of the ruleset in a file named
and put all implementation inside the folder
The public endpoint definition file
def.bzl does nothing but
decide which pieces of Bazel code in the private implemtnation
define the ruleset’s public interface.
For example, here’s what the
def.bzl might look like: