Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

How to capture the console output(stderr) of a cc_binary target

25 views
Skip to first unread message

Vasilena Milchova

unread,
Jan 3, 2025, 10:56:12 AMJan 3
to bazel-discuss
I have a cc_binary target that is compiling some .c files. When I build it I get the compiler warnings in the terminal and I am using this to capture them to a file:
bazel build path/to/target:my_target 2>&1 | Out-File -FilePath build_compiler_warnings.txt -Encoding utf8
Now I want every time that I build my_target to get a file with the warnings automatically, is there such way, because I have tried multiple solutions and nothing worked.

For another solution I found that for my compiler there is actually a flag that is redirecting the stderr to a file, and I am giving it in the copts of the cc_binary now to get the warnings file. But the file is not cached, and it is only created when something is compiled, but I need it all the time, is there a way to copy it or cache it, because I could not find such.
Reply all
Reply to author
Forward
0 new messages