@geastack/targets 0.1.77

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (348) hide show
  1. package/LICENSE +674 -0
  2. package/README.md +83 -0
  3. package/package.json +50 -0
  4. package/targets/cmake/geatsc-generated-archive-build.mjs +614 -0
  5. package/targets/cmake/geatsc_generated_archive.cmake +116 -0
  6. package/targets/cmake/geatsc_generated_archive_build.cmake +50 -0
  7. package/targets/esp32/app_project.cmake +33 -0
  8. package/targets/esp32/apps/app_manager.cpp +188 -0
  9. package/targets/esp32/apps/app_manager.h +10 -0
  10. package/targets/esp32/chip_bindings/README.md +58 -0
  11. package/targets/esp32/chip_bindings/audio/es8311.cpp +556 -0
  12. package/targets/esp32/chip_bindings/displays/co5300.cpp +510 -0
  13. package/targets/esp32/chip_bindings/displays/co5300.h +47 -0
  14. package/targets/esp32/chip_bindings/displays/co5300_async_stream.inc +79 -0
  15. package/targets/esp32/chip_bindings/displays/qspi_panel.h +65 -0
  16. package/targets/esp32/chip_bindings/displays/sh8601.cpp +583 -0
  17. package/targets/esp32/chip_bindings/displays/sh8601.h +36 -0
  18. package/targets/esp32/chip_bindings/gps/lc76g.cpp +296 -0
  19. package/targets/esp32/chip_bindings/gps/lc76g.h +7 -0
  20. package/targets/esp32/chip_bindings/imu/bmi270.cpp +299 -0
  21. package/targets/esp32/chip_bindings/imu/bmi270_config.inl +439 -0
  22. package/targets/esp32/chip_bindings/imu/qmi8658.cpp +213 -0
  23. package/targets/esp32/chip_bindings/power/axp2101.cpp +185 -0
  24. package/targets/esp32/chip_bindings/touch/cst9217.cpp +229 -0
  25. package/targets/esp32/chip_bindings/touch/cst9217_controller.h +78 -0
  26. package/targets/esp32/chip_bindings/touch/ft3168.cpp +340 -0
  27. package/targets/esp32/chip_bindings/touch/ft3168_controller.h +103 -0
  28. package/targets/esp32/chip_bindings/touch/ft6336.cpp +310 -0
  29. package/targets/esp32/chip_bindings/touch/ft6336_controller.h +90 -0
  30. package/targets/esp32/components/gea_framework/CMakeLists.txt +62 -0
  31. package/targets/esp32/connectivity/ble_hid.cpp +2916 -0
  32. package/targets/esp32/connectivity/ble_hid.h +8 -0
  33. package/targets/esp32/connectivity/diagnostics_transport.cpp +523 -0
  34. package/targets/esp32/connectivity/diagnostics_transport_offline.cpp +108 -0
  35. package/targets/esp32/connectivity/wifi.cpp +615 -0
  36. package/targets/esp32/connectivity/wifi_debug_offline.cpp +37 -0
  37. package/targets/esp32/connectivity/wifi_task_stack.h +119 -0
  38. package/targets/esp32/display.cpp +6010 -0
  39. package/targets/esp32/display_headless.cpp +468 -0
  40. package/targets/esp32/gea/platform_random.h +11 -0
  41. package/targets/esp32/gea_framework.cmake +382 -0
  42. package/targets/esp32/gpio.cpp +229 -0
  43. package/targets/esp32/host_sources.cmake +35 -0
  44. package/targets/esp32/imu_absent.cpp +36 -0
  45. package/targets/esp32/ldfragments/gea_ui_state_external.lf +35 -0
  46. package/targets/esp32/memory_config.h +64 -0
  47. package/targets/esp32/power_absent.cpp +22 -0
  48. package/targets/esp32/sdk-patches/0001-esp_ptr_dma_capable-accept-PSRAM.patch +70 -0
  49. package/targets/esp32/sdk-patches/0002-gdma-access_ext_mem-spi_master.patch +59 -0
  50. package/targets/esp32/sdk-patches/README.md +127 -0
  51. package/targets/esp32/services/app_runner.cpp +248 -0
  52. package/targets/esp32/services/app_state.cpp +56 -0
  53. package/targets/esp32/services/audio_runtime_stub.cpp +86 -0
  54. package/targets/esp32/services/battery_service.cpp +31 -0
  55. package/targets/esp32/services/device_control.cpp +1896 -0
  56. package/targets/esp32/services/device_control.h +31 -0
  57. package/targets/esp32/services/frame_scheduler.cpp +1571 -0
  58. package/targets/esp32/services/heap.cpp +129 -0
  59. package/targets/esp32/services/memory.cpp +103 -0
  60. package/targets/esp32/services/ota.cpp +840 -0
  61. package/targets/esp32/services/ota_image.cpp +162 -0
  62. package/targets/esp32/services/ota_image.h +16 -0
  63. package/targets/esp32/services/storage_service.cpp +159 -0
  64. package/targets/esp32/touch_absent.cpp +44 -0
  65. package/targets/esp32-m5stack-m5paper/CMakeLists.txt +10 -0
  66. package/targets/esp32-m5stack-m5paper/README.md +55 -0
  67. package/targets/esp32-m5stack-m5paper/dependencies.lock +76 -0
  68. package/targets/esp32-m5stack-m5paper/main/CMakeLists.txt +46 -0
  69. package/targets/esp32-m5stack-m5paper/main/Kconfig.projbuild +10 -0
  70. package/targets/esp32-m5stack-m5paper/main/app_main.cpp +114 -0
  71. package/targets/esp32-m5stack-m5paper/main/audio_stub.cpp +27 -0
  72. package/targets/esp32-m5stack-m5paper/main/buttons.cpp +111 -0
  73. package/targets/esp32-m5stack-m5paper/main/display.cpp +1074 -0
  74. package/targets/esp32-m5stack-m5paper/main/i2c.cpp +36 -0
  75. package/targets/esp32-m5stack-m5paper/main/idf_component.yml +7 -0
  76. package/targets/esp32-m5stack-m5paper/main/imu_stub.cpp +20 -0
  77. package/targets/esp32-m5stack-m5paper/main/include/board.h +100 -0
  78. package/targets/esp32-m5stack-m5paper/main/include/buttons.h +8 -0
  79. package/targets/esp32-m5stack-m5paper/main/launcher_button.cpp +82 -0
  80. package/targets/esp32-m5stack-m5paper/main/m5paper_psram.lf +20 -0
  81. package/targets/esp32-m5stack-m5paper/main/power.cpp +73 -0
  82. package/targets/esp32-m5stack-m5paper/main/sdcard_mount.cpp +82 -0
  83. package/targets/esp32-m5stack-m5paper/main/touch.cpp +279 -0
  84. package/targets/esp32-m5stack-m5paper/partitions.csv +9 -0
  85. package/targets/esp32-m5stack-m5paper/sdkconfig.defaults +84 -0
  86. package/targets/esp32-p4-m5stack-tab5/CMakeLists.txt +10 -0
  87. package/targets/esp32-p4-m5stack-tab5/dependencies.lock +276 -0
  88. package/targets/esp32-p4-m5stack-tab5/main/CMakeLists.txt +586 -0
  89. package/targets/esp32-p4-m5stack-tab5/main/Kconfig.projbuild +12 -0
  90. package/targets/esp32-p4-m5stack-tab5/main/app_main.cpp +177 -0
  91. package/targets/esp32-p4-m5stack-tab5/main/camera.cpp +2025 -0
  92. package/targets/esp32-p4-m5stack-tab5/main/display.cpp +4033 -0
  93. package/targets/esp32-p4-m5stack-tab5/main/fatfs_ffconf.h +383 -0
  94. package/targets/esp32-p4-m5stack-tab5/main/i2c.cpp +39 -0
  95. package/targets/esp32-p4-m5stack-tab5/main/idf_component.yml +21 -0
  96. package/targets/esp32-p4-m5stack-tab5/main/include/board.h +130 -0
  97. package/targets/esp32-p4-m5stack-tab5/main/include/tab5_drivers.h +68 -0
  98. package/targets/esp32-p4-m5stack-tab5/main/include/wifi_config.h.example +5 -0
  99. package/targets/esp32-p4-m5stack-tab5/main/launcher_button.cpp +188 -0
  100. package/targets/esp32-p4-m5stack-tab5/main/power.cpp +22 -0
  101. package/targets/esp32-p4-m5stack-tab5/main/sdcard_mount.cpp +125 -0
  102. package/targets/esp32-p4-m5stack-tab5/main/tab5_audio.cpp +345 -0
  103. package/targets/esp32-p4-m5stack-tab5/main/tab5_drivers.cpp +871 -0
  104. package/targets/esp32-p4-m5stack-tab5/main/tab5_imu.cpp +246 -0
  105. package/targets/esp32-p4-m5stack-tab5/main/touch.cpp +206 -0
  106. package/targets/esp32-p4-m5stack-tab5/partitions.csv +12 -0
  107. package/targets/esp32-p4-m5stack-tab5/sdkconfig.defaults +128 -0
  108. package/targets/esp32-p4-waveshare-touch-lcd-3.5/CMakeLists.txt +19 -0
  109. package/targets/esp32-p4-waveshare-touch-lcd-3.5/component-patches/0001-esp_video-csi-raw-passthrough-p4-rev-lt-v3.patch +28 -0
  110. package/targets/esp32-p4-waveshare-touch-lcd-3.5/component-patches/README.md +45 -0
  111. package/targets/esp32-p4-waveshare-touch-lcd-3.5/component-patches/apply.sh +37 -0
  112. package/targets/esp32-p4-waveshare-touch-lcd-3.5/dependencies.lock +196 -0
  113. package/targets/esp32-p4-waveshare-touch-lcd-3.5/main/CMakeLists.txt +562 -0
  114. package/targets/esp32-p4-waveshare-touch-lcd-3.5/main/Kconfig.projbuild +12 -0
  115. package/targets/esp32-p4-waveshare-touch-lcd-3.5/main/app_main.cpp +166 -0
  116. package/targets/esp32-p4-waveshare-touch-lcd-3.5/main/camera.cpp +2105 -0
  117. package/targets/esp32-p4-waveshare-touch-lcd-3.5/main/display.cpp +1730 -0
  118. package/targets/esp32-p4-waveshare-touch-lcd-3.5/main/fatfs_ffconf.h +383 -0
  119. package/targets/esp32-p4-waveshare-touch-lcd-3.5/main/i2c.cpp +39 -0
  120. package/targets/esp32-p4-waveshare-touch-lcd-3.5/main/idf_component.yml +11 -0
  121. package/targets/esp32-p4-waveshare-touch-lcd-3.5/main/include/board.h +87 -0
  122. package/targets/esp32-p4-waveshare-touch-lcd-3.5/main/include/panel_native.h +59 -0
  123. package/targets/esp32-p4-waveshare-touch-lcd-3.5/main/include/wifi_config.h.example +5 -0
  124. package/targets/esp32-p4-waveshare-touch-lcd-3.5/main/launcher_button.cpp +191 -0
  125. package/targets/esp32-p4-waveshare-touch-lcd-3.5/main/power.cpp +15 -0
  126. package/targets/esp32-p4-waveshare-touch-lcd-3.5/main/touch.cpp +306 -0
  127. package/targets/esp32-p4-waveshare-touch-lcd-3.5/partitions.csv +13 -0
  128. package/targets/esp32-p4-waveshare-touch-lcd-3.5/patches/README.md +22 -0
  129. package/targets/esp32-p4-waveshare-touch-lcd-3.5/patches/espressif__esp_video-csi-bypass.patch +28 -0
  130. package/targets/esp32-p4-waveshare-touch-lcd-3.5/sdkconfig.defaults +109 -0
  131. package/targets/esp32-p4-waveshare-touch-lcd-3.5/tools/README-camera-capture.md +84 -0
  132. package/targets/esp32-p4-waveshare-touch-lcd-3.5/tools/capture-camera.py +369 -0
  133. package/targets/esp32-p4-waveshare-touch-lcd-7/CMakeLists.txt +10 -0
  134. package/targets/esp32-p4-waveshare-touch-lcd-7/dependencies.lock +258 -0
  135. package/targets/esp32-p4-waveshare-touch-lcd-7/main/CMakeLists.txt +577 -0
  136. package/targets/esp32-p4-waveshare-touch-lcd-7/main/Kconfig.projbuild +12 -0
  137. package/targets/esp32-p4-waveshare-touch-lcd-7/main/app_main.cpp +177 -0
  138. package/targets/esp32-p4-waveshare-touch-lcd-7/main/camera.cpp +1935 -0
  139. package/targets/esp32-p4-waveshare-touch-lcd-7/main/display.cpp +2832 -0
  140. package/targets/esp32-p4-waveshare-touch-lcd-7/main/fatfs_ffconf.h +383 -0
  141. package/targets/esp32-p4-waveshare-touch-lcd-7/main/i2c.cpp +39 -0
  142. package/targets/esp32-p4-waveshare-touch-lcd-7/main/idf_component.yml +23 -0
  143. package/targets/esp32-p4-waveshare-touch-lcd-7/main/include/board.h +68 -0
  144. package/targets/esp32-p4-waveshare-touch-lcd-7/main/include/wifi_config.h.example +5 -0
  145. package/targets/esp32-p4-waveshare-touch-lcd-7/main/launcher_button.cpp +191 -0
  146. package/targets/esp32-p4-waveshare-touch-lcd-7/main/power.cpp +15 -0
  147. package/targets/esp32-p4-waveshare-touch-lcd-7/main/sdcard_mount.cpp +125 -0
  148. package/targets/esp32-p4-waveshare-touch-lcd-7/main/touch.cpp +332 -0
  149. package/targets/esp32-p4-waveshare-touch-lcd-7/partitions.csv +12 -0
  150. package/targets/esp32-p4-waveshare-touch-lcd-7/sdkconfig.defaults +122 -0
  151. package/targets/esp32-p4-waveshare-touch-lcd-7/tools/README-camera-capture.md +84 -0
  152. package/targets/esp32-p4-waveshare-touch-lcd-7/tools/capture-camera.py +369 -0
  153. package/targets/esp32-s3-devkit-n16r8.json +31 -0
  154. package/targets/esp32-s3-elecrow-rotary-2.1/CMakeLists.txt +10 -0
  155. package/targets/esp32-s3-elecrow-rotary-2.1/dependencies.lock +40 -0
  156. package/targets/esp32-s3-elecrow-rotary-2.1/main/CMakeLists.txt +549 -0
  157. package/targets/esp32-s3-elecrow-rotary-2.1/main/Kconfig.projbuild +12 -0
  158. package/targets/esp32-s3-elecrow-rotary-2.1/main/app_main.cpp +187 -0
  159. package/targets/esp32-s3-elecrow-rotary-2.1/main/display_rgb.cpp +1338 -0
  160. package/targets/esp32-s3-elecrow-rotary-2.1/main/i2c.cpp +39 -0
  161. package/targets/esp32-s3-elecrow-rotary-2.1/main/idf_component.yml +5 -0
  162. package/targets/esp32-s3-elecrow-rotary-2.1/main/include/board.h +142 -0
  163. package/targets/esp32-s3-elecrow-rotary-2.1/main/include/pcf8574.h +16 -0
  164. package/targets/esp32-s3-elecrow-rotary-2.1/main/include/rotary_encoder.h +7 -0
  165. package/targets/esp32-s3-elecrow-rotary-2.1/main/launcher_button.cpp +191 -0
  166. package/targets/esp32-s3-elecrow-rotary-2.1/main/pcf8574.cpp +86 -0
  167. package/targets/esp32-s3-elecrow-rotary-2.1/main/platform_stubs.cpp +47 -0
  168. package/targets/esp32-s3-elecrow-rotary-2.1/main/rotary_encoder.cpp +135 -0
  169. package/targets/esp32-s3-elecrow-rotary-2.1/main/touch.cpp +250 -0
  170. package/targets/esp32-s3-elecrow-rotary-2.1/partitions.csv +8 -0
  171. package/targets/esp32-s3-elecrow-rotary-2.1/sdkconfig.defaults +116 -0
  172. package/targets/esp32-s3-epaper-1.54/CMakeLists.txt +10 -0
  173. package/targets/esp32-s3-epaper-1.54/dependencies.lock +76 -0
  174. package/targets/esp32-s3-epaper-1.54/main/CMakeLists.txt +691 -0
  175. package/targets/esp32-s3-epaper-1.54/main/Kconfig.projbuild +12 -0
  176. package/targets/esp32-s3-epaper-1.54/main/app_main.cpp +181 -0
  177. package/targets/esp32-s3-epaper-1.54/main/buttons.cpp +144 -0
  178. package/targets/esp32-s3-epaper-1.54/main/display.cpp +1281 -0
  179. package/targets/esp32-s3-epaper-1.54/main/fatfs_ffconf.h +377 -0
  180. package/targets/esp32-s3-epaper-1.54/main/i2c.cpp +39 -0
  181. package/targets/esp32-s3-epaper-1.54/main/idf_component.yml +7 -0
  182. package/targets/esp32-s3-epaper-1.54/main/imu_stub.cpp +21 -0
  183. package/targets/esp32-s3-epaper-1.54/main/include/board.h +119 -0
  184. package/targets/esp32-s3-epaper-1.54/main/include/buttons.h +9 -0
  185. package/targets/esp32-s3-epaper-1.54/main/include/wifi_config.h.example +5 -0
  186. package/targets/esp32-s3-epaper-1.54/main/launcher_button.cpp +191 -0
  187. package/targets/esp32-s3-epaper-1.54/main/power.cpp +15 -0
  188. package/targets/esp32-s3-epaper-1.54/main/sdcard_mount.cpp +89 -0
  189. package/targets/esp32-s3-epaper-1.54/main/touch.cpp +299 -0
  190. package/targets/esp32-s3-epaper-1.54/partitions.csv +8 -0
  191. package/targets/esp32-s3-epaper-1.54/sdkconfig.defaults +217 -0
  192. package/targets/esp32-s3-lilygo-t-display-s3-long/CMakeLists.txt +10 -0
  193. package/targets/esp32-s3-lilygo-t-display-s3-long/README.md +29 -0
  194. package/targets/esp32-s3-lilygo-t-display-s3-long/dependencies.lock +116 -0
  195. package/targets/esp32-s3-lilygo-t-display-s3-long/main/CMakeLists.txt +90 -0
  196. package/targets/esp32-s3-lilygo-t-display-s3-long/main/idf_component.yml +7 -0
  197. package/targets/esp32-s3-lilygo-t-display-s3-long/main/include/board.h +61 -0
  198. package/targets/esp32-s3-lilygo-t-display-s3-long/main/touch.cpp +299 -0
  199. package/targets/esp32-s3-lilygo-t-display-s3-long/partitions.csv +7 -0
  200. package/targets/esp32-s3-lilygo-t-display-s3-long/sdkconfig.defaults +50 -0
  201. package/targets/esp32-s3-lilygo-t5-epaper-4.7/CMakeLists.txt +12 -0
  202. package/targets/esp32-s3-lilygo-t5-epaper-4.7/components/epd_driver/CMakeLists.txt +17 -0
  203. package/targets/esp32-s3-lilygo-t5-epaper-4.7/components/epd_driver/ed047tc1.c +269 -0
  204. package/targets/esp32-s3-lilygo-t5-epaper-4.7/components/epd_driver/ed047tc1.h +142 -0
  205. package/targets/esp32-s3-lilygo-t5-epaper-4.7/components/epd_driver/epd_driver.c +1114 -0
  206. package/targets/esp32-s3-lilygo-t5-epaper-4.7/components/epd_driver/epd_driver.h +410 -0
  207. package/targets/esp32-s3-lilygo-t5-epaper-4.7/components/epd_driver/gea_epd.c +989 -0
  208. package/targets/esp32-s3-lilygo-t5-epaper-4.7/components/epd_driver/i2s_data_bus.c +489 -0
  209. package/targets/esp32-s3-lilygo-t5-epaper-4.7/components/epd_driver/i2s_data_bus.h +104 -0
  210. package/targets/esp32-s3-lilygo-t5-epaper-4.7/components/epd_driver/rmt_pulse.c +136 -0
  211. package/targets/esp32-s3-lilygo-t5-epaper-4.7/components/epd_driver/rmt_pulse.h +78 -0
  212. package/targets/esp32-s3-lilygo-t5-epaper-4.7/components/epd_driver/utilities.h +49 -0
  213. package/targets/esp32-s3-lilygo-t5-epaper-4.7/dependencies.lock +35 -0
  214. package/targets/esp32-s3-lilygo-t5-epaper-4.7/main/CMakeLists.txt +30 -0
  215. package/targets/esp32-s3-lilygo-t5-epaper-4.7/main/Kconfig.projbuild +10 -0
  216. package/targets/esp32-s3-lilygo-t5-epaper-4.7/main/app_main.cpp +95 -0
  217. package/targets/esp32-s3-lilygo-t5-epaper-4.7/main/audio_stub.cpp +27 -0
  218. package/targets/esp32-s3-lilygo-t5-epaper-4.7/main/buttons.cpp +40 -0
  219. package/targets/esp32-s3-lilygo-t5-epaper-4.7/main/display.cpp +627 -0
  220. package/targets/esp32-s3-lilygo-t5-epaper-4.7/main/i2c.cpp +36 -0
  221. package/targets/esp32-s3-lilygo-t5-epaper-4.7/main/idf_component.yml +4 -0
  222. package/targets/esp32-s3-lilygo-t5-epaper-4.7/main/imu_stub.cpp +20 -0
  223. package/targets/esp32-s3-lilygo-t5-epaper-4.7/main/include/board.h +85 -0
  224. package/targets/esp32-s3-lilygo-t5-epaper-4.7/main/include/buttons.h +8 -0
  225. package/targets/esp32-s3-lilygo-t5-epaper-4.7/main/launcher_button.cpp +82 -0
  226. package/targets/esp32-s3-lilygo-t5-epaper-4.7/main/power.cpp +36 -0
  227. package/targets/esp32-s3-lilygo-t5-epaper-4.7/main/sdcard_mount.cpp +90 -0
  228. package/targets/esp32-s3-lilygo-t5-epaper-4.7/main/touch.cpp +293 -0
  229. package/targets/esp32-s3-lilygo-t5-epaper-4.7/partitions.csv +9 -0
  230. package/targets/esp32-s3-lilygo-t5-epaper-4.7/sdkconfig.defaults +217 -0
  231. package/targets/esp32-s3-m5stack-papers3/CMakeLists.txt +13 -0
  232. package/targets/esp32-s3-m5stack-papers3/components/papers3_epd/CMakeLists.txt +5 -0
  233. package/targets/esp32-s3-m5stack-papers3/components/papers3_epd/include/papers3_epd.h +74 -0
  234. package/targets/esp32-s3-m5stack-papers3/components/papers3_epd/papers3_epd.c +671 -0
  235. package/targets/esp32-s3-m5stack-papers3/dependencies.lock +76 -0
  236. package/targets/esp32-s3-m5stack-papers3/main/CMakeLists.txt +64 -0
  237. package/targets/esp32-s3-m5stack-papers3/main/Kconfig.projbuild +10 -0
  238. package/targets/esp32-s3-m5stack-papers3/main/app_main.cpp +96 -0
  239. package/targets/esp32-s3-m5stack-papers3/main/audio_stub.cpp +27 -0
  240. package/targets/esp32-s3-m5stack-papers3/main/buttons.cpp +49 -0
  241. package/targets/esp32-s3-m5stack-papers3/main/display.cpp +706 -0
  242. package/targets/esp32-s3-m5stack-papers3/main/i2c.cpp +36 -0
  243. package/targets/esp32-s3-m5stack-papers3/main/idf_component.yml +14 -0
  244. package/targets/esp32-s3-m5stack-papers3/main/imu.cpp +351 -0
  245. package/targets/esp32-s3-m5stack-papers3/main/include/board.h +101 -0
  246. package/targets/esp32-s3-m5stack-papers3/main/include/buttons.h +8 -0
  247. package/targets/esp32-s3-m5stack-papers3/main/launcher_button.cpp +96 -0
  248. package/targets/esp32-s3-m5stack-papers3/main/power.cpp +102 -0
  249. package/targets/esp32-s3-m5stack-papers3/main/sdcard_mount.cpp +88 -0
  250. package/targets/esp32-s3-m5stack-papers3/main/touch.cpp +287 -0
  251. package/targets/esp32-s3-m5stack-papers3/partitions.csv +9 -0
  252. package/targets/esp32-s3-m5stack-papers3/sdkconfig.defaults +232 -0
  253. package/targets/esp32-s3-m5stack-sticks3/CMakeLists.txt +10 -0
  254. package/targets/esp32-s3-m5stack-sticks3/dependencies.lock +51 -0
  255. package/targets/esp32-s3-m5stack-sticks3/main/CMakeLists.txt +51 -0
  256. package/targets/esp32-s3-m5stack-sticks3/main/Kconfig.projbuild +12 -0
  257. package/targets/esp32-s3-m5stack-sticks3/main/app_main.cpp +130 -0
  258. package/targets/esp32-s3-m5stack-sticks3/main/buttons.cpp +101 -0
  259. package/targets/esp32-s3-m5stack-sticks3/main/display.cpp +1391 -0
  260. package/targets/esp32-s3-m5stack-sticks3/main/i2c.cpp +39 -0
  261. package/targets/esp32-s3-m5stack-sticks3/main/idf_component.yml +8 -0
  262. package/targets/esp32-s3-m5stack-sticks3/main/imu_stub.cpp +9 -0
  263. package/targets/esp32-s3-m5stack-sticks3/main/include/board.h +89 -0
  264. package/targets/esp32-s3-m5stack-sticks3/main/include/buttons.h +9 -0
  265. package/targets/esp32-s3-m5stack-sticks3/main/launcher_button.cpp +191 -0
  266. package/targets/esp32-s3-m5stack-sticks3/main/power.cpp +15 -0
  267. package/targets/esp32-s3-m5stack-sticks3/main/sdcard_mount.cpp +8 -0
  268. package/targets/esp32-s3-m5stack-sticks3/main/touch.cpp +65 -0
  269. package/targets/esp32-s3-m5stack-sticks3/partitions.csv +8 -0
  270. package/targets/esp32-s3-m5stack-sticks3/sdkconfig.defaults +130 -0
  271. package/targets/esp32-s3-touch-amoled-1.75/CMakeLists.txt +10 -0
  272. package/targets/esp32-s3-touch-amoled-1.75/dependencies.lock +130 -0
  273. package/targets/esp32-s3-touch-amoled-1.75/main/CMakeLists.txt +589 -0
  274. package/targets/esp32-s3-touch-amoled-1.75/main/Kconfig.projbuild +12 -0
  275. package/targets/esp32-s3-touch-amoled-1.75/main/app_main.cpp +153 -0
  276. package/targets/esp32-s3-touch-amoled-1.75/main/i2c.cpp +39 -0
  277. package/targets/esp32-s3-touch-amoled-1.75/main/idf_component.yml +9 -0
  278. package/targets/esp32-s3-touch-amoled-1.75/main/include/board.h +110 -0
  279. package/targets/esp32-s3-touch-amoled-1.75/main/include/wifi_config.h.example +5 -0
  280. package/targets/esp32-s3-touch-amoled-1.75/main/launcher_button.cpp +191 -0
  281. package/targets/esp32-s3-touch-amoled-1.75/main/touch.cpp +45 -0
  282. package/targets/esp32-s3-touch-amoled-1.75/partitions.csv +8 -0
  283. package/targets/esp32-s3-touch-amoled-1.75/sdkconfig.defaults +179 -0
  284. package/targets/esp32-s3-touch-amoled-1.8/CMakeLists.txt +10 -0
  285. package/targets/esp32-s3-touch-amoled-1.8/dependencies.lock +105 -0
  286. package/targets/esp32-s3-touch-amoled-1.8/main/CMakeLists.txt +768 -0
  287. package/targets/esp32-s3-touch-amoled-1.8/main/Kconfig.projbuild +12 -0
  288. package/targets/esp32-s3-touch-amoled-1.8/main/app_main.cpp +172 -0
  289. package/targets/esp32-s3-touch-amoled-1.8/main/i2c.cpp +39 -0
  290. package/targets/esp32-s3-touch-amoled-1.8/main/idf_component.yml +8 -0
  291. package/targets/esp32-s3-touch-amoled-1.8/main/include/board.h +83 -0
  292. package/targets/esp32-s3-touch-amoled-1.8/main/include/wifi_config.h.example +5 -0
  293. package/targets/esp32-s3-touch-amoled-1.8/main/launcher_button.cpp +191 -0
  294. package/targets/esp32-s3-touch-amoled-1.8/main/touch.cpp +41 -0
  295. package/targets/esp32-s3-touch-amoled-1.8/partitions.csv +8 -0
  296. package/targets/esp32-s3-touch-amoled-1.8/sdkconfig.defaults +179 -0
  297. package/targets/esp32-s3-touch-amoled-2.06/CMakeLists.txt +10 -0
  298. package/targets/esp32-s3-touch-amoled-2.06/dependencies.lock +64 -0
  299. package/targets/esp32-s3-touch-amoled-2.06/main/CMakeLists.txt +1121 -0
  300. package/targets/esp32-s3-touch-amoled-2.06/main/Kconfig.projbuild +12 -0
  301. package/targets/esp32-s3-touch-amoled-2.06/main/app_main.cpp +333 -0
  302. package/targets/esp32-s3-touch-amoled-2.06/main/i2c.cpp +39 -0
  303. package/targets/esp32-s3-touch-amoled-2.06/main/idf_component.yml +27 -0
  304. package/targets/esp32-s3-touch-amoled-2.06/main/include/board.h +114 -0
  305. package/targets/esp32-s3-touch-amoled-2.06/main/include/wifi_config.h.example +5 -0
  306. package/targets/esp32-s3-touch-amoled-2.06/main/launcher_button.cpp +199 -0
  307. package/targets/esp32-s3-touch-amoled-2.06/main/sdcard_mount.cpp +105 -0
  308. package/targets/esp32-s3-touch-amoled-2.06/main/touch.cpp +49 -0
  309. package/targets/esp32-s3-touch-amoled-2.06/partitions.csv +14 -0
  310. package/targets/esp32-s3-touch-amoled-2.06/sdkconfig.defaults +273 -0
  311. package/targets/esp32-s3-touch-amoled-2.41/CMakeLists.txt +10 -0
  312. package/targets/esp32-s3-touch-amoled-2.41/main/CMakeLists.txt +71 -0
  313. package/targets/esp32-s3-touch-amoled-2.41/main/Kconfig.projbuild +12 -0
  314. package/targets/esp32-s3-touch-amoled-2.41/main/idf_component.yml +27 -0
  315. package/targets/esp32-s3-touch-amoled-2.41/main/include/board.h +108 -0
  316. package/targets/esp32-s3-touch-amoled-2.41/main/include/wifi_config.h.example +5 -0
  317. package/targets/esp32-s3-touch-amoled-2.41/main/panel_reset.cpp +82 -0
  318. package/targets/esp32-s3-touch-amoled-2.41/main/touch.cpp +49 -0
  319. package/targets/esp32-s3-touch-amoled-2.41/partitions.csv +8 -0
  320. package/targets/esp32-s3-touch-amoled-2.41/sdkconfig.defaults +273 -0
  321. package/targets/rp2350-tufty-2350/CMakeLists.txt +348 -0
  322. package/targets/rp2350-tufty-2350/README.md +53 -0
  323. package/targets/rp2350-tufty-2350/boards/pimoroni_tufty2350.h +87 -0
  324. package/targets/rp2350-tufty-2350/main/bringup.cpp +187 -0
  325. package/targets/rp2350-tufty-2350/main/include/board.h +124 -0
  326. package/targets/rp2350-tufty-2350/main/rp2350_panel.cpp +428 -0
  327. package/targets/rp2350-tufty-2350/main/rp2350_panel.h +46 -0
  328. package/targets/rp2350-tufty-2350/main/st7789_parallel.pio +7 -0
  329. package/targets/rp2350-waveshare-touch-amoled-2.41/CMakeLists.txt +345 -0
  330. package/targets/rp2350-waveshare-touch-amoled-2.41/README.md +153 -0
  331. package/targets/rp2350-waveshare-touch-amoled-2.41/boards/waveshare_rp2350_touch_amoled_2_41.h +59 -0
  332. package/targets/rp2350-waveshare-touch-amoled-2.41/main/app.cpp +984 -0
  333. package/targets/rp2350-waveshare-touch-amoled-2.41/main/bringup.cpp +222 -0
  334. package/targets/rp2350-waveshare-touch-amoled-2.41/main/include/board.h +138 -0
  335. package/targets/rp2350-waveshare-touch-amoled-2.41/main/rp2350_gea_platform.cpp +2553 -0
  336. package/targets/rp2350-waveshare-touch-amoled-2.41/main/rp2350_gea_platform.h +18 -0
  337. package/targets/rp2350-waveshare-touch-amoled-2.41/main/rp2350_host_fetch_stub.cpp +64 -0
  338. package/targets/rp2350-waveshare-touch-amoled-2.41/main/rp2350_panel.cpp +677 -0
  339. package/targets/rp2350-waveshare-touch-amoled-2.41/main/rp2350_panel.h +48 -0
  340. package/targets/rp2350-waveshare-touch-amoled-2.41/main/vendor/waveshare_psram/rp_pico_alloc.c +354 -0
  341. package/targets/rp2350-waveshare-touch-amoled-2.41/main/vendor/waveshare_psram/rp_pico_alloc.h +56 -0
  342. package/targets/rp2350-waveshare-touch-amoled-2.41/main/vendor/waveshare_psram/tlsf/tlsf.c +1284 -0
  343. package/targets/rp2350-waveshare-touch-amoled-2.41/main/vendor/waveshare_psram/tlsf/tlsf.h +95 -0
  344. package/targets/rp2350-waveshare-touch-amoled-2.41/main/vendor/waveshare_psram/tlsf/tlsf_block_functions.h +123 -0
  345. package/targets/rp2350-waveshare-touch-amoled-2.41/main/vendor/waveshare_psram/tlsf/tlsf_common.h +127 -0
  346. package/targets/rp2350-waveshare-touch-amoled-2.41/tools/rp2350-scroll-bench.py +162 -0
  347. package/targets/rp2350-waveshare-touch-amoled-2.41/tools/rp2350-scroll-parity.py +198 -0
  348. package/targets.json +154 -0
