I have a macro:
def py_layers(name, py_binary):
layers = []
# Do stuff
some_bazel_rule(...)
return layers
How can I make sure that the py_binary target is built by bazel before calling some_bazel_rule? From my understanding, looks like the proper way is to convert py_layers to a rule. However, it's still very unclear to me how I make py_binary an explicit dependency of py_layers. Can someone provide the correct implementation?
You would add the
py_binarytarget as a dependency of thesome_bazel_ruletarget.One thing to keep in mind is that macros just instantiate instances of rules (targets) in a repeatable way (and can perform some limited code / logic). So once the macro executes, all that's left are the targets that it generated. So it's not really that
py_layershas dependencies, but that the targets it creates has dependencies.