I am currently trying to measure the time bazel build //api/...
takes to build our "api" project with different --spawn_strategy
s.
I am having a hard time doing so because Bazel doesn't rebuild anything as long as I don't touch the source files.
I was able to force rebuilds by editing all files inside our "api" project, but doing this repeatedly is cumbersome.
What is the best way to force Bazel to rebuild so that I can measure build times for our repository?
Preferably, I would like to use something like bazel build //api/... --some_option_which_forces_rebuilding
or something similar.
Bazel expunge will remove all downloaded artifacts.
Debugging Bazel To debug the C++ client, run it from gdb or lldb as usual. However, to debug Java code, attach to the server using the following: Run Bazel with the debugging option --host_jvm_debug before the command (such as bazel --host_jvm_debug build //src:bazel ). Attach a debugger to the port 5005.
On Linux/macOS/Unixes: /etc/bazel. bazelrc. On Windows: %ProgramData%\bazel.
The Bazel user's build state is located beneath outputRoot/_bazel_$USER . This is called the outputUserRoot directory. Beneath the outputUserRoot directory there is an install directory, and in it is an installBase directory whose name is the MD5 hash of the Bazel installation manifest.
A bit dirty, but you could use --action_env
to change the build environment and invalidate all the actions. From the docs:
Environment variables are considered an essential part of an action. In other words, an action is expected to produce a different output, if the environment it is invoked in differs; in particular, a previously cached value cannot be taken if the effective environment changes.
also (from this page):
[...] The value of those environment variable can be enforced from the command line with the --action_env flag (but this flag will invalidate every action of the build).
Just setting a random variable should be enough:
> bazel build --action_env="avariable=1" :mytarget
> bazel build --action_env="avariable=2" :mytarget
> ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With