I have a program that can look at my language's source file, and derive the correct value for the deps=[]
value of its build rule.
I'm looking for a way to replace all my existing rules (that look like this):
build_lib(name = "foo", deps = [...])
build_lib(name = "bar", deps = [...])
build_lib(name = "baz", deps = [...])
To instead be:
build_lib_new(name = "foo")
build_lib_new(name = "bar")
build_lib_new(name = "baz")
with the same specified deps resolved internally in the rule by calling my program.
Ideally, build_lib_new
would just be a wrapper rule around build_lib
:
def derive_deps(name):
deps = []
# call my tool somehow?
return deps
def build_lib_new(name):
deps = derive_deps(name)
build_lib(name,deps)
Now I'm stuck. Unfortunately, I think bazel wants to know all the dependencies up front as part of the analysis phase. I see that their are actions to run shell commands, but I believe those happen after the dependency graph is made.
Do I have to run the external tool outside of bazel to rewrite BUILD
files?