jack2 codebase
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.3KB

  1. #!/usr/bin/env python
  2. # encoding: utf-8
  3. # Replaces the default formatter by one which understands RVCT output and colorizes it.
  4. __author__ = __maintainer__ = "Jérôme Carretero <cJ-waf@zougloub.eu>"
  5. __copyright__ = "Jérôme Carretero, 2012"
  6. import sys
  7. import atexit
  8. from waflib import Logs
  9. errors = []
  10. def show_errors():
  11. for i, e in enumerate(errors):
  12. if i > 5:
  13. break
  14. print("Error: %s" % e)
  15. atexit.register(show_errors)
  16. class RcvtFormatter(Logs.formatter):
  17. def __init__(self, colors):
  18. Logs.formatter.__init__(self)
  19. self.colors = colors
  20. def format(self, rec):
  21. frame = sys._getframe()
  22. while frame:
  23. func = frame.f_code.co_name
  24. if func == 'exec_command':
  25. cmd = frame.f_locals['cmd']
  26. if isinstance(cmd, list) and ('armcc' in cmd[0] or 'armld' in cmd[0]):
  27. lines = []
  28. for line in rec.msg.splitlines():
  29. if 'Warning: ' in line:
  30. lines.append(self.colors.YELLOW + line)
  31. elif 'Error: ' in line:
  32. lines.append(self.colors.RED + line)
  33. errors.append(line)
  34. elif 'note: ' in line:
  35. lines.append(self.colors.CYAN + line)
  36. else:
  37. lines.append(line)
  38. rec.msg = "\n".join(lines)
  39. frame = frame.f_back
  40. return Logs.formatter.format(self, rec)
  41. def options(opt):
  42. Logs.log.handlers[0].setFormatter(RcvtFormatter(Logs.colors))