main_builders.py 2.2 KB

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