Reputation: 171
I would like a set of rules from my_package.bzl
to be accessible to all BUILD
files of a workspace without having to load
my_package.bzl
in the BUILD
files. Basically I want the rules in the package to look like native rules. How can I achieve this?
I was thinking maybe there's a line I could add to one of the .bazelrc
s or to the WORKSPACE
file of the the project.
Upvotes: 2
Views: 736
Reputation: 1329
This can be achieved by adding a prelude_bazel
file at //tools/build_rules:prelude_bazel
(this must be a package, so tools/build_rules
must contain a BUILD
file).
This will be loaded and prepended to all BUILD
files loaded by Bazel.
However, there are a few things to consider before going this route. It's currently undocumented, and while doing some searching to find any info on this feature, it's unclear if it will remain a part of Bazel.
It may also have performance / scaling problems. If the prelude
were to change (or any of its dependencies), every BUILD file would have to be reloaded, and this may take some time depending on the size of the build graph.
Upvotes: 2