Cuadue
Cuadue

Reputation: 3929

How to solidify the order in which Bazel builds objects

I'm using Google Bazel to build a program. When I make a large change that affects multiple files, and rebuild, Bazel chooses one file at random to display the error message for. This causes a lot of editor churn, and I constantly lose my context. I fix one compilation error in one file, then rebuild, but I cannot see whether or not the fix worked because Bazel decides to fail on some other file.

Specifically if I have a target

cc_binary(name='foo',
          srcs=['bar.cc', 'qux.cc'])

and I run $ bazel build :foo then I will get error messages for bar.cc. If I run again without making any changes, then I will get (maybe) error messages.for qux.cc. I don't know what governs the randomness. Perhaps it is not meant to be known by mere mortals such as my lowly self?

Is there a way to solidify the order in which Bazel builds files, so that I don't have to jump "physically" and mentally between files? Reorienting mental context takes time, and when fixing dumb typos, that time is totally wasted.

What I would love is something like make whereby you can say $ make foo.o. Then I can fix foo.cc, and only after it builds then move on to bar.cc. Does Alphabet Google support such an advanced method?

Upvotes: 1

Views: 711

Answers (1)

ahumesky
ahumesky

Reputation: 5006

Try using --keep_going

That will tell bazel not to stop at the first error it finds, and instead try to build everything it can.

Upvotes: 2

Related Questions