rules_haskell
rules_haskell copied to clipboard
Show colour diagnostics in bazel builds
Is your feature request related to a problem? Please describe. GHC can colourise diagnostics, making them easier for a human to read. When outputting to a pipe, it disables colours. Bazel makes all tools output to a pipe. For clang, I've put a flag to force colour diagnostics always.
Describe the solution you'd like
I'd like rules_haskell to force-enable colour diagnostics on GHC. Or better yet, and maybe this already exists somewhere but I don't know about it: support setting global flags somewhere, like --copt but for haskell.
Describe alternatives you've considered
- I could put
-fdiagnostics-color=alwayson every haskell build rule. - I could make my own macros that add this flag to
compiler_flagsand wrap the rules_haskell macros.
Turns out, I can do this with haskell_toolchain and haskell_register_ghc_bindists, by setting compiler_flags there.
Nice workaround, but let's reopen - because perhaps we could consider doing this by default?
We could add a build_setting to control this.
It's worth pointing out though that from Bazel's perspective switching the value of -fdiagnostics-color= will invalidate a previously cached build. So, e.g. if CI builds are run without color output but developers use color output, then developers would not be able to use remote cache artifacts produced by CI builds.
We're using colour diagnostics on CI as well so sharing works.