Turning off C++ warnings as errors in external repos

388 views
Skip to first unread message

carpen...@gmail.com

unread,
Jan 16, 2023, 11:38:27 AM1/16/23
to bazel-discuss
Hi, 

I have a custom C++ toolchain and require warnings as errors to be turned on for our primary repo, however we do not want to get warnings as errors from all our third-party repositories. I am after a way to disable features/change Command-line options when compiling anything under external. 

I don't want to patch all the external build files unless needed. 
As far as I am aware features have a global/package/target scope. 
I don't want to wrap the cc_library in a macro unless unavoidable.

What is the best way of achieving warnings as errors for production code?
This is currently in bazel 5.3.2 - however we do plan to migrate to 5.4.0 then 6.0.0

Thanks

James

Phil Schrader

unread,
Jan 17, 2023, 1:13:50 PM1/17/23
to bazel-discuss
We have these lines in our bazelrc file which might be helpful. I have not validated that they actually work.
We've had them there for many years without touching them so I suspect it's possible that they're NOPs.

# Enable -Werror for all our code, but exclude for third-party.
build --per_file_copt=-third_party/.*,-external/.*@-Werror
# NOTE: Explicitly disable -Werror because the `-external/.*` filter does not work
build --per_file_copt=third_party/.*,external/.*@-Wno-error

Phil
Reply all
Reply to author
Forward
0 new messages