Scanning for ABLD Errors and Warnings

Symbian’s ABLD build system tends to produce a lot of output, especially when run with the verbose flag (-v), as I like to do to see the compiler invocations. Also, ABLD likes to run to “completion” despite individual build steps failing. The end result is that it takes some effort to look for the errors and warnings in the output.

Some suggest scanning ABLD output in order to terminate the build on error or to highlight errors and warnings. I like to use a combination of these methods, by stopping the build on any error, and by highlighting any warnings in a different (red, in my case) color.

To implement such functionality, one can drive abld through a script

$ abld-filter.rb abld build -v gcce urel

where the abld-filter.rb script might be something like

#!/usr/bin/env ruby

def chcolor(num)
  "\033[#{num}m"
end

def red(text)
  "#{chcolor(31)}#{text}#{chcolor(0)}"
end

WARNING_RE = /warning/i
ERROR_RE = /(?:fatal error|^make.*Error|error: )/i

def sh_check_build_errors(cmd)
  IO::popen(cmd + ' 2>&1') do |input|
    input.each_line do |line|
      line.chomp!
      if line =~ WARNING_RE
        puts(red(line))
      else
        puts(line)
      end
      if line =~ ERROR_RE
        puts "build error"
        exit 1
      end
    end
  end
end

unless ARGV.empty?
  command = ARGV.join(" ")
  sh_check_build_errors(command)
end

With the highlighting set up, one might also want to intentionally produce warnings, just because they look so colorful. To point out to-do items using the C/C++ preprocessor, for instance.

#warning TODO: error checking to be implemented