rules_dotnet icon indicating copy to clipboard operation
rules_dotnet copied to clipboard

Allow setting compiler options on target/toolchain

Open jtaylor100 opened this issue 4 years ago • 3 comments

I was looking to enable the 'TreatWarningsAsErrors' option on a bazel package, but I'm lost trying to find somewhere to put the compiler options on the csharp_binary rule.

Does an attribute exist on csharp_binary like the javacopt on java_binary? Does the csharp compiler make this tricky to do?

jtaylor100 avatar Sep 21 '21 09:09 jtaylor100

This is not possible at the moment but it should be pretty easy to add this so that it can be declared on either the targets themselves or apply it to all targets by specifying them on the toolchain.

I might needs this feature in the not so far future to so I might implement it but it will be a few weeks probably.

purkhusid avatar Sep 23 '21 08:09 purkhusid

This is now possible on the next branch. It can be configured via config settings for global configuration or per target. The documentation is still not ready but it's the treat_warnings_as_errors, warnings_as_errors, warnings_not_as_errors attributes that can be used to configure this and then the @rules_dotnet//dotnet/settings:<treat_warnings_as_errors/warnings_as_errors/warnings_not_as_errors> config settings for global configuration

purkhusid avatar Aug 31 '22 15:08 purkhusid

I was too quick closing this since we don't allow setting arbitrary compiler flags. I'm not sure if and how we would implement that since a lot of the compiler flags have to be correctly configured just so the build works and allowing arbitrary flags could lead to hard to debug errrors.

purkhusid avatar Aug 31 '22 15:08 purkhusid

You can now add arbitrary compiler flags using the compiler_options attribute on the targets.

purkhusid avatar Apr 03 '24 15:04 purkhusid