Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there verbose logging for Bazel?

Tags:

java

bazel

I dig around Bazel source code, there aren't much logging it seems. Is there a way to enable some kind of verbose mode so I can see what bazel is doing?

Also there seems to be various kind of debug options but I cant seem to comprehend yet, if I want to debug say java_library how should I do it?

like image 827
HoaPhan Avatar asked Oct 09 '18 13:10

HoaPhan


People also ask

How does Bazel run work?

When running a build or a test, Bazel does the following: Loads the BUILD files relevant to the target. Analyzes the inputs and their dependencies, applies the specified build rules, and produces an action graph. Executes the build actions on the inputs until the final build outputs are produced.

Does Bazel run build?

Bazel allows you to perform a build from a completely read-only volume. To build a program with Bazel, type bazel build followed by the target you want to build. After issuing the command to build //foo , you'll see output similar to this: INFO: Analyzed target //foo:foo (14 packages loaded, 48 targets configured).

Where is Bazelrc?

Path: On Linux/macOS/Unixes: /etc/bazel. bazelrc. On Windows: %ProgramData%\bazel.


1 Answers

To debug what Bazel does and why:

  • To list the commands Bazel executes, use the "--[no]subcommands" flag.
  • To request listing just the failing commands, use the "--[no]verbose_failures" flag.
  • To request writing an explanation of the build, use the "--explain" flag. Use "--[no]verbose_explanations" to adjust verbosity.

To debug programs you built with Bazel:

  • You cannot debug java_library rules
  • You can debug java_binary rules. Build with "-c dbg" (see the "--compilation_mode" flag), then run the binary with bazel-bin/path/to/java/program --debug=<port>

EDIT: added info about --verbose_failures and --verbose_explanations

like image 122
László Avatar answered Sep 22 '22 12:09

László