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.

68 lines
1.9 KiB

6 years ago
  1. #!/usr/bin/env python
  2. from subprocess import call
  3. import os
  4. import time
  5. Import("env")
  6. # ------------------------------------------------------------------------------
  7. # Utils
  8. # ------------------------------------------------------------------------------
  9. class Color(object):
  10. BLACK = '\x1b[1;30m'
  11. RED = '\x1b[1;31m'
  12. GREEN = '\x1b[1;32m'
  13. YELLOW = '\x1b[1;33m'
  14. BLUE = '\x1b[1;34m'
  15. MAGENTA = '\x1b[1;35m'
  16. CYAN = '\x1b[1;36m'
  17. WHITE = '\x1b[1;37m'
  18. LIGHT_GREY = '\x1b[0;30m'
  19. LIGHT_RED = '\x1b[0;31m'
  20. LIGHT_GREEN = '\x1b[0;32m'
  21. LIGHT_YELLOW = '\x1b[0;33m'
  22. LIGHT_BLUE = '\x1b[0;34m'
  23. LIGHT_MAGENTA = '\x1b[0;35m'
  24. LIGHT_CYAN = '\x1b[0;36m'
  25. LIGHT_WHITE = '\x1b[0;37m'
  26. def clr(color, text):
  27. return color + str(text) + '\x1b[0m'
  28. # ------------------------------------------------------------------------------
  29. # Callbacks
  30. # ------------------------------------------------------------------------------
  31. def remove_float_support():
  32. flags = " ".join(env['LINKFLAGS'])
  33. flags = flags.replace("-u _printf_float", "")
  34. flags = flags.replace("-u _scanf_float", "")
  35. newflags = flags.split()
  36. env.Replace(
  37. LINKFLAGS = newflags
  38. )
  39. def cpp_check(source, target, env):
  40. print("Started cppcheck...\n")
  41. call(["cppcheck", os.getcwd()+"/espurna", "--force", "--enable=all"])
  42. print("Finished cppcheck...\n")
  43. def check_size(source, target, env):
  44. time.sleep(2)
  45. size = target[0].get_size()
  46. print clr(Color.LIGHT_BLUE, "Binary size: %s bytes" % size)
  47. #if size > 512000:
  48. # print clr(Color.LIGHT_RED, "File too large for OTA!")
  49. # Exit(1)
  50. # ------------------------------------------------------------------------------
  51. # Hooks
  52. # ------------------------------------------------------------------------------
  53. remove_float_support()
  54. #env.AddPreAction("buildprog", cpp_check)
  55. env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", check_size)