I defined a Bazel macro. It looks something like this:
def my_macro():
java_binary(
srcs = glob(["*.java"])
# ...
)
When I run Bazel, it fails with an error
ERROR: /home/.../macros.bzl:105:19: name 'glob' is not defined
Is it possible to use glob in a macro?
The glob function is only available in BUILD.bazel files. In macro definitions in a .bzl file, access it as native.glob.
def my_macro():
java_binary(
srcs = native.glob(["*.java"])
# ...
)
References: https://groups.google.com/forum/#!topic/bazel-discuss/sXa60DnjxiA
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With