Fork of the espurna firmware for `mhsw` switches
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.

45 lines
1.4 KiB

  1. #!/usr/bin/env python
  2. Import("env")
  3. # ------------------------------------------------------------------------------
  4. # Utils
  5. # ------------------------------------------------------------------------------
  6. class Color:
  7. BLACK = '\x1b[1;30m'
  8. RED = '\x1b[1;31m'
  9. GREEN = '\x1b[1;32m'
  10. YELLOW = '\x1b[1;33m'
  11. BLUE = '\x1b[1;34m'
  12. MAGENTA = '\x1b[1;35m'
  13. CYAN = '\x1b[1;36m'
  14. WHITE = '\x1b[1;37m'
  15. LIGHT_GREY = '\x1b[0;30m'
  16. LIGHT_RED = '\x1b[0;31m'
  17. LIGHT_GREEN = '\x1b[0;32m'
  18. LIGHT_YELLOW = '\x1b[0;33m'
  19. LIGHT_BLUE = '\x1b[0;34m'
  20. LIGHT_MAGENTA = '\x1b[0;35m'
  21. LIGHT_CYAN = '\x1b[0;36m'
  22. LIGHT_WHITE = '\x1b[0;37m'
  23. def clr(color, text):
  24. return color + str(text) + '\x1b[0m'
  25. # ------------------------------------------------------------------------------
  26. # Callbacks
  27. # ------------------------------------------------------------------------------
  28. def check_size(source, target, env):
  29. size = target[0].get_size()
  30. print clr(Color.LIGHT_BLUE, "Binary size: %s bytes" % size)
  31. if size > 512000:
  32. print clr(Color.LIGHT_RED, "File too large for OTA!")
  33. Exit(1)
  34. # ------------------------------------------------------------------------------
  35. # Hooks
  36. # ------------------------------------------------------------------------------
  37. print env.Dump()
  38. env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", check_size)