rules_haskell icon indicating copy to clipboard operation
rules_haskell copied to clipboard

Show colour diagnostics in bazel builds

Open iphydf opened this issue 5 years ago • 4 comments

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=always on every haskell build rule.
  • I could make my own macros that add this flag to compiler_flags and wrap the rules_haskell macros.

iphydf avatar Mar 22 '20 12:03 iphydf

Turns out, I can do this with haskell_toolchain and haskell_register_ghc_bindists, by setting compiler_flags there.

iphydf avatar Mar 22 '20 12:03 iphydf

Nice workaround, but let's reopen - because perhaps we could consider doing this by default?

mboes avatar Mar 22 '20 13:03 mboes

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.

aherrmann avatar Feb 21 '22 13:02 aherrmann

We're using colour diagnostics on CI as well so sharing works.

iphydf avatar Feb 27 '22 09:02 iphydf