2

I want to implement fetching of compiler warnings with Bazel (Bazel based build). I know that there are files which can already be used for this. These files are located at:

$PROJECT_ROOT/bazel-out/_tmp/action_outs/

and are named stderr-XY.

Bazel has the ability to save all build events in a designated file. Note that currently (Bazel 0.14) there are 3 supported formats for that designated file, and those are: text file, JSON file and binary file. This question is related only to binary file.

If I have understood Google's protocol buffers correctly, the workflow for them to be implemented and to work is:

  1. You specify how you want the information you're serializing to be structured by defining protocol buffer message types in .proto files.
  2. Once you've defined your messages, you run the protocol buffer compiler (protoc) for your application's language on your .proto file to generate data access classes.
  3. Include generated files in your project and use generated class in your code. By use it is meant to populate, serialize and retrieve protocol buffer messages (i.e. for C++ which is the programming language that I use it is possible to use SerializeToOstream and ParseFromIstream methods for such tasks)

To conclude this question:

As it is stated here: "Have Bazel serialize the protocol buffer messages to a file by specifying the option --build_event_binary_file=/path/to/file. The file will contain serialized protocol buffer messages with each message being length delimited."

I do not see the way to avoid the fact that the developer who wants to use Bazel's functionality to write build events in a binary file, needs to know the "format" or even more concise to say Class architecture to read that binary file. Am I missing something here? Can all of this be done and how?

Also, I have tried to use protoc --decode_raw < bazelbepbinary.bin and it says:

Failed to parse input.

All of this was done on Ubuntu 16.04 and at the moment I'm not sure what is the GCC version but I will add GCC version to the question when I have to access to that information.

My side question is: is it possible to capture only those build events which reflect build warnings (without using some kind of filter e.g grep on generated file?) I have read the documentation and used:

bazel help build --long | grep "relevant_build_event_protocol_keywords"

and was unable to find anything like that in the API.

CleanCoder265
  • 574
  • 1
  • 5
  • 22
  • 4
    Yes, to use protobuf you will need the [.proto file](https://github.com/bazelbuild/bazel/blob/master/src/main/java/com/google/devtools/build/lib/buildeventstream/proto/build_event_stream.proto) describing the messages (linked from the documentation you linked to in the question). – Miles Budnek Jun 13 '18 at 21:07
  • So I will need to compile that .proto file that you have linked with protoc. For that I would need the entire bazel repo. Are there anywhere precompiled files which could be used for decoding the binary file? – CleanCoder265 Jun 14 '18 at 10:30

0 Answers0