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