To figure the list of targets to request from the build we need to run Bazel query and massage the output with Python-like script.
We can do it in two steps:
1. run the script which executes Bazel query (or queries), calculates the list of targets and writes them to the file "targets.bzl"
2. run the actual build to act on that list;
Of course people would forget to run the first step, the build get executed on the stale list of targets and we get all kinds of weird build error reports.
I wonder if there is a way to embed the query into the build to make it all single invocation of Bazel. Ideally I would like to run Bazel query as part of repository rule execution.
Obviously I cannot simply invoke "bazel query" command from repository rule as Bazel can execute only one command at a time, but the existence of "genquery" gives me hope that there is a way to run query as part of the same build command.
Any leads?
Thank you!
Konstantin