@typecad/framework-zephyr 1.0.0-alpha.15 → 1.0.0-alpha.18
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/LICENSE +202 -21
- package/README.md +49 -87
- package/dist/as-built.d.ts +2 -2
- package/dist/as-built.js +2 -2
- package/dist/boardgen.d.ts +1 -9
- package/dist/boardgen.js +228 -45
- package/dist/chips/types.d.ts +1 -1
- package/dist/debug-codegen.js +1 -1
- package/dist/display/touch-adapter.js +1 -1
- package/dist/display/ui-adapter.js +549 -549
- package/dist/doctor.js +4 -4
- package/dist/dt-config/custom-board.js +2 -2
- package/dist/dt-config/kconfig.js +18 -12
- package/dist/dt-config/overlay.d.ts +2 -2
- package/dist/dt-config/overlay.js +2 -2
- package/dist/framework.manifest.d.ts +3 -3
- package/dist/framework.manifest.js +10 -7
- package/dist/index.js +5 -5
- package/dist/licenses.d.ts +2 -2
- package/dist/licenses.js +8 -8
- package/dist/lowering/fs.js +1 -1
- package/dist/lowering/gpio.js +0 -32
- package/dist/lowering/http.js +264 -32
- package/dist/lowering/i2c.js +0 -8
- package/dist/lowering/interrupts.js +6 -0
- package/dist/lowering/mqtt.js +110 -8
- package/dist/lowering/usb.js +11 -11
- package/dist/lowering/wdt.js +2 -29
- package/dist/sdk/board-catalog-sync.d.ts +1 -3
- package/dist/sdk/board-catalog-sync.js +4 -10
- package/dist/strategy.d.ts +22 -44
- package/dist/strategy.js +152 -155
- package/dist/tmp-probe.d.ts +2 -0
- package/dist/tmp-probe.js +9 -0
- package/dist/toolchain/debug-config.d.ts +50 -90
- package/dist/toolchain/debug-config.js +241 -502
- package/dist/toolchain/env-check.d.ts +1 -3
- package/dist/toolchain/env-check.js +2 -7
- package/dist/toolchain/index.d.ts +65 -2
- package/dist/toolchain/index.js +432 -55
- package/dist/toolchain/runners.d.ts +16 -0
- package/dist/toolchain/runners.js +75 -0
- package/dist/toolchain/scaffold.d.ts +1 -1
- package/dist/toolchain/scaffold.js +12 -12
- package/dist/toolchain/west-discover.d.ts +6 -0
- package/dist/toolchain/west-discover.js +36 -13
- package/dist/toolchain/west-spawn.js +8 -2
- package/installer/README.md +328 -328
- package/installer/install.sh +2 -2
- package/installer/templates/project/.typecad/activate-zephyr.ps1 +1 -1
- package/installer/templates/project/.typecad/activate-zephyr.sh +1 -1
- package/installer/templates/project/.vscode/settings.json +1 -1
- package/installer/templates/project/README.md +2 -2
- package/package.json +5 -5
- package/src/as-built.ts +206 -206
- package/src/boardgen.ts +214 -48
- package/src/chips/types.ts +567 -567
- package/src/display/touch-adapter.ts +204 -204
- package/src/display/ui-adapter.ts +781 -781
- package/src/doctor.ts +4 -4
- package/src/dt-config/custom-board.ts +2 -2
- package/src/dt-config/kconfig.ts +18 -12
- package/src/dt-config/overlay.ts +1058 -1058
- package/src/framework.manifest.ts +538 -535
- package/src/index.ts +5 -5
- package/src/licenses.ts +425 -425
- package/src/lowering/fs.ts +135 -135
- package/src/lowering/gpio.ts +0 -33
- package/src/lowering/http.ts +264 -32
- package/src/lowering/i2c.ts +0 -9
- package/src/lowering/interrupts.ts +6 -0
- package/src/lowering/mqtt.ts +109 -8
- package/src/lowering/usb.ts +221 -221
- package/src/lowering/wdt.ts +2 -25
- package/src/sdk/board-catalog-sync.ts +4 -25
- package/src/strategy.ts +2265 -2309
- package/src/toolchain/debug-config.ts +264 -514
- package/src/toolchain/env-check.ts +279 -285
- package/src/toolchain/index.ts +1703 -1286
- package/src/toolchain/runners.ts +80 -0
- package/src/toolchain/scaffold.ts +296 -296
- package/src/toolchain/west-discover.ts +35 -13
- package/src/toolchain/west-spawn.ts +174 -168
- package/dist/async/timer-polyfill.d.ts +0 -10
- package/dist/async/timer-polyfill.js +0 -95
- package/dist/chips/board-overrides.d.ts +0 -7
- package/dist/chips/board-overrides.js +0 -11
- package/dist/chips/esp32.d.ts +0 -2
- package/dist/chips/esp32.js +0 -71
- package/dist/chips/esp32s3.d.ts +0 -2
- package/dist/chips/esp32s3.js +0 -103
- package/dist/chips/soc/.d.ts +0 -2
- package/dist/chips/soc/.js +0 -129
- package/dist/chips/soc/esp32.d.ts +0 -2
- package/dist/chips/soc/esp32.js +0 -120
- package/dist/chips/soc/esp32c3.d.ts +0 -2
- package/dist/chips/soc/esp32c3.js +0 -90
- package/dist/chips/soc/esp32c6.d.ts +0 -2
- package/dist/chips/soc/esp32c6.js +0 -109
- package/dist/chips/soc/esp32s3.d.ts +0 -2
- package/dist/chips/soc/esp32s3.js +0 -189
- package/dist/chips/soc/index.d.ts +0 -2
- package/dist/chips/soc/index.js +0 -23
- package/dist/chips/soc/nrf52840.d.ts +0 -2
- package/dist/chips/soc/nrf52840.js +0 -130
- package/dist/chips/soc/rp2040.d.ts +0 -2
- package/dist/chips/soc/rp2040.js +0 -141
- package/dist/chips/soc/rp2350a.d.ts +0 -2
- package/dist/chips/soc/rp2350a.js +0 -145
- package/dist/chips/soc/samd21g18a.d.ts +0 -2
- package/dist/chips/soc/samd21g18a.js +0 -143
- package/dist/chips/soc/stm32f411xe.d.ts +0 -2
- package/dist/chips/soc/stm32f411xe.js +0 -251
- package/dist/chips/xiao-ble.d.ts +0 -2
- package/dist/chips/xiao-ble.js +0 -100
- package/dist/lowering/power.d.ts +0 -9
- package/dist/lowering/power.js +0 -60
- package/dist/lowering/pulse.d.ts +0 -7
- package/dist/lowering/pulse.js +0 -51
- package/dist/lowering/tone.d.ts +0 -10
- package/dist/lowering/tone.js +0 -63
- package/dist/lowering/worker-backing.d.ts +0 -14
- package/dist/lowering/worker-backing.js +0 -79
- package/dist/lowering/worker.d.ts +0 -6
- package/dist/lowering/worker.js +0 -14
- package/dist/sdk/board-data.generated.d.ts +0 -2
- package/dist/sdk/board-data.generated.js +0 -4
- package/dist/sdk/catalog-walker.d.ts +0 -90
- package/dist/sdk/catalog-walker.js +0 -682
- package/dist/sdk/dts-reader.d.ts +0 -83
- package/dist/sdk/dts-reader.js +0 -596
- package/src/debug-codegen.ts +0 -207
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// ---------------------------------------------------------------------------
|
|
2
|
+
// runners.ts — read west's resolved runner facts from a built Zephyr tree.
|
|
3
|
+
//
|
|
4
|
+
// After any successful `west build`, Zephyr writes build/zephyr/runners.yaml —
|
|
5
|
+
// the FULLY RESOLVED debug/flash configuration for the board: the arch gdb
|
|
6
|
+
// binary, the openocd binary + its script search dirs, the jlink device name,
|
|
7
|
+
// the board's declared default debug runner. It is the single source of debug
|
|
8
|
+
// truth west itself uses (`west debug` / `west debugserver` read the same
|
|
9
|
+
// file), so cuttlefish reads it instead of reconstructing any of this.
|
|
10
|
+
//
|
|
11
|
+
// The parser below is deliberately minimal: it understands exactly the shape
|
|
12
|
+
// west's run_common.py emits — top-level scalars, a list section whose items
|
|
13
|
+
// sit at column 0, and a nested config map — and ignores everything else
|
|
14
|
+
// (e.g. the args section). A general YAML dependency is not worth it for one
|
|
15
|
+
// machine-generated file.
|
|
16
|
+
// ---------------------------------------------------------------------------
|
|
17
|
+
import fs from 'node:fs';
|
|
18
|
+
import { join } from 'node:path';
|
|
19
|
+
/**
|
|
20
|
+
* Parse the subset of runners.yaml cuttlefish consumes. Exported for tests.
|
|
21
|
+
* Returns undefined on shapes it does not understand (callers treat as
|
|
22
|
+
* "no facts" — never crash a build over diagnostics data).
|
|
23
|
+
*/
|
|
24
|
+
export function parseRunnersYaml(text) {
|
|
25
|
+
const runners = [];
|
|
26
|
+
let debugRunner;
|
|
27
|
+
let gdb;
|
|
28
|
+
// Section state: '' = top level, 'runners' = the list, 'config' = the map.
|
|
29
|
+
let section = '';
|
|
30
|
+
for (const rawLine of text.split(/\r?\n/)) {
|
|
31
|
+
const trimmed = rawLine.trim();
|
|
32
|
+
if (trimmed.startsWith('#') || trimmed === '')
|
|
33
|
+
continue;
|
|
34
|
+
// List items — west writes the runners list at column 0 and
|
|
35
|
+
// openocd_search indented; both belong to the last-opened section.
|
|
36
|
+
if (trimmed.startsWith('- ')) {
|
|
37
|
+
const item = trimmed.slice(2).trim();
|
|
38
|
+
if (section === 'runners')
|
|
39
|
+
runners.push(item);
|
|
40
|
+
continue; // other sections' lists (openocd_search, args) are unused
|
|
41
|
+
}
|
|
42
|
+
const indent = rawLine.length - rawLine.trimStart().length;
|
|
43
|
+
const m = trimmed.match(/^([A-Za-z0-9_.-]+):\s*(.*)$/);
|
|
44
|
+
if (!m)
|
|
45
|
+
continue; // e.g. west's empty-list `[]` lines — skip, don't bail
|
|
46
|
+
const [, key, value] = m;
|
|
47
|
+
if (indent === 0) {
|
|
48
|
+
if (key === 'runners') {
|
|
49
|
+
section = 'runners';
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
if (key === 'config') {
|
|
53
|
+
section = 'config';
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
section = '';
|
|
57
|
+
if (key === 'debug-runner' && value)
|
|
58
|
+
debugRunner = value.trim();
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
if (section === 'config' && key === 'gdb' && value) {
|
|
62
|
+
gdb = value.trim().replace(/^['"]|['"]$/g, '');
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return { runners, ...(debugRunner ? { debugRunner } : {}), ...(gdb ? { gdb } : {}) };
|
|
66
|
+
}
|
|
67
|
+
/** Read the resolved runner facts for a build dir. undefined when absent/unparseable. */
|
|
68
|
+
export function readRunnersFacts(buildDir) {
|
|
69
|
+
try {
|
|
70
|
+
return parseRunnersYaml(fs.readFileSync(join(buildDir, 'zephyr', 'runners.yaml'), 'utf-8'));
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
return undefined;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Returns true when the file was written (content changed or file was new). */
|
|
3
3
|
export declare function writeIfChanged(filePath: string, content: string): boolean;
|
|
4
4
|
/**
|
|
5
|
-
* Append
|
|
5
|
+
* Append typecad-hal library packages' devicetree overlay fragments to the
|
|
6
6
|
* generated overlay. Library entries come from the transpiler's libraries.json
|
|
7
7
|
* sidecar (next to the emitted sources) and are already gated on the
|
|
8
8
|
* library's include token appearing in the emitted sources — no re-detection.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// ---------------------------------------------------------------------------
|
|
2
2
|
// Zephyr project scaffolding
|
|
3
3
|
//
|
|
4
|
-
// Writes the CMakeLists.txt + prj.conf around the
|
|
4
|
+
// Writes the CMakeLists.txt + prj.conf around the typecad-hal-emitted src/main.cpp
|
|
5
5
|
// so `west build` has a valid Zephyr application. Idempotent: overwrites the
|
|
6
6
|
// generated files only when their content changes (avoids invalidating the
|
|
7
7
|
// Ninja incremental build's mtime-based dependency tracking).
|
|
@@ -28,7 +28,7 @@ export function writeIfChanged(filePath, content) {
|
|
|
28
28
|
return true;
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
31
|
-
* Names of the
|
|
31
|
+
* Names of the typecad-hal-emitted C/C++ sources under src/ (top level only,
|
|
32
32
|
* matching the old `src/*.cpp src/*.c` glob; sorted so the generated
|
|
33
33
|
* CMakeLists.txt is stable across readdir orderings). Empty when no sources
|
|
34
34
|
* exist yet (first prepare call).
|
|
@@ -61,7 +61,7 @@ function readEmittedSources(srcDir) {
|
|
|
61
61
|
return out;
|
|
62
62
|
}
|
|
63
63
|
/**
|
|
64
|
-
* Append
|
|
64
|
+
* Append typecad-hal library packages' devicetree overlay fragments to the
|
|
65
65
|
* generated overlay. Library entries come from the transpiler's libraries.json
|
|
66
66
|
* sidecar (next to the emitted sources) and are already gated on the
|
|
67
67
|
* library's include token appearing in the emitted sources — no re-detection.
|
|
@@ -174,7 +174,7 @@ export function scaffoldZephyrProject(projectRoot, debug = false, userKconfig, p
|
|
|
174
174
|
// configChanged and reconfigures with the new list baked in.
|
|
175
175
|
const sourceFiles = listEmittedSources(srcDir);
|
|
176
176
|
const cmakeLists = [
|
|
177
|
-
'# Auto-generated by @typecad/framework-zephyr from
|
|
177
|
+
'# Auto-generated by @typecad/framework-zephyr from typecad-hal.config.ts.',
|
|
178
178
|
'cmake_minimum_required(VERSION 3.20.0)',
|
|
179
179
|
'',
|
|
180
180
|
'# The app is its own board root: MCU-only targets generate an out-of-tree',
|
|
@@ -189,7 +189,7 @@ export function scaffoldZephyrProject(projectRoot, debug = false, userKconfig, p
|
|
|
189
189
|
'',
|
|
190
190
|
...(sourceFiles.length > 0
|
|
191
191
|
? [
|
|
192
|
-
'#
|
|
192
|
+
'# TypeCAD-emitted sources. This list is regenerated whenever the',
|
|
193
193
|
'# emitted file set changes (the scaffold rewrites CMakeLists.txt).',
|
|
194
194
|
'target_sources(app PRIVATE',
|
|
195
195
|
...sourceFiles.map((name) => ` src/${name}`),
|
|
@@ -217,12 +217,12 @@ export function scaffoldZephyrProject(projectRoot, debug = false, userKconfig, p
|
|
|
217
217
|
// delegated to resolveKconfigFragments (unit-tested in dt-config/kconfig).
|
|
218
218
|
const symbols = resolveKconfigFragments(usage, debug);
|
|
219
219
|
const prjConf = [
|
|
220
|
-
'# Auto-generated by @typecad/framework-zephyr from
|
|
221
|
-
'# Edit in
|
|
220
|
+
'# Auto-generated by @typecad/framework-zephyr from typecad-hal.config.ts.',
|
|
221
|
+
'# Edit in typecad-hal.config.ts (frameworkData), not here.',
|
|
222
222
|
'# Driver symbols are usage-gated on the emitted source — only peripherals',
|
|
223
223
|
'# the program references are enabled.',
|
|
224
224
|
'',
|
|
225
|
-
'# Route printf/stdout to the console UART (needed by the
|
|
225
|
+
'# Route printf/stdout to the console UART (needed by the typecad-hal',
|
|
226
226
|
'# test runner protocol, which uses printf via __tc_print/__tc_println).',
|
|
227
227
|
'CONFIG_STDOUT_CONSOLE=y',
|
|
228
228
|
'CONFIG_PRINTK=y',
|
|
@@ -241,7 +241,7 @@ export function scaffoldZephyrProject(projectRoot, debug = false, userKconfig, p
|
|
|
241
241
|
wifiHeaderEmitted = true;
|
|
242
242
|
}
|
|
243
243
|
// Skip auto-detected symbols that the user explicitly overrides
|
|
244
|
-
// in
|
|
244
|
+
// in typecad-hal.config.ts zephyr.kconfig — the user value is
|
|
245
245
|
// emitted in the User Kconfig section below and takes precedence.
|
|
246
246
|
if (userKconfig && userKconfig.hasOwnProperty(sym))
|
|
247
247
|
continue;
|
|
@@ -256,7 +256,7 @@ export function scaffoldZephyrProject(projectRoot, debug = false, userKconfig, p
|
|
|
256
256
|
// zephyr.kconfig overrides still win.
|
|
257
257
|
const libraryEntries = readCuttlefishLibrarySidecar(srcDir);
|
|
258
258
|
if (libraryEntries.length > 0) {
|
|
259
|
-
prjConf.push('', '# Library packages (
|
|
259
|
+
prjConf.push('', '# Library packages (typecad-hal.library.json contributions).');
|
|
260
260
|
for (const entry of libraryEntries) {
|
|
261
261
|
for (const line of entry.kconfig) {
|
|
262
262
|
const sym = line.split('=')[0];
|
|
@@ -279,10 +279,10 @@ export function scaffoldZephyrProject(projectRoot, debug = false, userKconfig, p
|
|
|
279
279
|
prjConf.push(line);
|
|
280
280
|
}
|
|
281
281
|
}
|
|
282
|
-
// Emit user-specified Kconfig from
|
|
282
|
+
// Emit user-specified Kconfig from typecad-hal.config.ts zephyr.kconfig.
|
|
283
283
|
// These override any matching auto-detected symbol (skipped above).
|
|
284
284
|
if (userKconfig) {
|
|
285
|
-
prjConf.push('', '# User Kconfig (
|
|
285
|
+
prjConf.push('', '# User Kconfig (typecad-hal.config.ts → zephyr.kconfig).');
|
|
286
286
|
for (const [sym, val] of Object.entries(userKconfig)) {
|
|
287
287
|
prjConf.push(`${sym}=${val}`);
|
|
288
288
|
}
|
|
@@ -30,6 +30,12 @@ export declare function discoverFromPath(): WestInstall | null;
|
|
|
30
30
|
/** The canonical Zephyr workspace layout puts the venv beside the SDK:
|
|
31
31
|
* <workspace>/{.venv, zephyr}. So ${ZEPHYR_BASE}/../.venv is the venv. */
|
|
32
32
|
export declare function discoverFromZephyrBase(): WestInstall | null;
|
|
33
|
+
/** The installer-written SDK dir for the default micromamba env, when the
|
|
34
|
+
* installer has run on this machine. Read WITHOUT requiring micromamba
|
|
35
|
+
* mode — a PATH/venv west install is enriched with it so builds spawned
|
|
36
|
+
* through it still pin the installer's SDK (otherwise Zephyr's CMake
|
|
37
|
+
* searches $HOME and can pick up a stray, older SDK). */
|
|
38
|
+
export declare function installerSdkDir(): string | undefined;
|
|
33
39
|
/** The installer-written ZEPHYR_BASE of the micromamba env, fs-only (no
|
|
34
40
|
* spawn) — the cheap probe shared by board-catalog overlay discovery.
|
|
35
41
|
* Undefined when the installer env or its env-vars file is absent. */
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
// 1. `west` already on PATH (env already activated / global install).
|
|
12
12
|
// 2. $ZEPHYR_BASE venv: ${ZEPHYR_BASE}/../.venv/<python> -m west.
|
|
13
13
|
// 3. micromamba env from @typecad/zephyr-installer (invoked via `micromamba run`,
|
|
14
|
-
// so
|
|
14
|
+
// so typecad-hal builds work with NO manual activation).
|
|
15
15
|
// 4. Well-known workspace layouts: ~/zephyrproject/.venv, /opt/zephyrproject/.
|
|
16
16
|
// venv, etc.
|
|
17
17
|
// 5. System pythons (`python`, `python3`, `py`) via `-m west`.
|
|
@@ -111,6 +111,34 @@ export function discoverFromZephyrBase() {
|
|
|
111
111
|
source: 'zephyr-base-venv',
|
|
112
112
|
};
|
|
113
113
|
}
|
|
114
|
+
/** The installer-written SDK dir for the default micromamba env, when the
|
|
115
|
+
* installer has run on this machine. Read WITHOUT requiring micromamba
|
|
116
|
+
* mode — a PATH/venv west install is enriched with it so builds spawned
|
|
117
|
+
* through it still pin the installer's SDK (otherwise Zephyr's CMake
|
|
118
|
+
* searches $HOME and can pick up a stray, older SDK). */
|
|
119
|
+
export function installerSdkDir() {
|
|
120
|
+
const mm = findMicromamba();
|
|
121
|
+
if (!mm)
|
|
122
|
+
return undefined;
|
|
123
|
+
const envName = process.env.TYPECAD_ZEPHYR_ENV || 'zephyr';
|
|
124
|
+
const envDir = join(mm.rootPrefix, 'envs', envName);
|
|
125
|
+
if (!existsSync(envDir))
|
|
126
|
+
return undefined;
|
|
127
|
+
const sdk = readMicromambaEnvVar(envDir, 'TYPECAD_ZEPHYR_SDK_INSTALL_DIR');
|
|
128
|
+
return sdk && existsSync(sdk) ? sdk : undefined;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* The micromamba env created by `@typecad/zephyr-installer`. The env's west
|
|
132
|
+
* lives at envs/<name>/bin/west (POSIX) or Scripts/west.exe (Windows). Found
|
|
133
|
+
* installs are invoked via `micromamba run -n <name> west …` (see
|
|
134
|
+
* west-spawn.ts), which sets up the env's full PATH (cmake/ninja/dtc) AND runs
|
|
135
|
+
* the activation hook (ZEPHYR_BASE / ZEPHYR_SDK_INSTALL_DIR) — so builds work
|
|
136
|
+
* with NO manual `micromamba activate`. This is what makes a fresh
|
|
137
|
+
* `typecad-hal build` succeed in any project without the user activating.
|
|
138
|
+
*
|
|
139
|
+
* Env name defaults to "zephyr"; override via TYPECAD_ZEPHYR_ENV. File-check
|
|
140
|
+
* based (no spawn) so it's cheap to run on every invocation.
|
|
141
|
+
*/
|
|
114
142
|
// ── Strategy 3: micromamba env (the @typecad/zephyr-installer install) ─────
|
|
115
143
|
// Locate the micromamba binary + root prefix. The installer downloads
|
|
116
144
|
// micromamba to $MAMBA_ROOT_PREFIX/bin (POSIX) or Library/bin (Windows); the
|
|
@@ -123,18 +151,6 @@ function findMicromamba() {
|
|
|
123
151
|
: join(root, 'bin', 'micromamba');
|
|
124
152
|
return existsSync(exe) ? { exe, rootPrefix: root } : null;
|
|
125
153
|
}
|
|
126
|
-
/**
|
|
127
|
-
* The micromamba env created by `@typecad/zephyr-installer`. The env's west
|
|
128
|
-
* lives at envs/<name>/bin/west (POSIX) or Scripts/west.exe (Windows). Found
|
|
129
|
-
* installs are invoked via `micromamba run -n <name> west …` (see
|
|
130
|
-
* west-spawn.ts), which sets up the env's full PATH (cmake/ninja/dtc) AND runs
|
|
131
|
-
* the activation hook (ZEPHYR_BASE / ZEPHYR_SDK_INSTALL_DIR) — so cuttlefish
|
|
132
|
-
* builds work with NO manual `micromamba activate`. This is what makes a fresh
|
|
133
|
-
* `cuttlefish build` succeed in any project without the user activating.
|
|
134
|
-
*
|
|
135
|
-
* Env name defaults to "zephyr"; override via TYPECAD_ZEPHYR_ENV. File-check
|
|
136
|
-
* based (no spawn) so it's cheap to run on every cuttlefish invocation.
|
|
137
|
-
*/
|
|
138
154
|
/** Read a TYPECAD_ZEPHYR_* value from the installer-written env-vars file in
|
|
139
155
|
* a micromamba env. Handles .sh (export VAR="val"), .bat (set "VAR=val"),
|
|
140
156
|
* and .ps1 ($env:VAR = "val"). Returns undefined if absent/unreadable. */
|
|
@@ -284,6 +300,13 @@ export function discoverWest() {
|
|
|
284
300
|
install = null;
|
|
285
301
|
}
|
|
286
302
|
if (install) {
|
|
303
|
+
// A PATH/venv west install knows nothing about the installer's SDK.
|
|
304
|
+
// Enrich it: west-spawn pins the child's ZEPHYR_SDK_INSTALL_DIR to the
|
|
305
|
+
// installer dir, so Zephyr's CMake cannot pick up a stray SDK from
|
|
306
|
+
// $HOME (a version mismatch that only surfaces at configure time).
|
|
307
|
+
if (!install.sdkInstallDir) {
|
|
308
|
+
install.sdkInstallDir = installerSdkDir();
|
|
309
|
+
}
|
|
287
310
|
cachedDiscover = install;
|
|
288
311
|
return install;
|
|
289
312
|
}
|
|
@@ -49,6 +49,12 @@ export function buildEnv(install) {
|
|
|
49
49
|
// flashing works without activation. $ZEPHYR_SDK_INSTALL_DIR (set by an
|
|
50
50
|
// activated env) wins over the discovered install dir.
|
|
51
51
|
const sdkRoot = env.ZEPHYR_SDK_INSTALL_DIR || install.sdkInstallDir;
|
|
52
|
+
// Pin the west/cmake child to the discovered SDK: without this, Zephyr's
|
|
53
|
+
// FindZephyr-sdk searches $HOME and can latch onto a stray, older SDK —
|
|
54
|
+
// a configure-time version failure that only surfaces in the build log.
|
|
55
|
+
if (!env.ZEPHYR_SDK_INSTALL_DIR && install.sdkInstallDir) {
|
|
56
|
+
env.ZEPHYR_SDK_INSTALL_DIR = install.sdkInstallDir;
|
|
57
|
+
}
|
|
52
58
|
const openocdBin = sdkRoot ? join(sdkRoot, 'hosttools', 'openocd', 'bin') : undefined;
|
|
53
59
|
const prepend = [
|
|
54
60
|
openocdBin !== undefined && existsSync(openocdBin) ? openocdBin : undefined,
|
|
@@ -92,7 +98,7 @@ export function westSpawn(westArgs, baseOptions) {
|
|
|
92
98
|
throw new Error([
|
|
93
99
|
'west (the Zephyr build tool) was not found.',
|
|
94
100
|
'',
|
|
95
|
-
'
|
|
101
|
+
'typecad-hal looked for it on PATH, in $ZEPHYR_BASE/.venv, in common',
|
|
96
102
|
'Zephyr workspace dirs (~/zephyrproject/.venv), and as a system',
|
|
97
103
|
"Python module (`python -m west`). To fix:",
|
|
98
104
|
'',
|
|
@@ -113,7 +119,7 @@ export function westSpawn(westArgs, baseOptions) {
|
|
|
113
119
|
if (install.mode === 'micromamba' && install.micromambaExe) {
|
|
114
120
|
// `micromamba run -n <env> west …` sets up the env's full PATH
|
|
115
121
|
// (cmake/ninja/dtc) and runs the activation hook (ZEPHYR_BASE /
|
|
116
|
-
// ZEPHYR_SDK_INSTALL_DIR), so
|
|
122
|
+
// ZEPHYR_SDK_INSTALL_DIR), so typecad-hal builds work WITHOUT the user
|
|
117
123
|
// activating the env. Inject MAMBA_ROOT_PREFIX so micromamba finds envs.
|
|
118
124
|
const mmEnv = { ...env };
|
|
119
125
|
if (install.mambaRootPrefix)
|