main_builders.py 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. """Functions used to generate source files during build time"""
  2. def make_splash(target, source, env):
  3. src = str(source[0])
  4. dst = str(target[0])
  5. with open(src, "rb") as f:
  6. buf = f.read()
  7. with open(dst, "w", encoding="utf-8", newline="\n") as g:
  8. g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
  9. g.write("#ifndef BOOT_SPLASH_H\n")
  10. g.write("#define BOOT_SPLASH_H\n")
  11. # Use a neutral gray color to better fit various kinds of projects.
  12. g.write("static const Color boot_splash_bg_color = Color(0.14, 0.14, 0.14);\n")
  13. g.write("static const unsigned char boot_splash_png[] = {\n")
  14. for i in range(len(buf)):
  15. g.write(str(buf[i]) + ",\n")
  16. g.write("};\n")
  17. g.write("#endif")
  18. def make_splash_editor(target, source, env):
  19. src = str(source[0])
  20. dst = str(target[0])
  21. with open(src, "rb") as f:
  22. buf = f.read()
  23. with open(dst, "w", encoding="utf-8", newline="\n") as g:
  24. g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
  25. g.write("#ifndef BOOT_SPLASH_EDITOR_H\n")
  26. g.write("#define BOOT_SPLASH_EDITOR_H\n")
  27. # The editor splash background color is taken from the default editor theme's background color.
  28. # This helps achieve a visually "smoother" transition between the splash screen and the editor.
  29. g.write("static const Color boot_splash_editor_bg_color = Color(0.125, 0.145, 0.192);\n")
  30. g.write("static const unsigned char boot_splash_editor_png[] = {\n")
  31. for i in range(len(buf)):
  32. g.write(str(buf[i]) + ",\n")
  33. g.write("};\n")
  34. g.write("#endif")
  35. def make_app_icon(target, source, env):
  36. src = str(source[0])
  37. dst = str(target[0])
  38. with open(src, "rb") as f:
  39. buf = f.read()
  40. with open(dst, "w", encoding="utf-8", newline="\n") as g:
  41. g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
  42. g.write("#ifndef APP_ICON_H\n")
  43. g.write("#define APP_ICON_H\n")
  44. g.write("static const unsigned char app_icon_png[] = {\n")
  45. for i in range(len(buf)):
  46. g.write(str(buf[i]) + ",\n")
  47. g.write("};\n")
  48. g.write("#endif")