Support `per_file_copt`
Options passed as --per_file_copt are currently not honored by rules_foreign_cc.
This is blocking us from enabling -Werror for our own code but ignoring warnings on external code where we have no control over.
We want to do this with the following .bazelrc:
build --per_file_copt=external/.*@-Wno-everything --host_per_file_copt=external/.*@-Wno-everything
build --copt=-Werror --host_copt=-Werror
See https://github.com/bazelbuild/bazel/issues/24528 for further details.
I'm not sure how you'd implement this as you'd need support from the configure script or the cmake script to apply flags to specific files which I don't think there is a general solution for.
What we support though is features and so you could add a feature to your toolchain that sets the desired flags and then set the features for your rules_foreign_cc targets?
@jsharpe thanks for your quick reply.
I do not have control over all rules_foreign_cc targets as some come in via transitive dependencies. I also get some errors for internal tools like make and pkgconfig.
Could there be a way to explicitly set additional copt for all rules_foreign_cc targets?
Another approach could be to match the regex (here external/.*) against the BUILD file or the cmake() rule itself and if matching then appending the per_file_copt to the copts for the whole the target.
Another approach could be to match the regex (here
external/.*) against theBUILDfile or thecmake()rule itself and if matching then appending theper_file_coptto thecoptsfor the whole the target.
I don't think starlark has visibility of the per_file_copt except indirectly via the cc_common API?
I don't think starlark has visibility of the
per_file_coptexcept indirectly via thecc_commonAPI?
@meteorcloudy @fmeum could you answer this?
bump on this, any new ideas on how to accomplish this other than patching every single third-party CMakeLists.txt?