@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.
- package/README.md +13 -1
- package/dist/chips/controllers.d.ts +28 -8
- package/dist/chips/controllers.js +49 -12
- package/dist/chips/resolve.js +32 -6
- package/dist/chips/types.d.ts +63 -12
- package/dist/chips/xiao-ble.js +12 -0
- package/dist/dt-config/kconfig.d.ts +11 -0
- package/dist/dt-config/kconfig.js +1 -1
- package/dist/dt-config/overlay.js +85 -0
- package/dist/framework.manifest.d.ts +20 -30
- package/dist/framework.manifest.js +12 -3
- package/dist/lowering/adc.d.ts +7 -4
- package/dist/lowering/adc.js +25 -11
- package/dist/lowering/gpio.js +9 -6
- package/dist/lowering/mqtt.js +9 -1
- package/dist/lowering/pulse.js +7 -7
- package/dist/lowering/pwm.d.ts +21 -3
- package/dist/lowering/pwm.js +28 -4
- package/dist/lowering/spi.js +2 -2
- package/dist/lowering/tone.js +3 -2
- package/dist/lowering/wifi.js +28 -5
- package/dist/strategy.js +56 -4
- package/dist/toolchain/debug-config.js +1 -1
- package/dist/toolchain/index.d.ts +1 -1
- package/dist/toolchain/index.js +83 -8
- package/dist/toolchain/scaffold.d.ts +9 -0
- package/dist/toolchain/scaffold.js +45 -0
- package/dist/toolchain/west-discover.d.ts +4 -1
- package/dist/toolchain/west-discover.js +2 -0
- package/dist/toolchain/west-spawn.js +17 -5
- package/package.json +5 -5
- package/src/chips/controllers.ts +61 -12
- package/src/chips/resolve.ts +32 -5
- package/src/chips/types.ts +63 -12
- package/src/chips/xiao-ble.ts +82 -70
- package/src/dt-config/kconfig.ts +12 -1
- package/src/dt-config/overlay.ts +546 -450
- package/src/framework.manifest.ts +12 -3
- package/src/lowering/adc.ts +28 -12
- package/src/lowering/gpio.ts +9 -6
- package/src/lowering/mqtt.ts +9 -1
- package/src/lowering/pulse.ts +7 -7
- package/src/lowering/pwm.ts +29 -4
- package/src/lowering/spi.ts +2 -2
- package/src/lowering/tone.ts +3 -3
- package/src/lowering/wifi.ts +29 -5
- package/src/strategy.ts +52 -4
- package/src/toolchain/debug-config.ts +1 -1
- package/src/toolchain/index.ts +645 -565
- package/src/toolchain/scaffold.ts +43 -0
- package/src/toolchain/west-discover.ts +321 -316
- 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) {
|