@@ -0,0 +1,614 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { createHash } from 'node:crypto'
4
+ import { existsSync, mkdirSync, readFileSync, realpathSync, renameSync, rmSync, statSync, writeFileSync } from 'node:fs'
5
+ import os from 'node:os'
6
+ import path from 'node:path'
7
+ import { spawn } from 'node:child_process'
8
+ import { fileURLToPath } from 'node:url'
9
+
10
+ const OBJECT_SIGNATURE_VERSION = 'gea-geatsc-object-v2'
11
+ const ARCHIVE_SIGNATURE_VERSION = 'gea-geatsc-archive-v1'
12
+ const PCH_SIGNATURE_VERSION = 'gea-geatsc-pch-v1'
13
+ const NO_GENERATED_DEBUG_INFO_FLAGS = ['-g0']
14
+ // The geatsc runtime umbrella (runtime_pch.h -> runtime.cpp -> prelude +
15
+ // value_* parts, ~99k preprocessed lines) is included by EVERY generated TU.
16
+ // Precompiling it once per flag-set removes that parse from each of the ~60
17
+ // module compiles (measured 2.0s -> 0.06s per small TU when the .gch loads).
18
+ // ⛔ OPT-IN ONLY (GEA_GEATSC_PCH=1): xtensa gcc 15.2 on macOS hosts
19
+ // NONDETERMINISTICALLY segfaults ("internal compiler error: Segmentation
20
+ // fault: 11") while loading the ~174MB .gch this umbrella produces — the same
21
+ // .gch loads fine in one process and kills the next. A randomly failing build
22
+ // is worse than a slow one, so the default stays textual inclusion until the
23
+ // toolchain's PCH relocation is trustworthy (or the runtime is decl/def-split
24
+ // small enough for a reliable PCH). Both compiles below share the exact
25
+ // @flags-file + generated-flags prefix, as GCC requires for .gch validity.
26
+ const PCH_HEADER_NAME = 'runtime_pch.h'
27
+ // -Winvalid-pch: GCC silently falls back to the textual include when it
28
+ // rejects a .gch; surface that as a warning so a mismatch is visible.
29
+ // -fpch-deps: without it, -MMD omits every header folded INTO the PCH, so the
30
+ // per-object staleness check would miss edits to the runtime parts.
31
+ // -fpch-preprocess: keeps the PCH marker in -E output; required for ccache's
32
+ // preprocessor mode to cache PCH-using compiles instead of bailing.
33
+ const PCH_CONSUMER_FLAGS = ['-Winvalid-pch', '-fpch-deps', '-fpch-preprocess']
34
+
35
+ // Warning tolerances applied ONLY to geatsc-generated translation units (never
36
+ // to hand-written framework code). gcc 15's -Werror=infinite-recursion is a
37
+ // false positive on the generated `gea_cpp_key` callable-adapter: the recursive
38
+ // call is on std::function<Sig>, whose instantiation takes the non-recursive
39
+ // branch, so it always terminates — the analyzer just can't prove it across the
40
+ // type change. Downgrade it for generated code so a compiler heuristic can't
41
+ // break app builds.
42
+ // -Wno-error=unused-label: the typed-IR backend lowers each function to a basic-
43
+ // block CFG (labels + goto). Blocks that become unreachable after CFG construction
44
+ // (e.g. the fall-through after an early `return` in `clampIndex`) leave a defined-
45
+ // but-unused label — inherent to CFG codegen, exactly like the unused-variable/
46
+ // function tolerances already applied to generated TUs. Downgrade for generated
47
+ // code so a cosmetic dead-label can't break app builds.
48
+ // -Wno-error=overloaded-virtual: a generated class hierarchy re-declares a base
49
+ // virtual (e.g. the `__sym_GEA_CREATE_TEMPLATE` reactive hook) on a derived class
50
+ // with a related-but-distinct signature; gcc warns the base is "hidden". This is
51
+ // benign for the generated dispatch surface — downgrade for generated code.
52
+ const GENERATED_WARNING_TOLERANCE_FLAGS = ['-Wno-error=infinite-recursion', '-Wno-error=unused-label', '-Wno-error=overloaded-virtual']
53
+
54
+ function sha256(parts) {
55
+ const hash = createHash('sha256')
56
+ for (const part of parts) {
57
+ hash.update(String(part))
58
+ hash.update('\0')
59
+ }
60
+ return hash.digest('hex')
61
+ }
62
+
63
+ function sourceObjectHash(sourcePath) {
64
+ // Match CMake's previous `string(SHA256 hash "${source}")` object naming so
65
+ // the migration does not create a second set of differently named objects.
66
+ return createHash('sha256').update(sourcePath).digest('hex')
67
+ }
68
+
69
+ function positiveInteger(value) {
70
+ const parsed = Number(value)
71
+ return Number.isInteger(parsed) && parsed > 0 ? parsed : null
72
+ }
73
+
74
+ export function defaultJobCount(env = process.env) {
75
+ const explicit = positiveInteger(env.GEA_GEATSC_JOBS)
76
+ if (explicit) return explicit
77
+
78
+ const hostCpuCount = typeof os.availableParallelism === 'function' ? os.availableParallelism() : os.cpus().length
79
+ const cpuCount = positiveInteger(env.CMAKE_BUILD_PARALLEL_LEVEL) ?? hostCpuCount
80
+ // Generated C++ frontends remain memory-heavy even after moving shared
81
+ // runtime code out of each module. Keep the automatic batch small enough
82
+ // that an ESP build can coexist with the IDF and native builds. Developers
83
+ // who prefer throughput can opt into a larger batch with GEA_GEATSC_JOBS.
84
+ const memoryCount = Math.max(1, Math.floor(os.totalmem() / (3 * 1024 ** 3)))
85
+ return Math.max(1, Math.min(4, cpuCount || 1, memoryCount))
86
+ }
87
+
88
+ function firstRule(text) {
89
+ return text.replace(/\\\r?\n/g, ' ').split(/\r?\n/, 1)[0] ?? ''
90
+ }
91
+
92
+ function ruleColon(rule) {
93
+ let escaped = false
94
+ for (let index = 0; index < rule.length; index++) {
95
+ const char = rule[index]
96
+ if (escaped) {
97
+ escaped = false
98
+ continue
99
+ }
100
+ if (char === '\\') {
101
+ escaped = true
102
+ continue
103
+ }
104
+ if (char === ':') return index
105
+ }
106
+ return -1
107
+ }
108
+
109
+ export function parseDepfile(text, cwd = process.cwd()) {
110
+ const rule = firstRule(text)
111
+ const colon = ruleColon(rule)
112
+ if (colon < 0) return []
113
+
114
+ const dependencies = []
115
+ let token = ''
116
+ let escaped = false
117
+ const flush = () => {
118
+ if (!token) return
119
+ dependencies.push(path.isAbsolute(token) ? path.normalize(token) : path.resolve(cwd, token))
120
+ token = ''
121
+ }
122
+
123
+ for (const char of rule.slice(colon + 1)) {
124
+ if (escaped) {
125
+ token += char
126
+ escaped = false
127
+ } else if (char === '\\') {
128
+ escaped = true
129
+ } else if (/\s/.test(char)) {
130
+ flush()
131
+ } else {
132
+ token += char
133
+ }
134
+ }
135
+ if (escaped) token += '\\'
136
+ flush()
137
+ return dependencies
138
+ }
139
+
140
+ function depfileDependencies(depfilePath) {
141
+ if (!existsSync(depfilePath)) return []
142
+ return parseDepfile(readFileSync(depfilePath, 'utf8'))
143
+ }
144
+
145
+ function toolIdentity(toolPath) {
146
+ try {
147
+ const resolved = realpathSync(toolPath)
148
+ const stat = statSync(resolved)
149
+ return `${resolved}\0${stat.size}\0${stat.mtimeMs}`
150
+ } catch {
151
+ return toolPath
152
+ }
153
+ }
154
+
155
+ // Windows executables carry an extension from PATHEXT, so a bare name such as
156
+ // `ccache` matches nothing on PATH there and the lookup used to fall through to
157
+ // `<cwd>/ccache` -- which then failed the existence check and stopped the build
158
+ // as soon as the caller started passing a launcher.
159
+ function executableCandidates(tool) {
160
+ if (process.platform !== 'win32') return [tool]
161
+ const extensions = (process.env.PATHEXT ?? '.COM;.EXE;.BAT;.CMD').split(';').filter(Boolean)
162
+ return [tool, ...extensions.map((extension) => `${tool}${extension}`)]
163
+ }
164
+
165
+ function resolveExecutable(tool) {
166
+ if (path.isAbsolute(tool)) return path.normalize(tool)
167
+ if (tool.includes(path.sep) || tool.includes('/')) return path.resolve(tool)
168
+ const candidates = executableCandidates(tool)
169
+ for (const directory of (process.env.PATH ?? '').split(path.delimiter).filter(Boolean)) {
170
+ for (const name of candidates) {
171
+ const candidate = path.join(directory, name)
172
+ if (existsSync(candidate)) return candidate
173
+ }
174
+ }
175
+ return path.resolve(tool)
176
+ }
177
+
178
+ function writeFileAtomic(filePath, contents) {
179
+ mkdirSync(path.dirname(filePath), { recursive: true })
180
+ const temporaryPath = `${filePath}.${process.pid}.${Math.random().toString(16).slice(2)}.tmp`
181
+ writeFileSync(temporaryPath, contents)
182
+ try {
183
+ replaceFile(temporaryPath, filePath)
184
+ } catch (error) {
185
+ rmSync(temporaryPath, { force: true })
186
+ throw error
187
+ }
188
+ }
189
+
190
+ function writeFileIfChanged(filePath, contents) {
191
+ if (existsSync(filePath) && readFileSync(filePath, 'utf8') === contents) return
192
+ writeFileAtomic(filePath, contents)
193
+ }
194
+
195
+ function replaceFile(sourcePath, destinationPath) {
196
+ try {
197
+ renameSync(sourcePath, destinationPath)
198
+ } catch (error) {
199
+ if (process.platform !== 'win32') throw error
200
+ rmSync(destinationPath, { force: true })
201
+ renameSync(sourcePath, destinationPath)
202
+ }
203
+ }
204
+
205
+ function objectNeedsCompile(record, compileSignature) {
206
+ if (!existsSync(record.objectPath) || !existsSync(record.depfilePath) || !existsSync(record.signaturePath)) return true
207
+ if (readFileSync(record.signaturePath, 'utf8').trim() !== compileSignature) return true
208
+
209
+ const objectTime = statSync(record.objectPath).mtimeMs
210
+ if (statSync(record.sourcePath).mtimeMs > objectTime) return true
211
+ const dependencies = depfileDependencies(record.depfilePath)
212
+ if (dependencies.length === 0) return true
213
+ for (const dependency of dependencies) {
214
+ if (!existsSync(dependency) || statSync(dependency).mtimeMs > objectTime) return true
215
+ }
216
+ return false
217
+ }
218
+
219
+ function runCommand(command, args) {
220
+ return new Promise((resolve, reject) => {
221
+ const child = spawn(command, args, { stdio: ['ignore', 'pipe', 'pipe'], windowsHide: true })
222
+ let stdout = ''
223
+ let stderr = ''
224
+ let spawnError = null
225
+ child.stdout.on('data', (chunk) => {
226
+ stdout += chunk
227
+ })
228
+ child.stderr.on('data', (chunk) => {
229
+ stderr += chunk
230
+ })
231
+ child.on('error', (error) => {
232
+ spawnError = error
233
+ })
234
+ child.on('close', (status, signal) => {
235
+ if (spawnError) {
236
+ reject(spawnError)
237
+ } else if (status !== 0) {
238
+ const detail = stderr || stdout || `terminated by ${signal ?? `exit ${status}`}`
239
+ reject(new Error(`${command} failed: ${detail.trim()}`))
240
+ } else {
241
+ resolve({ stdout, stderr })
242
+ }
243
+ })
244
+ })
245
+ }
246
+
247
+ async function compileObject(record, options, compileSignature) {
248
+ const suffix = `${process.pid}.${Math.random().toString(16).slice(2)}.tmp`
249
+ const temporaryObject = `${record.objectPath}.${suffix}`
250
+ const temporaryDepfile = `${record.depfilePath}.${suffix}`
251
+ mkdirSync(path.dirname(record.objectPath), { recursive: true })
252
+ try {
253
+ const compilerArgs = [
254
+ `@${options.flagsFile}`,
255
+ ...options.generatedCompileFlags,
256
+ '-MMD',
257
+ '-MP',
258
+ '-MF',
259
+ temporaryDepfile,
260
+ '-c',
261
+ record.sourcePath,
262
+ '-o',
263
+ temporaryObject,
264
+ ]
265
+ const result = options.compilerLauncher
266
+ ? await runCommand(options.compilerLauncher, [options.compiler, ...compilerArgs])
267
+ : await runCommand(options.compiler, compilerArgs)
268
+ if (result.stdout) process.stdout.write(result.stdout)
269
+ if (result.stderr) process.stderr.write(result.stderr)
270
+ replaceFile(temporaryObject, record.objectPath)
271
+ replaceFile(temporaryDepfile, record.depfilePath)
272
+ writeFileAtomic(record.signaturePath, `${compileSignature}\n`)
273
+ } catch (error) {
274
+ rmSync(temporaryObject, { force: true })
275
+ rmSync(temporaryDepfile, { force: true })
276
+ throw new Error(`failed to compile ${record.sourcePath}: ${error instanceof Error ? error.message : String(error)}`)
277
+ }
278
+ }
279
+
280
+ function contentHash(filePath) {
281
+ try {
282
+ return createHash('sha256').update(readFileSync(filePath)).digest('hex')
283
+ } catch {
284
+ return `missing:${filePath}`
285
+ }
286
+ }
287
+
288
+ // Content-based staleness for the PCH: geatsc rewrites every generated file
289
+ // with a fresh mtime on each emission even when the bytes are identical, so
290
+ // the mtime-based objectNeedsCompile would rebuild the (expensive) .gch every
291
+ // build. Hash the header and every dependency recorded by the previous
292
+ // compile's depfile instead; only real content changes rebuild it.
293
+ function pchSignatureFor(options, record) {
294
+ const dependencies = depfileDependencies(record.depfilePath)
295
+ const dependencyHashes = [...new Set([record.sourcePath, ...dependencies])]
296
+ .sort()
297
+ .map((dependency) => `${dependency}\0${contentHash(dependency)}`)
298
+ return sha256([
299
+ PCH_SIGNATURE_VERSION,
300
+ toolIdentity(options.compiler),
301
+ readFileSync(options.flagsFile),
302
+ ...options.generatedCompileFlags,
303
+ ...dependencyHashes,
304
+ ])
305
+ }
306
+
307
+ /**
308
+ * The header to precompile for this generated directory.
309
+ *
310
+ * Preferred: the `runtime=` line of `geatsc-header.txt`, which a per-file
311
+ * compile writes -- the compiler's own prelude (standard headers, the hosts'
312
+ * preambles, `gea_runtime.h`, the hosts' headers) and nothing else. It has to
313
+ * be that text: the preambles PRECEDE `gea_runtime.h` and decide what it
314
+ * declares, so a PCH built from a header without them declares engine
315
+ * stand-ins that collide with the engine's own types in every unit.
316
+ *
317
+ * Two reasons to prefer it over `runtime_pch.h`. It is the only one the
318
+ * current compiler emits at all -- `runtime_pch.h` was the previous one's
319
+ * umbrella, so on a directory this compiler generated the fallback finds
320
+ * nothing and the whole PCH path was dead. And it is far smaller: the umbrella
321
+ * pulls the runtime's `value_01..25` implementations in and produces a ~174MB
322
+ * .gch, the size at which xtensa gcc 15.2 nondeterministically ICEs while
323
+ * loading it (which is why `GEA_GEATSC_PCH` is opt-in). The prelude alone is
324
+ * a fraction of that, so it is the configuration in which the opt-in has a
325
+ * chance of becoming the default -- unproven on device, which is why this
326
+ * changes the source and not the gate.
327
+ *
328
+ * One layer only, unlike the macOS chain: GCC takes a single PCH per compile
329
+ * and cannot chain one on another, so the program header (`<stem>.hpp`, which
330
+ * changes whenever a declaration does) is not precompiled here. The runtime
331
+ * layer is the stable one and most of the win.
332
+ */
333
+ function pchHeaderFor(options) {
334
+ const dir = path.dirname(options.sourceList)
335
+ const manifest = path.join(dir, 'geatsc-header.txt')
336
+ if (existsSync(manifest)) {
337
+ for (const line of readFileSync(manifest, 'utf8').split('\n')) {
338
+ if (!line.startsWith('runtime=')) continue
339
+ const named = line.slice('runtime='.length).trim()
340
+ if (named && existsSync(named)) return named
341
+ }
342
+ }
343
+ const fallback = path.join(dir, PCH_HEADER_NAME)
344
+ return existsSync(fallback) ? fallback : null
345
+ }
346
+
347
+ async function prepareRuntimePch(options) {
348
+ if (process.env.GEA_GEATSC_PCH !== '1') return null
349
+ const headerPath = pchHeaderFor(options)
350
+ if (!headerPath) return null
351
+ const gchPath = `${headerPath}.gch`
352
+ const headerName = path.basename(headerPath)
353
+ const record = {
354
+ sourcePath: headerPath,
355
+ objectPath: gchPath,
356
+ depfilePath: path.join(options.objectDir, `${headerName}.gch.d`),
357
+ signaturePath: path.join(options.objectDir, `${headerName}.gch.compile.sig`),
358
+ }
359
+ const signature = pchSignatureFor(options, record)
360
+ const stale =
361
+ !existsSync(record.objectPath) ||
362
+ !existsSync(record.depfilePath) ||
363
+ !existsSync(record.signaturePath) ||
364
+ readFileSync(record.signaturePath, 'utf8').trim() !== signature
365
+ if (stale) {
366
+ const suffix = `${process.pid}.${Math.random().toString(16).slice(2)}.tmp`
367
+ const temporaryGch = `${gchPath}.${suffix}`
368
+ const temporaryDepfile = `${record.depfilePath}.${suffix}`
369
+ mkdirSync(options.objectDir, { recursive: true })
370
+ try {
371
+ // The launcher (ccache) is deliberately skipped: this is one compile per
372
+ // flag-set, and ccache treats PCH *creation* as uncacheable anyway.
373
+ const result = await runCommand(options.compiler, [
374
+ `@${options.flagsFile}`,
375
+ ...options.generatedCompileFlags,
376
+ '-x',
377
+ 'c++-header',
378
+ '-MMD',
379
+ '-MP',
380
+ '-MF',
381
+ temporaryDepfile,
382
+ '-c',
383
+ headerPath,
384
+ '-o',
385
+ temporaryGch,
386
+ ])
387
+ if (result.stdout) process.stdout.write(result.stdout)
388
+ if (result.stderr) process.stderr.write(result.stderr)
389
+ replaceFile(temporaryGch, gchPath)
390
+ replaceFile(temporaryDepfile, record.depfilePath)
391
+ // Re-derive the signature from the freshly written depfile: the first
392
+ // build has no previous depfile, so the pre-compile signature covered
393
+ // only the header itself.
394
+ writeFileAtomic(record.signaturePath, `${pchSignatureFor(options, record)}\n`)
395
+ } catch (error) {
396
+ rmSync(temporaryGch, { force: true })
397
+ rmSync(temporaryDepfile, { force: true })
398
+ throw new Error(`failed to precompile ${headerPath}: ${error instanceof Error ? error.message : String(error)}`)
399
+ }
400
+ }
401
+ return { gchPath, headerPath, rebuilt: stale }
402
+ }
403
+
404
+ async function compileInParallel(records, options, compileSignature, jobs) {
405
+ let nextIndex = 0
406
+ let failed = false
407
+ const errors = []
408
+ const worker = async () => {
409
+ while (!failed) {
410
+ const index = nextIndex++
411
+ if (index >= records.length) return
412
+ try {
413
+ await compileObject(records[index], options, compileSignature)
414
+ } catch (error) {
415
+ failed = true
416
+ errors.push(error)
417
+ }
418
+ }
419
+ }
420
+ const workerCount = Math.min(jobs, records.length)
421
+ await Promise.all(Array.from({ length: workerCount }, () => worker()))
422
+ if (errors.length > 0) throw errors[0]
423
+ }
424
+
425
+ function makeEscape(value) {
426
+ return value.replace(/\\/g, '\\\\').replace(/\$/g, '$$$$').replace(/#/g, '\\#').replace(/ /g, '\\ ').replace(/:/g, '\\:')
427
+ }
428
+
429
+ function writeAggregateDepfile(options, records) {
430
+ const dependencies = new Set([options.sourceList, options.flagsFile])
431
+ for (const record of records) {
432
+ dependencies.add(record.sourcePath)
433
+ for (const dependency of depfileDependencies(record.depfilePath)) dependencies.add(dependency)
434
+ }
435
+ const continuation = ` \\${String.fromCharCode(10)} `
436
+ const lines = [...dependencies].sort().map((dependency) => continuation + makeEscape(dependency))
437
+ writeFileIfChanged(options.depfile, `${makeEscape(options.archive)}:${lines.join('')}\n`)
438
+ }
439
+
440
+ async function rebuildArchive(options, records) {
441
+ mkdirSync(path.dirname(options.archive), { recursive: true })
442
+ const temporaryArchive = `${options.archive}.${process.pid}.${Math.random().toString(16).slice(2)}.tmp`
443
+ rmSync(temporaryArchive, { force: true })
444
+ try {
445
+ const archived = await runCommand(options.ar, ['qc', temporaryArchive, ...records.map((record) => record.objectPath)])
446
+ if (archived.stdout) process.stdout.write(archived.stdout)
447
+ if (archived.stderr) process.stderr.write(archived.stderr)
448
+ if (options.ranlib) {
449
+ const indexed = await runCommand(options.ranlib, [temporaryArchive])
450
+ if (indexed.stdout) process.stdout.write(indexed.stdout)
451
+ if (indexed.stderr) process.stderr.write(indexed.stderr)
452
+ }
453
+ replaceFile(temporaryArchive, options.archive)
454
+ } catch (error) {
455
+ rmSync(temporaryArchive, { force: true })
456
+ throw error
457
+ }
458
+ }
459
+
460
+ function readSources(sourceList) {
461
+ const sourceRoot = path.dirname(sourceList)
462
+ const sources = readFileSync(sourceList, 'utf8')
463
+ .split(/\r?\n/)
464
+ .map((line) => line.trim())
465
+ .filter(Boolean)
466
+ .map((source) => (path.isAbsolute(source) ? path.normalize(source) : path.resolve(sourceRoot, source)))
467
+ if (sources.length === 0) throw new Error(`geatsc source list is empty: ${sourceList}`)
468
+ for (const source of sources) {
469
+ if (!existsSync(source)) throw new Error(`geatsc generated source not found: ${source}`)
470
+ }
471
+ return sources
472
+ }
473
+
474
+ export async function buildGeneratedArchive(rawOptions) {
475
+ const options = {
476
+ ...rawOptions,
477
+ sourceList: path.resolve(rawOptions.sourceList),
478
+ archive: path.resolve(rawOptions.archive),
479
+ objectDir: path.resolve(rawOptions.objectDir),
480
+ depfile: path.resolve(rawOptions.depfile),
481
+ flagsFile: path.resolve(rawOptions.flagsFile),
482
+ compiler: path.resolve(rawOptions.compiler),
483
+ compilerLauncher: rawOptions.compilerLauncher ? resolveExecutable(rawOptions.compilerLauncher) : '',
484
+ ar: path.resolve(rawOptions.ar),
485
+ ranlib: rawOptions.ranlib ? path.resolve(rawOptions.ranlib) : '',
486
+ // ESP-IDF enables full DWARF globally. The geatsc runtime interface is
487
+ // intentionally shared by every generated translation unit, so emitting
488
+ // its type information into every object made even a four-line module
489
+ // tens of megabytes. Keep source-level generated-code debugging available
490
+ // as an explicit opt-in without charging normal app builds for it.
491
+ generatedCompileFlags: [
492
+ ...GENERATED_WARNING_TOLERANCE_FLAGS,
493
+ ...(rawOptions.debugInfo === true || process.env.GEA_GEATSC_DEBUG_INFO === '1' ? [] : NO_GENERATED_DEBUG_INFO_FLAGS),
494
+ ],
495
+ }
496
+ for (const [name, filePath] of Object.entries({
497
+ sourceList: options.sourceList,
498
+ flagsFile: options.flagsFile,
499
+ compiler: options.compiler,
500
+ ...(options.compilerLauncher ? { compilerLauncher: options.compilerLauncher } : {}),
501
+ ar: options.ar,
502
+ })) {
503
+ if (!existsSync(filePath)) throw new Error(`${name} not found: ${filePath}`)
504
+ }
505
+ if (options.ranlib && !existsSync(options.ranlib)) throw new Error(`ranlib not found: ${options.ranlib}`)
506
+
507
+ const sources = readSources(options.sourceList)
508
+ mkdirSync(options.objectDir, { recursive: true })
509
+ const records = sources.map((sourcePath) => {
510
+ const extension = path.extname(sourcePath)
511
+ const objectPath = path.join(options.objectDir, `${sourceObjectHash(sourcePath)}${extension}.o`)
512
+ return {
513
+ sourcePath,
514
+ objectPath,
515
+ depfilePath: `${objectPath}.d`,
516
+ signaturePath: `${objectPath}.compile.sig`,
517
+ }
518
+ })
519
+
520
+ const pch = await prepareRuntimePch(options)
521
+ if (pch) {
522
+ // GCC only consumes a .gch when the header is named from the MAIN file;
523
+ // the generated TUs reach runtime_pch.h through generated_support.hpp, one
524
+ // include level down, which silently degrades to textual inclusion (no
525
+ // -Winvalid-pch diagnostic — the PCH is simply never considered). Forcing
526
+ // the header first via -include makes it a main-file include, and the
527
+ // TU's own nested include then no-ops on the already-recorded guard.
528
+ options.generatedCompileFlags = [...options.generatedCompileFlags, ...PCH_CONSUMER_FLAGS, '-include', pch.headerPath]
529
+ // ccache rejects (or worse, mis-keys) GCC-PCH compiles unless it is told
530
+ // to ignore the defines/time macros folded into the .gch. The env var
531
+ // overrides ccache.conf wholesale, so merge instead of clobbering.
532
+ if (options.compilerLauncher && path.basename(options.compilerLauncher).includes('ccache')) {
533
+ const sloppiness = new Set(
534
+ (process.env.CCACHE_SLOPPINESS ?? '')
535
+ .split(',')
536
+ .map((entry) => entry.trim())
537
+ .filter(Boolean),
538
+ )
539
+ sloppiness.add('pch_defines')
540
+ sloppiness.add('time_macros')
541
+ process.env.CCACHE_SLOPPINESS = [...sloppiness].join(',')
542
+ }
543
+ }
544
+
545
+ const compileSignature = sha256([
546
+ OBJECT_SIGNATURE_VERSION,
547
+ options.compilerLauncher ? toolIdentity(options.compilerLauncher) : '',
548
+ toolIdentity(options.compiler),
549
+ readFileSync(options.flagsFile),
550
+ '@flags',
551
+ '-MMD',
552
+ '-MP',
553
+ ...options.generatedCompileFlags,
554
+ // A new .gch means every object that baked the old one in must rebuild;
555
+ // stat identity is stable across builds that reuse the cached PCH.
556
+ pch ? toolIdentity(pch.gchPath) : 'no-pch',
557
+ ])
558
+ const staleRecords = records.filter((record) => objectNeedsCompile(record, compileSignature))
559
+ const jobs = positiveInteger(rawOptions.jobs) ?? defaultJobCount()
560
+ await compileInParallel(staleRecords, options, compileSignature, jobs)
561
+
562
+ const archiveSignature = sha256([
563
+ ARCHIVE_SIGNATURE_VERSION,
564
+ toolIdentity(options.ar),
565
+ options.ranlib ? toolIdentity(options.ranlib) : '',
566
+ ...records.flatMap((record) => {
567
+ const stat = statSync(record.objectPath)
568
+ return [record.objectPath, stat.size, stat.mtimeMs]
569
+ }),
570
+ ])
571
+ const archiveSignaturePath = `${options.archive}.objects.sig`
572
+ const previousArchiveSignature = existsSync(archiveSignaturePath) ? readFileSync(archiveSignaturePath, 'utf8').trim() : ''
573
+ const archiveChanged = !existsSync(options.archive) || previousArchiveSignature !== archiveSignature
574
+ if (archiveChanged) {
575
+ await rebuildArchive(options, records)
576
+ writeFileAtomic(archiveSignaturePath, `${archiveSignature}\n`)
577
+ }
578
+ writeAggregateDepfile(options, records)
579
+
580
+ const compiled = staleRecords.length
581
+ const reused = records.length - compiled
582
+ process.stdout.write(
583
+ `geatsc-generated-archive: compiled=${compiled} reused=${reused} jobs=${Math.min(jobs, Math.max(1, compiled))} archived=${archiveChanged ? 1 : 0} pch=${pch ? (pch.rebuilt ? 'built' : 'reused') : 'off'}\n`,
584
+ )
585
+ return { compiled, reused, jobs, archived: archiveChanged, records, pch }
586
+ }
587
+
588
+ function parseArguments(argv) {
589
+ const options = {}
590
+ for (let index = 0; index < argv.length; index++) {
591
+ const argument = argv[index]
592
+ if (!argument.startsWith('--')) throw new Error(`unexpected argument: ${argument}`)
593
+ const equals = argument.indexOf('=')
594
+ const key = (equals >= 0 ? argument.slice(2, equals) : argument.slice(2)).replace(/-([a-z])/g, (_, char) => char.toUpperCase())
595
+ const value = equals >= 0 ? argument.slice(equals + 1) : argv[++index]
596
+ if (value === undefined) throw new Error(`missing value for ${argument}`)
597
+ options[key] = value
598
+ }
599
+ for (const required of ['sourceList', 'archive', 'objectDir', 'depfile', 'flagsFile', 'compiler', 'ar']) {
600
+ if (!options[required]) throw new Error(`missing --${required.replace(/[A-Z]/g, (char) => `-${char.toLowerCase()}`)}`)
601
+ }
602
+ return options
603
+ }
604
+
605
+ async function main() {
606
+ await buildGeneratedArchive(parseArguments(process.argv.slice(2)))
607
+ }
608
+
609
+ if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
610
+ main().catch((error) => {
611
+ process.stderr.write(`geatsc-generated-archive: ${error instanceof Error ? error.message : String(error)}\n`)
612
+ process.exitCode = 1
613
+ })
614
+ }