Categories
Mozilla Technology

Highlight Warnings in Make

Curtis just gave me this incredibly handy piece of code that higlights errors and warnings in make output. Now, when I’m building, all the warnings are highlighted in yellow, and the errors in red. Just put the following in your bash profile script:

make()
{
  pathpat="(/[^/]*)+:[0-9]+"
  ccred=$(echo -e "\033[0;31m")
  ccyellow=$(echo -e "\033[0;33m")
  ccend=$(echo -e "\033[0m")
  /usr/bin/make "$@" 2>&1 | sed -E -e "/[Ee]rror[: ]/ s%$pathpat%$ccred&$ccend%g" -e "/[Ww]arning[: ]/ s%$pathpat%$ccyellow&$ccend%g"
  return ${PIPESTATUS[0]}
}

Of course, improvements and more ideas welcome! Thanks goes to Curtis for this!

By Shawn Wilsher

The man behind the site.

10 replies on “Highlight Warnings in Make”

Nope. It’s giving me curly quotes for the terminating quote on the first line, the opening quote on the 2nd line, and the ones around warning in the 2nd to last line. If you look at the source code of this page, wordpress is converting the quote characters into & # 8221; and & # 8220; (hopefully I spaced that out enough that it won’t convert them into the actual characters here…)

(on windows, but obviously the wordpress output is system agnostic)

Any way we can get this styling applied to the buildlogs submitted to tinderbox so that it’s easier to spot the problems when investigating a failed build?

for sed, -E appears to be an OSX only flag. I think the linux equivalent is -r, so:

make()
{
  pathpat="(/[^/]*)+:[0-9]+"
  ccred=$(echo -e "33[0;31m")
  ccyellow=$(echo -e "33[0;33m")
  ccend=$(echo -e "33[0m")
  /usr/bin/make "$@" 2>&1 | sed -r -e "/[Ee]rror[: ]/ s%$pathpat%$ccred&$ccend%g" -e "/[Ww]arning[: ]/ s%$pathpat%$ccyellow&$ccend%g"
  return ${PIPESTATUS[0]}
}

Comments are closed.