Closed josephperrott closed 4 years ago
@josephperrott, I think this would be a really really great feature to add. I've been doing some repo cleanup with the goal of engaging you on this issue. How could I help get you engaged?
All the code for controlling the query operation lives inside a small block inside the bazel lib.
It doesn't look to me like it would be that hard to add a new method cquery
and then change all the callers over. Is this a thing I could interest you in?
I'm about to do a release that will add colors (YAY!) and fix a lot of the output formatting issues (YAY!) but would love to do a v0.11.1
as early as this afternoon if you're interested.
Stale issue message
Don't close this please.
On Sat, Feb 15, 2020, 4:14 PM github-actions[bot] notifications@github.com wrote:
Stale issue message
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/bazelbuild/bazel-watcher/issues/305?email_source=notifications&email_token=AABUZ2EOYWP2BSJZZHN7EG3RDCAPFA5CNFSM4JU54OM2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEL32FGY#issuecomment-586654363, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABUZ2BQWL732LAMV4WOHU3RDCAPFANCNFSM4JU54OMQ .
Stale issue message
not stale
@achew22 Thanks for working on this. I think unfortunately it's not improving things as there is still a bazel query
call for determining the build files. This causes the analysis cache to be still discarded.
The goal would be that the analysis cache is not discarded. We could achieve this by using cquery
for determining the build files, or by always using bazel query
and allowing define variables.
cquery
does not support buildfiles, but maybe we could make that work with upstream changes in bazel? Ideally though, bazel query
would just support --define
for the sake of not discarding analysis cache, unless I miss something here. This makes me wonder why the analysis cache is even discarded at all if standard bazel query
is supposed to just run as part of the loading phase.
@devversion this sounds like a great issue to open upstream on the Bazel main repo. Unfortunately I don't have enough time to spin up on that particular issue, but I would be interested in seeing what they say. It could be something as simple as changing a Boolean value somewhere. That's something I would be happy to do.
Hey y'all, bazel engineer here. @devversion is right, query
just runs the loading phase which is why it doesn't respect any build flags (like --define
). That also means it shouldn't be invalidating the analysis cache because it doesn't run the analysis phase.
Out of curiosity, you're running two query
commands one after another and you're seeing symptoms that looks like analysis cache invalidation? What are those symptoms?
As for bazel changes, adding --define
respect to query
isn't an option. cquery
was created to be a query that respects build flags. But adding buildfiles()
support to cquery
seems possible to me. If I remember correctly, there wasn't any major technical reason this didn't happen, we just figured we'd implement when a need arose:
https://cs.opensource.google/bazel/bazel/+/master:src/main/java/com/google/devtools/build/lib/query2/PostAnalysisQueryEnvironment.java;l=480
Here's the implementation in query
:
https://cs.opensource.google/bazel/bazel/+/master:src/main/java/com/google/devtools/build/lib/query2/query/BlazeQueryEnvironment.java;l=410
Bazel team probably doesn't have the cycles to own this but If you wanted to investigate/make this change in the bazel repo I'd be happy to shepherd your PRs through.
Currently ibazel uses
bazel query
to determine if the build graph has changed. Howeverbazel query
does not allow for configurations to be considered.If you set a
--define
flag for yourbuild
s, every time ibazel runsbazel query
, the analysis cache is invalidated in determining thequery
results only to have the results invalidated again by the nextbuild
.If
bazel cquery
is used instead, the--define
flag is now considered/valid and the correct graph is created.cquery
inherits all of its flags frombuild
(as doesrun
andtest
) which leads to all supported flags in ibazel being able to be forwarded to the "query" checksUnder the hood the commands that are called by ibazel in this instance look something like this:
with
cquery
it would instead be: