@typecad/framework-zephyr 1.0.0-alpha.13 → 1.0.0-alpha.14

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 (52) hide show
  1. package/README.md +13 -1
  2. package/dist/chips/controllers.d.ts +28 -8
  3. package/dist/chips/controllers.js +49 -12
  4. package/dist/chips/resolve.js +32 -6
  5. package/dist/chips/types.d.ts +63 -12
  6. package/dist/chips/xiao-ble.js +12 -0
  7. package/dist/dt-config/kconfig.d.ts +11 -0
  8. package/dist/dt-config/kconfig.js +1 -1
  9. package/dist/dt-config/overlay.js +85 -0
  10. package/dist/framework.manifest.d.ts +20 -30
  11. package/dist/framework.manifest.js +12 -3
  12. package/dist/lowering/adc.d.ts +7 -4
  13. package/dist/lowering/adc.js +25 -11
  14. package/dist/lowering/gpio.js +9 -6
  15. package/dist/lowering/mqtt.js +9 -1
  16. package/dist/lowering/pulse.js +7 -7
  17. package/dist/lowering/pwm.d.ts +21 -3
  18. package/dist/lowering/pwm.js +28 -4
  19. package/dist/lowering/spi.js +2 -2
  20. package/dist/lowering/tone.js +3 -2
  21. package/dist/lowering/wifi.js +28 -5
  22. package/dist/strategy.js +56 -4
  23. package/dist/toolchain/debug-config.js +1 -1
  24. package/dist/toolchain/index.d.ts +1 -1
  25. package/dist/toolchain/index.js +83 -8
  26. package/dist/toolchain/scaffold.d.ts +9 -0
  27. package/dist/toolchain/scaffold.js +45 -0
  28. package/dist/toolchain/west-discover.d.ts +4 -1
  29. package/dist/toolchain/west-discover.js +2 -0
  30. package/dist/toolchain/west-spawn.js +17 -5
  31. package/package.json +5 -5
  32. package/src/chips/controllers.ts +61 -12
  33. package/src/chips/resolve.ts +32 -5
  34. package/src/chips/types.ts +63 -12
  35. package/src/chips/xiao-ble.ts +82 -70
  36. package/src/dt-config/kconfig.ts +12 -1
  37. package/src/dt-config/overlay.ts +546 -450
  38. package/src/framework.manifest.ts +12 -3
  39. package/src/lowering/adc.ts +28 -12
  40. package/src/lowering/gpio.ts +9 -6
  41. package/src/lowering/mqtt.ts +9 -1
  42. package/src/lowering/pulse.ts +7 -7
  43. package/src/lowering/pwm.ts +29 -4
  44. package/src/lowering/spi.ts +2 -2
  45. package/src/lowering/tone.ts +3 -3
  46. package/src/lowering/wifi.ts +29 -5
  47. package/src/strategy.ts +52 -4
  48. package/src/toolchain/debug-config.ts +1 -1
  49. package/src/toolchain/index.ts +645 -565
  50. package/src/toolchain/scaffold.ts +43 -0
  51. package/src/toolchain/west-discover.ts +321 -316
  52. package/src/toolchain/west-spawn.ts +17 -5
@@ -10,6 +10,7 @@
10
10
  import { writeFileSync, existsSync, mkdirSync, readFileSync, readdirSync } from 'node:fs';
11
11
  import { join } from 'node:path';
12
12
  import { resolveKconfigFragments, type KconfigUsage } from '../dt-config/kconfig.js';
13
+ import { readCuttlefishLibrarySidecar } from '@typecad/cuttlefish/library-packages';
13
14
 
14
15
  /** Write a file only if the content differs from the existing file.
15
16
  * Returns true when the file was written (content changed or file was new). */
@@ -58,6 +59,30 @@ function readEmittedSources(srcDir: string): string {
58
59
  return out;
59
60
  }
60
61
 
62
+ /**
63
+ * Append cuttlefish library packages' devicetree overlay fragments to the
64
+ * generated overlay. Library entries come from the transpiler's libraries.json
65
+ * sidecar (next to the emitted sources) and are already gated on the
66
+ * library's include token appearing in the emitted sources — no re-detection.
67
+ * Fragments merge after the framework overlay so library nodes (e.g.
68
+ * @typecad/zephyr-esp32s3-rgb's WS2812 node on I2S0) layer over it.
69
+ */
70
+ export function appendLibraryOverlayFragments(overlay: string, projectRoot: string): string {
71
+ let out = overlay;
72
+ for (const entry of readCuttlefishLibrarySidecar(join(projectRoot, 'src'))) {
73
+ if (!entry.overlay) continue;
74
+ try {
75
+ const fragment = readFileSync(entry.overlay, 'utf8').trim();
76
+ if (fragment.length > 0) {
77
+ out += (out.endsWith('\n') ? '' : '\n') + '\n' + fragment + '\n';
78
+ }
79
+ } catch {
80
+ // best-effort; a missing fragment surfaces as a DT error
81
+ }
82
+ }
83
+ return out;
84
+ }
85
+
61
86
  /**
62
87
  * Emit the Zephyr application skeleton around the generated src/main.cpp.
63
88
  *
@@ -205,6 +230,24 @@ export function scaffoldZephyrProject(projectRoot: string, debug = false, userKc
205
230
  if (userKconfig && userKconfig.hasOwnProperty(sym)) continue;
206
231
  prjConf.push(`${sym}=${val}`);
207
232
  }
233
+ // ── Cuttlefish library packages ─────────────────────────────────────────
234
+ // Libraries the program imports (recorded in the transpiler's libraries.json
235
+ // sidecar, next to the emitted sources) contribute their manifest's kconfig
236
+ // lines — e.g. @typecad/zephyr-esp32s3-rgb contributes CONFIG_LED_STRIP.
237
+ // Sidecar entries are already gated on the library's include token
238
+ // appearing in the emitted sources, so no re-detection here. User
239
+ // zephyr.kconfig overrides still win.
240
+ const libraryEntries = readCuttlefishLibrarySidecar(srcDir);
241
+ if (libraryEntries.length > 0) {
242
+ prjConf.push('', '# Library packages (cuttlefish.library.json contributions).');
243
+ for (const entry of libraryEntries) {
244
+ for (const line of entry.kconfig) {
245
+ const sym = line.split('=')[0];
246
+ if (userKconfig && sym !== undefined && userKconfig.hasOwnProperty(sym)) continue;
247
+ prjConf.push(line);
248
+ }
249
+ }
250
+ }
208
251
  // Emit user-specified Kconfig from cuttlefish.config.ts zephyr.kconfig.
209
252
  // These override any matching auto-detected symbol (skipped above).
210
253
  if (userKconfig) {