@kvell007/embed-labs-cli 0.1.0-alpha.6 → 0.1.0-alpha.60
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 +87 -23
- package/dist/index.js +2261 -112
- package/dist/index.js.map +1 -1
- package/dist/install-progress.d.ts +2 -0
- package/dist/install-progress.js +75 -0
- package/dist/install-progress.js.map +1 -0
- package/dist/local-toolchain.d.ts +190 -5
- package/dist/local-toolchain.js +1456 -84
- package/dist/local-toolchain.js.map +1 -1
- package/package.json +3 -3
package/dist/local-toolchain.js
CHANGED
|
@@ -8,9 +8,9 @@ import { Readable } from "node:stream";
|
|
|
8
8
|
import { pipeline } from "node:stream/promises";
|
|
9
9
|
import { fileURLToPath } from "node:url";
|
|
10
10
|
const DEFAULT_RELEASE_ROOT = "/Volumes/LLVM-TSPI/tspi-rk3566-llvm-release-minimal";
|
|
11
|
-
const DEFAULT_QT_SMOKE_SOURCE = "/Users/kvell/kk-project/DBT-Agent-Project/llvm-build-tspi/qt-smoke";
|
|
12
|
-
const DEFAULT_METADATA_ROOT = "/Users/kvell/kk-project/DBT-Agent-Project/llvm-build-tspi/embedlabs-release";
|
|
13
11
|
const DEFAULT_BOARD_ID = "taishanpi-1m-rk3566";
|
|
12
|
+
const PICO2W_RP2350_BOARD_ID = "pico2w-rp2350-monitor";
|
|
13
|
+
const COLOREASYPICO2_RP2350_BOARD_ID = "coloreasypico2-rp2350-monitor";
|
|
14
14
|
const DEFAULT_CHANNEL = "stable";
|
|
15
15
|
const DEFAULT_DOWNLOAD_BASE_URL = "https://download.embedboard.com";
|
|
16
16
|
const DOWNLOAD_REQUEST_TIMEOUT_MS = 12_000;
|
|
@@ -20,9 +20,15 @@ const BUILT_IN_CHANNEL = {
|
|
|
20
20
|
packages: [
|
|
21
21
|
{ id: "embedlabs.tools.vendor.rockchip", version: "1.0.0", manifest: "" },
|
|
22
22
|
{ id: "embedlabs.tools.common.llvm", version: "22.1.3", manifest: "" },
|
|
23
|
+
{ id: "embedlabs.tools.common.arm-none-eabi", version: "15.2.rel1", manifest: "" },
|
|
23
24
|
{ id: "embedlabs.tools.common.e2fsprogs", version: "1.0.0", manifest: "" },
|
|
25
|
+
{ id: "embedlabs.tools.runtime.qtquick-live-preview", version: "1.0.33", manifest: "" },
|
|
26
|
+
{ id: "embedlabs.tools.runtime.rp2350-monitor", version: "1.0.33", manifest: "" },
|
|
24
27
|
{ id: "embedlabs.family.rk356x", version: "1.0.0", manifest: "" },
|
|
25
|
-
{ id: "embedlabs.
|
|
28
|
+
{ id: "embedlabs.family.rp2350", version: "1.0.0", manifest: "" },
|
|
29
|
+
{ id: "embedlabs.board.taishanpi.1m-rk3566", version: "1.0.33", manifest: "" },
|
|
30
|
+
{ id: "embedlabs.board.pico2w.rp2350-monitor", version: "1.0.33", manifest: "" },
|
|
31
|
+
{ id: "embedlabs.board.coloreasypico2.rp2350-monitor", version: "1.0.33", manifest: "" }
|
|
26
32
|
]
|
|
27
33
|
};
|
|
28
34
|
const BUILT_IN_MANIFESTS = {
|
|
@@ -42,6 +48,14 @@ const BUILT_IN_MANIFESTS = {
|
|
|
42
48
|
hosts: ["darwin-arm64", "linux-x86_64"],
|
|
43
49
|
provides: ["llvm.clang", "llvm.clangxx", "llvm.ld_lld", "llvm.ar", "llvm.objcopy", "llvm.readelf"]
|
|
44
50
|
},
|
|
51
|
+
"embedlabs.tools.common.arm-none-eabi": {
|
|
52
|
+
schema: "embedlabs.package.v1",
|
|
53
|
+
id: "embedlabs.tools.common.arm-none-eabi",
|
|
54
|
+
version: "15.2.rel1",
|
|
55
|
+
kind: "tools",
|
|
56
|
+
hosts: ["darwin-arm64"],
|
|
57
|
+
provides: ["arm-none-eabi.gcc", "arm-none-eabi.g++", "arm-none-eabi.objcopy", "picotool"]
|
|
58
|
+
},
|
|
45
59
|
"embedlabs.tools.common.e2fsprogs": {
|
|
46
60
|
schema: "embedlabs.package.v1",
|
|
47
61
|
id: "embedlabs.tools.common.e2fsprogs",
|
|
@@ -50,6 +64,22 @@ const BUILT_IN_MANIFESTS = {
|
|
|
50
64
|
hosts: ["darwin-arm64", "linux-x86_64"],
|
|
51
65
|
provides: ["ext4.mke2fs", "ext4.resize2fs", "fakeroot"]
|
|
52
66
|
},
|
|
67
|
+
"embedlabs.tools.runtime.qtquick-live-preview": {
|
|
68
|
+
schema: "embedlabs.package.v1",
|
|
69
|
+
id: "embedlabs.tools.runtime.qtquick-live-preview",
|
|
70
|
+
version: "1.0.33",
|
|
71
|
+
kind: "tools",
|
|
72
|
+
hosts: ["darwin-arm64", "linux-x86_64"],
|
|
73
|
+
provides: ["qtquick.live_preview", "qtquick.live_preview.inspector", "qtquick.live_preview.feedback"]
|
|
74
|
+
},
|
|
75
|
+
"embedlabs.tools.runtime.rp2350-monitor": {
|
|
76
|
+
schema: "embedlabs.package.v1",
|
|
77
|
+
id: "embedlabs.tools.runtime.rp2350-monitor",
|
|
78
|
+
version: "1.0.33",
|
|
79
|
+
kind: "tools",
|
|
80
|
+
hosts: ["darwin-arm64", "linux-x86_64"],
|
|
81
|
+
provides: ["rp2350.monitor.cli", "rp2350.monitor.logic_analyzer", "rp2350.monitor.logic_decode"]
|
|
82
|
+
},
|
|
53
83
|
"embedlabs.family.rk356x": {
|
|
54
84
|
schema: "embedlabs.package.v1",
|
|
55
85
|
id: "embedlabs.family.rk356x",
|
|
@@ -62,10 +92,21 @@ const BUILT_IN_MANIFESTS = {
|
|
|
62
92
|
{ id: "embedlabs.tools.common.e2fsprogs", version: "^1.0.0" }
|
|
63
93
|
]
|
|
64
94
|
},
|
|
95
|
+
"embedlabs.family.rp2350": {
|
|
96
|
+
schema: "embedlabs.package.v1",
|
|
97
|
+
id: "embedlabs.family.rp2350",
|
|
98
|
+
version: "1.0.0",
|
|
99
|
+
kind: "family",
|
|
100
|
+
family: "rp2350",
|
|
101
|
+
requires: [
|
|
102
|
+
{ id: "embedlabs.tools.common.arm-none-eabi", version: "15.x", roles: ["compile", "uf2"] },
|
|
103
|
+
{ id: "embedlabs.tools.runtime.rp2350-monitor", version: "^1.0.33", roles: ["hardware-control", "logic-analyzer", "debug-probe"] }
|
|
104
|
+
]
|
|
105
|
+
},
|
|
65
106
|
"embedlabs.board.taishanpi.1m-rk3566": {
|
|
66
107
|
schema: "embedlabs.package.v1",
|
|
67
108
|
id: "embedlabs.board.taishanpi.1m-rk3566",
|
|
68
|
-
version: "1.0.
|
|
109
|
+
version: "1.0.33",
|
|
69
110
|
kind: "board",
|
|
70
111
|
family: "rk356x",
|
|
71
112
|
board: "TaishanPi",
|
|
@@ -74,20 +115,67 @@ const BUILT_IN_MANIFESTS = {
|
|
|
74
115
|
{ id: "embedlabs.family.rk356x", version: "^1.0.0" },
|
|
75
116
|
{ id: "embedlabs.tools.vendor.rockchip", version: "^1.0.0", roles: ["flash", "resource-image"] },
|
|
76
117
|
{ id: "embedlabs.tools.common.llvm", version: "22.x", roles: ["compile"] },
|
|
77
|
-
{ id: "embedlabs.tools.common.e2fsprogs", version: "^1.0.0", roles: ["userdata-image"] }
|
|
118
|
+
{ id: "embedlabs.tools.common.e2fsprogs", version: "^1.0.0", roles: ["userdata-image"] },
|
|
119
|
+
{ id: "embedlabs.tools.runtime.qtquick-live-preview", version: "^1.0.33", roles: ["qtquick-preview"] }
|
|
78
120
|
],
|
|
79
121
|
build_modes: ["local-llvm"]
|
|
122
|
+
},
|
|
123
|
+
"embedlabs.board.pico2w.rp2350-monitor": {
|
|
124
|
+
schema: "embedlabs.package.v1",
|
|
125
|
+
id: "embedlabs.board.pico2w.rp2350-monitor",
|
|
126
|
+
version: "1.0.33",
|
|
127
|
+
kind: "board",
|
|
128
|
+
display_name: "Pico 2 W",
|
|
129
|
+
family: "rp2350",
|
|
130
|
+
board: "Pico 2 W",
|
|
131
|
+
board_id: PICO2W_RP2350_BOARD_ID,
|
|
132
|
+
requires: [
|
|
133
|
+
{ id: "embedlabs.family.rp2350", version: "^1.0.0" },
|
|
134
|
+
{ id: "embedlabs.tools.common.arm-none-eabi", version: "15.x", roles: ["compile", "uf2", "picotool"] },
|
|
135
|
+
{ id: "embedlabs.tools.runtime.rp2350-monitor", version: "^1.0.33", roles: ["hardware-control", "logic-analyzer", "debug-probe"] }
|
|
136
|
+
],
|
|
137
|
+
build_modes: ["local-pico-sdk", "optional-rp2350-monitor"]
|
|
138
|
+
},
|
|
139
|
+
"embedlabs.board.coloreasypico2.rp2350-monitor": {
|
|
140
|
+
schema: "embedlabs.package.v1",
|
|
141
|
+
id: "embedlabs.board.coloreasypico2.rp2350-monitor",
|
|
142
|
+
version: "1.0.33",
|
|
143
|
+
kind: "board",
|
|
144
|
+
display_name: "ColorEasyPICO2",
|
|
145
|
+
family: "rp2350",
|
|
146
|
+
board: "ColorEasyPICO2",
|
|
147
|
+
board_id: COLOREASYPICO2_RP2350_BOARD_ID,
|
|
148
|
+
requires: [
|
|
149
|
+
{ id: "embedlabs.family.rp2350", version: "^1.0.0" },
|
|
150
|
+
{ id: "embedlabs.tools.common.arm-none-eabi", version: "15.x", roles: ["compile", "uf2", "picotool"] },
|
|
151
|
+
{ id: "embedlabs.tools.runtime.rp2350-monitor", version: "^1.0.33", roles: ["hardware-control", "logic-analyzer", "debug-probe"] }
|
|
152
|
+
],
|
|
153
|
+
build_modes: ["local-pico-sdk", "optional-rp2350-monitor"]
|
|
80
154
|
}
|
|
81
155
|
};
|
|
82
156
|
const INSTALL_COPY_PATHS = [
|
|
83
157
|
"toolchain/llvm-cross",
|
|
84
|
-
"toolchain/host
|
|
158
|
+
"toolchain/host",
|
|
159
|
+
"toolchain/host-tools",
|
|
160
|
+
"toolchain/qt6-rk3566-llvm-toolchain.cmake",
|
|
85
161
|
"qt-target/qt6-rk3566-llvm-6.8.3",
|
|
162
|
+
"qt-host/qt6-host-macos-6.8.3",
|
|
86
163
|
"tools/mac",
|
|
164
|
+
"toolkit-runtime/qtquick-live-preview",
|
|
165
|
+
"toolkit-runtime/rp2350-monitor",
|
|
166
|
+
"rp2350-sdk",
|
|
167
|
+
"rp2350-initial-firmware",
|
|
168
|
+
"rp2350-examples",
|
|
87
169
|
"images/current",
|
|
88
170
|
"userdata/rootfs",
|
|
89
|
-
"boot-workspace
|
|
171
|
+
"boot-workspace",
|
|
172
|
+
"README.md",
|
|
173
|
+
"meta",
|
|
174
|
+
"scripts",
|
|
175
|
+
"support",
|
|
176
|
+
"third_party"
|
|
90
177
|
];
|
|
178
|
+
const LOCAL_TOOLCHAIN_INSTALL_MODES = ["minimal", "runtime", "compile", "qt", "firmware", "full", "images"];
|
|
91
179
|
export function defaultLocalReleaseRoot() {
|
|
92
180
|
return process.env.EMBEDLABS_LOCAL_RELEASE_ROOT?.trim()
|
|
93
181
|
|| process.env.EMBEDLABS_RELEASE_ROOT?.trim()
|
|
@@ -102,12 +190,13 @@ export async function latestLocalToolchain(options = {}) {
|
|
|
102
190
|
if (!board) {
|
|
103
191
|
throw new Error(`No local toolchain board package found for ${boardId}.`);
|
|
104
192
|
}
|
|
193
|
+
const canonicalBoardId = boardIdForPackageManifest(board);
|
|
105
194
|
const packages = resolvePackageRefs(boardPackageId, channel, manifests);
|
|
106
195
|
let download;
|
|
107
196
|
let downloadError;
|
|
108
197
|
try {
|
|
109
198
|
download = await resolveLocalToolchainDownloadPlan({
|
|
110
|
-
boardId,
|
|
199
|
+
boardId: canonicalBoardId,
|
|
111
200
|
channel: channelName,
|
|
112
201
|
host: hostId(),
|
|
113
202
|
toolchain: "llvm"
|
|
@@ -116,11 +205,14 @@ export async function latestLocalToolchain(options = {}) {
|
|
|
116
205
|
catch (error) {
|
|
117
206
|
downloadError = error instanceof Error ? error.message : String(error);
|
|
118
207
|
}
|
|
208
|
+
if (!download && isNativeWindowsTaishanPiHost(canonicalBoardId, hostId())) {
|
|
209
|
+
downloadError = taishanPiWindowsRequirementMessage(hostId());
|
|
210
|
+
}
|
|
119
211
|
return {
|
|
120
|
-
board_id:
|
|
212
|
+
board_id: canonicalBoardId,
|
|
121
213
|
channel: channel.channel,
|
|
122
214
|
host: hostId(),
|
|
123
|
-
version: board.version,
|
|
215
|
+
version: download?.version ?? board.version,
|
|
124
216
|
metadata_root: metadataRoot,
|
|
125
217
|
packages,
|
|
126
218
|
download,
|
|
@@ -132,11 +224,36 @@ export async function currentLocalToolchain(installRoot, boardId = DEFAULT_BOARD
|
|
|
132
224
|
const registryPath = localToolchainRegistryPath(root);
|
|
133
225
|
try {
|
|
134
226
|
const registry = JSON.parse(await readFile(registryPath, "utf8"));
|
|
227
|
+
const environments = registry.environments;
|
|
228
|
+
const boardInstall = environments?.[normalizeBoardId(boardId)];
|
|
229
|
+
if (boardInstall?.release_root) {
|
|
230
|
+
return {
|
|
231
|
+
installed: true,
|
|
232
|
+
board_id: typeof boardInstall.board_id === "string" ? boardInstall.board_id : boardId,
|
|
233
|
+
version: typeof boardInstall.version === "string" ? boardInstall.version : undefined,
|
|
234
|
+
mode: typeof boardInstall.mode === "string" ? boardInstall.mode : undefined,
|
|
235
|
+
release_root: boardInstall.release_root,
|
|
236
|
+
registry_path: registryPath,
|
|
237
|
+
install_root: root,
|
|
238
|
+
channel: typeof boardInstall.channel === "string" ? boardInstall.channel : undefined,
|
|
239
|
+
packages: Array.isArray(boardInstall.packages) ? boardInstall.packages : undefined
|
|
240
|
+
};
|
|
241
|
+
}
|
|
135
242
|
const releaseRoot = typeof registry.release_root === "string" ? registry.release_root : undefined;
|
|
243
|
+
const registryBoardId = typeof registry.board_id === "string" ? registry.board_id : boardId;
|
|
244
|
+
if (releaseRoot && normalizeBoardId(registryBoardId) !== normalizeBoardId(boardId)) {
|
|
245
|
+
return {
|
|
246
|
+
installed: false,
|
|
247
|
+
board_id: boardId,
|
|
248
|
+
registry_path: registryPath,
|
|
249
|
+
install_root: root
|
|
250
|
+
};
|
|
251
|
+
}
|
|
136
252
|
return {
|
|
137
253
|
installed: !!releaseRoot,
|
|
138
|
-
board_id:
|
|
254
|
+
board_id: registryBoardId,
|
|
139
255
|
version: typeof registry.version === "string" ? registry.version : undefined,
|
|
256
|
+
mode: typeof registry.mode === "string" ? registry.mode : undefined,
|
|
140
257
|
release_root: releaseRoot,
|
|
141
258
|
registry_path: registryPath,
|
|
142
259
|
install_root: root,
|
|
@@ -153,48 +270,248 @@ export async function currentLocalToolchain(installRoot, boardId = DEFAULT_BOARD
|
|
|
153
270
|
};
|
|
154
271
|
}
|
|
155
272
|
}
|
|
273
|
+
async function discoverInstalledLocalToolchains(installRoot, current) {
|
|
274
|
+
const installed = new Map();
|
|
275
|
+
if (current.installed && current.release_root) {
|
|
276
|
+
installed.set(normalizeBoardId(current.board_id), {
|
|
277
|
+
board_id: current.board_id,
|
|
278
|
+
version: current.version,
|
|
279
|
+
channel: current.channel,
|
|
280
|
+
mode: current.mode,
|
|
281
|
+
release_root: current.release_root
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
const toolchainsRoot = join(installRoot, "toolchains");
|
|
285
|
+
let boardEntries;
|
|
286
|
+
try {
|
|
287
|
+
boardEntries = await readdir(toolchainsRoot, { withFileTypes: true });
|
|
288
|
+
}
|
|
289
|
+
catch {
|
|
290
|
+
return installed;
|
|
291
|
+
}
|
|
292
|
+
for (const boardEntry of boardEntries) {
|
|
293
|
+
if (!boardEntry.isDirectory()) {
|
|
294
|
+
continue;
|
|
295
|
+
}
|
|
296
|
+
const boardId = normalizeBoardId(boardEntry.name);
|
|
297
|
+
if (installed.has(boardId)) {
|
|
298
|
+
continue;
|
|
299
|
+
}
|
|
300
|
+
const boardRoot = join(toolchainsRoot, boardEntry.name);
|
|
301
|
+
let versionEntries;
|
|
302
|
+
try {
|
|
303
|
+
versionEntries = await readdir(boardRoot, { withFileTypes: true });
|
|
304
|
+
}
|
|
305
|
+
catch {
|
|
306
|
+
continue;
|
|
307
|
+
}
|
|
308
|
+
const versions = versionEntries
|
|
309
|
+
.filter((entry) => entry.isDirectory())
|
|
310
|
+
.map((entry) => entry.name)
|
|
311
|
+
.sort(compareVersionLike)
|
|
312
|
+
.reverse();
|
|
313
|
+
const version = versions[0];
|
|
314
|
+
if (!version) {
|
|
315
|
+
continue;
|
|
316
|
+
}
|
|
317
|
+
installed.set(boardId, {
|
|
318
|
+
board_id: boardId,
|
|
319
|
+
version,
|
|
320
|
+
release_root: join(boardRoot, version)
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
return installed;
|
|
324
|
+
}
|
|
325
|
+
export async function listLocalToolchainEnvironments(options = {}) {
|
|
326
|
+
const channelName = options.channel ?? DEFAULT_CHANNEL;
|
|
327
|
+
const host = hostId();
|
|
328
|
+
const installRoot = resolveInstallRoot(options.installRoot);
|
|
329
|
+
const registryPath = localToolchainRegistryPath(installRoot);
|
|
330
|
+
const { channel, manifests, metadataRoot } = await loadLocalToolchainMetadata(options.metadataRoot, channelName);
|
|
331
|
+
const current = await currentLocalToolchain(installRoot);
|
|
332
|
+
const installedByBoard = await discoverInstalledLocalToolchains(installRoot, current);
|
|
333
|
+
const boardManifests = [...manifests.values()]
|
|
334
|
+
.filter((manifest) => manifest.kind === "board")
|
|
335
|
+
.filter((manifest) => {
|
|
336
|
+
if (!options.boardId) {
|
|
337
|
+
return true;
|
|
338
|
+
}
|
|
339
|
+
const normalizedFilter = normalizeBoardId(options.boardId);
|
|
340
|
+
return boardIdForPackageManifest(manifest) === normalizedFilter
|
|
341
|
+
|| manifest.id === options.boardId
|
|
342
|
+
|| manifest.id === packageIdForBoardFilter(options.boardId);
|
|
343
|
+
})
|
|
344
|
+
.sort((left, right) => boardIdForPackageManifest(left).localeCompare(boardIdForPackageManifest(right)));
|
|
345
|
+
const environments = [];
|
|
346
|
+
const wslStatus = host.startsWith("win32-")
|
|
347
|
+
? await windowsWslStatus()
|
|
348
|
+
: undefined;
|
|
349
|
+
for (const board of boardManifests) {
|
|
350
|
+
const boardId = boardIdForPackageManifest(board);
|
|
351
|
+
const packages = resolvePackageRefs(board.id, channel, manifests);
|
|
352
|
+
const hostSupport = packageHostSupport(packages, manifests, host);
|
|
353
|
+
let download;
|
|
354
|
+
let downloadError;
|
|
355
|
+
try {
|
|
356
|
+
download = await resolveLocalToolchainDownloadPlan({
|
|
357
|
+
boardId,
|
|
358
|
+
channel: channelName,
|
|
359
|
+
host,
|
|
360
|
+
toolchain: "llvm"
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
catch (error) {
|
|
364
|
+
downloadError = error instanceof Error ? error.message : String(error);
|
|
365
|
+
}
|
|
366
|
+
if (!download && isNativeWindowsTaishanPiHost(boardId, host)) {
|
|
367
|
+
downloadError = taishanPiWindowsRequirementMessage(host);
|
|
368
|
+
}
|
|
369
|
+
const latestVersion = download?.version ?? board.version;
|
|
370
|
+
const currentForBoard = await currentLocalToolchain(installRoot, boardId);
|
|
371
|
+
const installedCandidate = currentForBoard.installed
|
|
372
|
+
? currentForBoard
|
|
373
|
+
: installedByBoard.get(normalizeBoardId(boardId));
|
|
374
|
+
const installed = installedCandidate
|
|
375
|
+
? {
|
|
376
|
+
version: installedCandidate.version,
|
|
377
|
+
channel: installedCandidate.channel,
|
|
378
|
+
mode: installedCandidate.mode,
|
|
379
|
+
release_root: installedCandidate.release_root
|
|
380
|
+
}
|
|
381
|
+
: undefined;
|
|
382
|
+
const updateAvailable = !!installed?.version && installed.version !== latestVersion;
|
|
383
|
+
const nativeWindowsTaishanPi = isNativeWindowsTaishanPiHost(boardId, host);
|
|
384
|
+
const execution = nativeWindowsTaishanPi
|
|
385
|
+
? taishanPiWindowsExecutionRoute(host, wslStatus)
|
|
386
|
+
: {
|
|
387
|
+
kind: "native",
|
|
388
|
+
supported: !!download || !!installed || hostSupport.supported,
|
|
389
|
+
actual_host: host
|
|
390
|
+
};
|
|
391
|
+
const effectiveHostSupport = nativeWindowsTaishanPi
|
|
392
|
+
? { supported: false, unsupportedPackages: ["taishanpi-1m-rk3566 native Windows toolchain"] }
|
|
393
|
+
: download || installed
|
|
394
|
+
? { supported: true, unsupportedPackages: [] }
|
|
395
|
+
: hostSupport;
|
|
396
|
+
const status = !effectiveHostSupport.supported
|
|
397
|
+
? "unsupported_host"
|
|
398
|
+
: updateAvailable
|
|
399
|
+
? "update_available"
|
|
400
|
+
: installed
|
|
401
|
+
? "installed"
|
|
402
|
+
: "available";
|
|
403
|
+
const mode = download?.default_mode ?? "qt";
|
|
404
|
+
const installModes = download
|
|
405
|
+
? localToolchainInstallModesForDownload(download)
|
|
406
|
+
: installed?.mode
|
|
407
|
+
? [installed.mode]
|
|
408
|
+
: localToolchainInstallModesForDownload(download);
|
|
409
|
+
environments.push({
|
|
410
|
+
board_id: boardId,
|
|
411
|
+
package_id: board.id,
|
|
412
|
+
display_name: board.display_name || [board.board, board.variant].filter(Boolean).join(" ") || boardId,
|
|
413
|
+
family: board.family,
|
|
414
|
+
variant: board.variant,
|
|
415
|
+
channel: channel.channel,
|
|
416
|
+
host,
|
|
417
|
+
status,
|
|
418
|
+
supported_host: effectiveHostSupport.supported,
|
|
419
|
+
unsupported_packages: effectiveHostSupport.unsupportedPackages,
|
|
420
|
+
install_modes: installModes,
|
|
421
|
+
installed,
|
|
422
|
+
latest: {
|
|
423
|
+
version: latestVersion,
|
|
424
|
+
default_mode: download?.default_mode,
|
|
425
|
+
source_url: download?.source_url,
|
|
426
|
+
manifest_url: download?.manifest_url,
|
|
427
|
+
component_count: download?.components?.length,
|
|
428
|
+
download_error: downloadError
|
|
429
|
+
},
|
|
430
|
+
packages,
|
|
431
|
+
components: download?.components?.map(localToolchainEnvironmentComponent),
|
|
432
|
+
execution,
|
|
433
|
+
install_command: nativeWindowsTaishanPi ? "embedlabs local wsl status" : `embedlabs local toolchain install --board ${boardId} --mode ${mode}`,
|
|
434
|
+
update_command: nativeWindowsTaishanPi ? "embedlabs local wsl status" : `embedlabs local toolchain install --board ${boardId} --mode ${mode} --force`,
|
|
435
|
+
notes: environmentNotes({ boardId, status, downloadError, unsupportedPackages: effectiveHostSupport.unsupportedPackages })
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
const filteredEnvironments = options.installedOnly
|
|
439
|
+
? environments.filter((environment) => !!environment.installed)
|
|
440
|
+
: environments;
|
|
441
|
+
return {
|
|
442
|
+
host,
|
|
443
|
+
channel: channel.channel,
|
|
444
|
+
metadata_source: metadataRoot ? "local_override" : "built_in",
|
|
445
|
+
metadata_root: metadataRoot,
|
|
446
|
+
install_root: installRoot,
|
|
447
|
+
registry_path: registryPath,
|
|
448
|
+
environments: filteredEnvironments
|
|
449
|
+
};
|
|
450
|
+
}
|
|
156
451
|
export async function installLocalToolchain(options = {}) {
|
|
157
452
|
const latest = await latestLocalToolchain(options);
|
|
453
|
+
if (isNativeWindowsTaishanPiHost(latest.board_id, latest.host)) {
|
|
454
|
+
throw new Error(taishanPiWindowsRequirementMessage(latest.host));
|
|
455
|
+
}
|
|
158
456
|
const installRoot = resolveInstallRoot(options.installRoot);
|
|
159
457
|
const releaseRoot = resolve(installRoot, "toolchains", latest.board_id, latest.version);
|
|
458
|
+
const installMode = normalizeLocalToolchainInstallMode(options.mode ?? latest.download?.default_mode);
|
|
160
459
|
if (await pathExists(releaseRoot) && !options.force) {
|
|
161
|
-
|
|
460
|
+
await rewriteLocalToolchainPortablePaths(releaseRoot, latest.board_id);
|
|
461
|
+
const validation = await validateLocalToolchain({ releaseRoot, mode: installMode, boardId: latest.board_id });
|
|
162
462
|
if (!validation.ok) {
|
|
163
|
-
|
|
463
|
+
if (latest.download?.components?.length) {
|
|
464
|
+
// Component installs can upgrade an existing lower-mode install by overlaying
|
|
465
|
+
// only the newly selected components instead of deleting the whole tree.
|
|
466
|
+
}
|
|
467
|
+
else {
|
|
468
|
+
throw new Error(`Existing local toolchain is incomplete at ${releaseRoot}; rerun with --force.`);
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
else {
|
|
472
|
+
await writeCurrentRegistry(installRoot, latest, releaseRoot, installMode);
|
|
473
|
+
return {
|
|
474
|
+
board_id: latest.board_id,
|
|
475
|
+
version: latest.version,
|
|
476
|
+
channel: latest.channel,
|
|
477
|
+
host: latest.host,
|
|
478
|
+
mode: installMode,
|
|
479
|
+
install_root: installRoot,
|
|
480
|
+
release_root: releaseRoot,
|
|
481
|
+
registry_path: localToolchainRegistryPath(installRoot),
|
|
482
|
+
source: { kind: "directory", value: releaseRoot },
|
|
483
|
+
installed_paths: [],
|
|
484
|
+
packages: latest.packages,
|
|
485
|
+
validation
|
|
486
|
+
};
|
|
164
487
|
}
|
|
165
|
-
await writeCurrentRegistry(installRoot, latest, releaseRoot);
|
|
166
|
-
return {
|
|
167
|
-
board_id: latest.board_id,
|
|
168
|
-
version: latest.version,
|
|
169
|
-
channel: latest.channel,
|
|
170
|
-
host: latest.host,
|
|
171
|
-
install_root: installRoot,
|
|
172
|
-
release_root: releaseRoot,
|
|
173
|
-
registry_path: localToolchainRegistryPath(installRoot),
|
|
174
|
-
source: { kind: "directory", value: releaseRoot },
|
|
175
|
-
installed_paths: [],
|
|
176
|
-
packages: latest.packages,
|
|
177
|
-
validation
|
|
178
|
-
};
|
|
179
488
|
}
|
|
180
489
|
const tempDir = await mkdtemp(join(tmpdir(), "embedlabs-local-toolchain-install-"));
|
|
181
490
|
try {
|
|
182
491
|
const sourceRoot = await sourceReleaseRootForInstall(options, latest, installRoot, tempDir);
|
|
183
|
-
await
|
|
492
|
+
if (options.force || !await pathExists(releaseRoot) || sourceRoot.source.kind !== "components") {
|
|
493
|
+
await rm(releaseRoot, { recursive: true, force: true });
|
|
494
|
+
}
|
|
184
495
|
await mkdir(releaseRoot, { recursive: true });
|
|
185
496
|
const installedPaths = [];
|
|
186
|
-
for (const relativePath of
|
|
187
|
-
const sourcePath =
|
|
497
|
+
for (const relativePath of installCopyPathsForBoard(latest.board_id)) {
|
|
498
|
+
const sourcePath = await resolveInstallSourcePathForBoard(sourceRoot.path, relativePath, latest.board_id);
|
|
188
499
|
if (!await pathExists(sourcePath)) {
|
|
189
500
|
continue;
|
|
190
501
|
}
|
|
191
502
|
const targetPath = resolve(releaseRoot, relativePath);
|
|
192
503
|
await mkdir(dirname(targetPath), { recursive: true });
|
|
193
|
-
await cp(sourcePath, targetPath, {
|
|
504
|
+
await cp(sourcePath, targetPath, {
|
|
505
|
+
recursive: true,
|
|
506
|
+
force: true,
|
|
507
|
+
preserveTimestamps: true,
|
|
508
|
+
verbatimSymlinks: true
|
|
509
|
+
});
|
|
194
510
|
installedPaths.push(relativePath);
|
|
195
511
|
}
|
|
196
|
-
await
|
|
197
|
-
|
|
512
|
+
await rewriteLocalToolchainPortablePaths(releaseRoot, latest.board_id);
|
|
513
|
+
await writeCurrentRegistry(installRoot, latest, releaseRoot, installMode, sourceRoot.source);
|
|
514
|
+
const validation = await validateLocalToolchain({ releaseRoot, mode: installMode, boardId: latest.board_id });
|
|
198
515
|
if (!validation.ok) {
|
|
199
516
|
throw new Error(`Installed local toolchain is incomplete: ${validation.missing_paths.join(", ")}`);
|
|
200
517
|
}
|
|
@@ -203,6 +520,7 @@ export async function installLocalToolchain(options = {}) {
|
|
|
203
520
|
version: latest.version,
|
|
204
521
|
channel: latest.channel,
|
|
205
522
|
host: latest.host,
|
|
523
|
+
mode: installMode,
|
|
206
524
|
install_root: installRoot,
|
|
207
525
|
release_root: releaseRoot,
|
|
208
526
|
registry_path: localToolchainRegistryPath(installRoot),
|
|
@@ -216,19 +534,183 @@ export async function installLocalToolchain(options = {}) {
|
|
|
216
534
|
await rm(tempDir, { recursive: true, force: true });
|
|
217
535
|
}
|
|
218
536
|
}
|
|
219
|
-
export async function
|
|
220
|
-
const
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
[
|
|
229
|
-
[
|
|
230
|
-
|
|
231
|
-
|
|
537
|
+
export async function windowsWslStatus() {
|
|
538
|
+
const result = {
|
|
539
|
+
host: hostId(),
|
|
540
|
+
platform: platform(),
|
|
541
|
+
arch: arch(),
|
|
542
|
+
checked_at: new Date().toISOString(),
|
|
543
|
+
applicable: platform() === "win32",
|
|
544
|
+
wsl_available: false,
|
|
545
|
+
usable: false,
|
|
546
|
+
distributions: [],
|
|
547
|
+
online_distributions: [],
|
|
548
|
+
taishanpi_execution: {
|
|
549
|
+
supported: false,
|
|
550
|
+
required_host: "linux-x86_64",
|
|
551
|
+
windows_host: hostId(),
|
|
552
|
+
route: "wsl2",
|
|
553
|
+
status: platform() === "win32" ? "wsl_missing" : "wsl_not_applicable",
|
|
554
|
+
install_command: "embedlabs local wsl status",
|
|
555
|
+
reason: platform() === "win32"
|
|
556
|
+
? "WSL status has not been checked yet."
|
|
557
|
+
: "WSL2 is only applicable on Windows hosts."
|
|
558
|
+
},
|
|
559
|
+
commands: {
|
|
560
|
+
status: "wsl.exe --status",
|
|
561
|
+
list: "wsl.exe -l -v",
|
|
562
|
+
list_online: "wsl.exe --list --online",
|
|
563
|
+
install_ubuntu: "wsl.exe --install -d Ubuntu --web-download"
|
|
564
|
+
},
|
|
565
|
+
notes: []
|
|
566
|
+
};
|
|
567
|
+
if (!result.applicable) {
|
|
568
|
+
result.taishanpi_execution = taishanPiWindowsExecutionRoute(result.host, result);
|
|
569
|
+
result.notes.push("WSL2 is only required for TaishanPi local development on Windows hosts.");
|
|
570
|
+
return result;
|
|
571
|
+
}
|
|
572
|
+
const whereWsl = await runCommand(["cmd", "/c", "where wsl.exe"], homedir());
|
|
573
|
+
result.wsl_available = whereWsl.exit_code === 0;
|
|
574
|
+
if (!result.wsl_available) {
|
|
575
|
+
result.taishanpi_execution = taishanPiWindowsExecutionRoute(result.host, result);
|
|
576
|
+
result.notes.push("wsl.exe was not found. Enable Windows Subsystem for Linux before installing TaishanPi local tools.");
|
|
577
|
+
return result;
|
|
578
|
+
}
|
|
579
|
+
const list = await runCommand(["wsl.exe", "-l", "-v"], homedir());
|
|
580
|
+
const normalized = normalizeWindowsCommandText([...list.stdout_tail, ...list.stderr_tail].join("\n"));
|
|
581
|
+
result.distributions = list.exit_code === 0 ? parseWslDistributionList(normalized) : [];
|
|
582
|
+
const online = await runCommand(["wsl.exe", "--list", "--online"], homedir());
|
|
583
|
+
const normalizedOnline = normalizeWindowsCommandText([...online.stdout_tail, ...online.stderr_tail].join("\n"));
|
|
584
|
+
result.online_distributions = online.exit_code === 0 ? parseWslOnlineDistributionList(normalizedOnline) : [];
|
|
585
|
+
result.usable = list.exit_code === 0 && result.distributions.length > 0;
|
|
586
|
+
result.taishanpi_execution = taishanPiWindowsExecutionRoute(result.host, result);
|
|
587
|
+
if (!result.usable) {
|
|
588
|
+
result.notes.push("No usable WSL2 distribution is configured yet. Install Ubuntu, restart Windows if requested, then run Embed Labs TaishanPi tools inside WSL2.");
|
|
589
|
+
}
|
|
590
|
+
else {
|
|
591
|
+
result.notes.push("Run TaishanPi local compile, Qt, and image tooling inside the listed WSL2 distribution. Native Windows TaishanPi toolchain packages are intentionally not published.");
|
|
592
|
+
}
|
|
593
|
+
if (result.host === "win32-arm64") {
|
|
594
|
+
result.notes.push("This Windows ARM64 host maps WSL2 to linux-arm64. TaishanPi local compile/Qt/image parity still requires a published linux-arm64/native Windows package, or a separate Windows x64 + WSL2/linux-x86_64 package and validation.");
|
|
595
|
+
}
|
|
596
|
+
return result;
|
|
597
|
+
}
|
|
598
|
+
export async function windowsWslInstall(options = {}) {
|
|
599
|
+
const distro = options.distribution?.trim() || "Ubuntu";
|
|
600
|
+
const command = ["wsl.exe", "--install", "-d", distro];
|
|
601
|
+
if (options.noLaunch !== false) {
|
|
602
|
+
command.push("--no-launch");
|
|
603
|
+
}
|
|
604
|
+
if (options.webDownload !== false) {
|
|
605
|
+
command.push("--web-download");
|
|
606
|
+
}
|
|
607
|
+
const notes = [];
|
|
608
|
+
if (platform() !== "win32") {
|
|
609
|
+
notes.push("WSL installation can only run on Windows hosts.");
|
|
610
|
+
return {
|
|
611
|
+
host: hostId(),
|
|
612
|
+
platform: platform(),
|
|
613
|
+
arch: arch(),
|
|
614
|
+
command,
|
|
615
|
+
exit_code: 1,
|
|
616
|
+
stdout_tail: [],
|
|
617
|
+
stderr_tail: [],
|
|
618
|
+
status_after: await windowsWslStatus(),
|
|
619
|
+
notes
|
|
620
|
+
};
|
|
621
|
+
}
|
|
622
|
+
const result = await runCommandWithTimeout(command, homedir(), options.timeoutMs ?? 600_000);
|
|
623
|
+
const statusAfter = await windowsWslStatus();
|
|
624
|
+
if (result.exit_code === 0) {
|
|
625
|
+
notes.push("WSL install command completed. If Windows requests a restart, restart before running TaishanPi local tools.");
|
|
626
|
+
}
|
|
627
|
+
else {
|
|
628
|
+
notes.push("WSL install command did not complete successfully. Run the same command in an elevated Windows terminal if the error indicates permissions or reboot requirements.");
|
|
629
|
+
}
|
|
630
|
+
if (!statusAfter.usable) {
|
|
631
|
+
notes.push("WSL2 is still not usable after this command. Complete first-launch setup for the distribution, then rerun embedlabs local wsl status.");
|
|
632
|
+
}
|
|
633
|
+
return {
|
|
634
|
+
host: hostId(),
|
|
635
|
+
platform: platform(),
|
|
636
|
+
arch: arch(),
|
|
637
|
+
command,
|
|
638
|
+
exit_code: result.exit_code,
|
|
639
|
+
stdout_tail: result.stdout_tail,
|
|
640
|
+
stderr_tail: result.stderr_tail,
|
|
641
|
+
status_after: statusAfter,
|
|
642
|
+
notes
|
|
643
|
+
};
|
|
644
|
+
}
|
|
645
|
+
export async function uninstallLocalToolchain(options = {}) {
|
|
646
|
+
if (!options.boardId?.trim()) {
|
|
647
|
+
throw new Error("board_id is required for local toolchain uninstall.");
|
|
648
|
+
}
|
|
649
|
+
const boardId = normalizeBoardId(options.boardId);
|
|
650
|
+
const installRoot = resolveInstallRoot(options.installRoot);
|
|
651
|
+
const registryPath = localToolchainRegistryPath(installRoot);
|
|
652
|
+
const boardRoot = resolve(installRoot, "toolchains", boardId);
|
|
653
|
+
const removedPaths = [];
|
|
654
|
+
if (await pathExists(boardRoot)) {
|
|
655
|
+
await rm(boardRoot, { recursive: true, force: true });
|
|
656
|
+
removedPaths.push(boardRoot);
|
|
657
|
+
}
|
|
658
|
+
let removedRegistryEntry = false;
|
|
659
|
+
let existing = {};
|
|
660
|
+
try {
|
|
661
|
+
existing = JSON.parse(await readFile(registryPath, "utf8"));
|
|
662
|
+
}
|
|
663
|
+
catch {
|
|
664
|
+
existing = {};
|
|
665
|
+
}
|
|
666
|
+
const environments = isRecord(existing.environments)
|
|
667
|
+
? { ...existing.environments }
|
|
668
|
+
: {};
|
|
669
|
+
if (Object.prototype.hasOwnProperty.call(environments, boardId)) {
|
|
670
|
+
delete environments[boardId];
|
|
671
|
+
removedRegistryEntry = true;
|
|
672
|
+
}
|
|
673
|
+
const topLevelBoard = normalizeBoardId(String(existing.board_id ?? DEFAULT_BOARD_ID));
|
|
674
|
+
const topLevelPointsToBoard = topLevelBoard === boardId && typeof existing.release_root === "string";
|
|
675
|
+
const cleaned = { ...existing, environments, updated_at: new Date().toISOString() };
|
|
676
|
+
if (topLevelPointsToBoard) {
|
|
677
|
+
for (const key of [
|
|
678
|
+
"installed",
|
|
679
|
+
"board_id",
|
|
680
|
+
"version",
|
|
681
|
+
"channel",
|
|
682
|
+
"host",
|
|
683
|
+
"mode",
|
|
684
|
+
"release_root",
|
|
685
|
+
"packages",
|
|
686
|
+
"source",
|
|
687
|
+
"installed_components"
|
|
688
|
+
]) {
|
|
689
|
+
delete cleaned[key];
|
|
690
|
+
}
|
|
691
|
+
removedRegistryEntry = true;
|
|
692
|
+
}
|
|
693
|
+
if (removedRegistryEntry || Object.keys(environments).length > 0 || Object.keys(existing).length > 0) {
|
|
694
|
+
await mkdir(dirname(registryPath), { recursive: true });
|
|
695
|
+
await writeFile(registryPath, `${JSON.stringify(cleaned, null, 2)}\n`, "utf8");
|
|
696
|
+
}
|
|
697
|
+
return {
|
|
698
|
+
board_id: boardId,
|
|
699
|
+
install_root: installRoot,
|
|
700
|
+
registry_path: registryPath,
|
|
701
|
+
removed: removedPaths.length > 0 || removedRegistryEntry,
|
|
702
|
+
removed_paths: removedPaths,
|
|
703
|
+
removed_registry_entry: removedRegistryEntry,
|
|
704
|
+
remaining_installed_boards: Object.keys(environments).sort(),
|
|
705
|
+
observed_at: new Date().toISOString()
|
|
706
|
+
};
|
|
707
|
+
}
|
|
708
|
+
export async function validateLocalToolchain(input) {
|
|
709
|
+
const releaseRoot = typeof input === "string" ? input : input?.releaseRoot;
|
|
710
|
+
const mode = normalizeLocalToolchainInstallMode(typeof input === "string" ? undefined : input?.mode);
|
|
711
|
+
const boardId = normalizeBoardId(typeof input === "string" ? DEFAULT_BOARD_ID : input?.boardId ?? DEFAULT_BOARD_ID);
|
|
712
|
+
const resolvedRoot = await resolveLocalReleaseRoot(releaseRoot, boardId);
|
|
713
|
+
const required = requiredLocalToolchainChecks(mode, boardId);
|
|
232
714
|
const checked_paths = [];
|
|
233
715
|
for (const [label, relativePath] of required) {
|
|
234
716
|
const absolutePath = resolve(resolvedRoot, relativePath);
|
|
@@ -239,22 +721,353 @@ export async function validateLocalToolchain(releaseRoot) {
|
|
|
239
721
|
});
|
|
240
722
|
}
|
|
241
723
|
const missing_paths = checked_paths.filter((item) => !item.exists).map((item) => item.path);
|
|
724
|
+
const path_leaks = await localToolchainPathLeaks(resolvedRoot, boardId);
|
|
725
|
+
const missing_groups = localToolchainMissingGroups(checked_paths, path_leaks);
|
|
726
|
+
const repair_command = missing_paths.length > 0 || path_leaks.length > 0
|
|
727
|
+
? `embedlabs local toolchain install --board ${boardId} --mode ${mode}`
|
|
728
|
+
: undefined;
|
|
242
729
|
return {
|
|
243
|
-
ok: missing_paths.length === 0,
|
|
730
|
+
ok: missing_paths.length === 0 && path_leaks.length === 0,
|
|
731
|
+
mode,
|
|
244
732
|
host: {
|
|
245
733
|
platform: platform(),
|
|
246
734
|
arch: arch()
|
|
247
735
|
},
|
|
248
|
-
board_id:
|
|
736
|
+
board_id: boardId,
|
|
249
737
|
release_root: resolvedRoot,
|
|
250
738
|
checked_paths,
|
|
251
739
|
missing_paths,
|
|
740
|
+
path_leaks,
|
|
741
|
+
missing_groups,
|
|
742
|
+
repair_command,
|
|
743
|
+
summary_for_user: localToolchainValidationSummary({
|
|
744
|
+
boardId,
|
|
745
|
+
mode,
|
|
746
|
+
ok: missing_paths.length === 0,
|
|
747
|
+
missingGroups: missing_groups,
|
|
748
|
+
repairCommand: repair_command
|
|
749
|
+
}),
|
|
252
750
|
notes: [
|
|
253
751
|
"Local build commands require an Embed Labs auth token so local resource use remains account attributable.",
|
|
254
|
-
|
|
752
|
+
`This validator checks the ${boardId} local support layout for install mode ${mode}.`
|
|
255
753
|
]
|
|
256
754
|
};
|
|
257
755
|
}
|
|
756
|
+
function localToolchainMissingGroups(checkedPaths, pathLeaks = []) {
|
|
757
|
+
const groups = new Set();
|
|
758
|
+
if (pathLeaks.length > 0) {
|
|
759
|
+
groups.add("portable-paths/安装包可移植路径");
|
|
760
|
+
}
|
|
761
|
+
for (const check of checkedPaths) {
|
|
762
|
+
if (check.exists) {
|
|
763
|
+
continue;
|
|
764
|
+
}
|
|
765
|
+
const text = `${check.label} ${check.path}`.toLowerCase();
|
|
766
|
+
if (text.includes("qt host") || text.includes("qtquick") || text.includes("qt cmake") || text.includes("qt target")) {
|
|
767
|
+
groups.add("qt/Qt host、target 或实时预览组件");
|
|
768
|
+
continue;
|
|
769
|
+
}
|
|
770
|
+
if (text.includes("compiler") || text.includes("readelf") || text.includes("sysroot") || text.includes("include directory") || text.includes("clang wrapper") || text.includes("gcc libraries")) {
|
|
771
|
+
groups.add("compile/交叉编译器与 sysroot");
|
|
772
|
+
continue;
|
|
773
|
+
}
|
|
774
|
+
if (text.includes("boot") || text.includes("dtb") || text.includes("resource image") || text.includes("metadata") || text.includes("/meta")) {
|
|
775
|
+
groups.add("board-resources/启动资源、DTB 与元数据");
|
|
776
|
+
continue;
|
|
777
|
+
}
|
|
778
|
+
if (text.includes("image") || text.includes("rootfs") || text.includes("parameter")) {
|
|
779
|
+
groups.add("images/基础镜像资源");
|
|
780
|
+
continue;
|
|
781
|
+
}
|
|
782
|
+
if (text.includes("rp2350") || text.includes("pico")) {
|
|
783
|
+
groups.add("rp2350/RP2350 SDK、固件或监控运行时");
|
|
784
|
+
continue;
|
|
785
|
+
}
|
|
786
|
+
groups.add("runtime/运行时文件");
|
|
787
|
+
}
|
|
788
|
+
return [...groups];
|
|
789
|
+
}
|
|
790
|
+
async function rewriteLocalToolchainPortablePaths(releaseRoot, boardId) {
|
|
791
|
+
if (normalizeBoardId(boardId) !== DEFAULT_BOARD_ID) {
|
|
792
|
+
return;
|
|
793
|
+
}
|
|
794
|
+
const replacements = taishanPiPortablePathReplacements(releaseRoot);
|
|
795
|
+
const files = await taishanPiPortableTextFiles(releaseRoot);
|
|
796
|
+
for (const file of files) {
|
|
797
|
+
let content;
|
|
798
|
+
try {
|
|
799
|
+
content = await readFile(file, "utf8");
|
|
800
|
+
}
|
|
801
|
+
catch {
|
|
802
|
+
continue;
|
|
803
|
+
}
|
|
804
|
+
const rewritten = rewritePortablePathContent(content, replacements);
|
|
805
|
+
if (rewritten !== content) {
|
|
806
|
+
await writeFile(file, rewritten, "utf8");
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
async function localToolchainPathLeaks(releaseRoot, boardId) {
|
|
811
|
+
if (normalizeBoardId(boardId) !== DEFAULT_BOARD_ID || !await pathExists(releaseRoot)) {
|
|
812
|
+
return [];
|
|
813
|
+
}
|
|
814
|
+
const forbidden = taishanPiForbiddenPortablePathFragments();
|
|
815
|
+
const files = await taishanPiPortableTextFiles(releaseRoot);
|
|
816
|
+
const leaks = [];
|
|
817
|
+
for (const file of files) {
|
|
818
|
+
let content;
|
|
819
|
+
try {
|
|
820
|
+
content = await readFile(file, "utf8");
|
|
821
|
+
}
|
|
822
|
+
catch {
|
|
823
|
+
continue;
|
|
824
|
+
}
|
|
825
|
+
for (const fragment of forbidden) {
|
|
826
|
+
if (content.includes(fragment)) {
|
|
827
|
+
leaks.push({
|
|
828
|
+
label: "portable path check",
|
|
829
|
+
path: file,
|
|
830
|
+
forbidden: fragment
|
|
831
|
+
});
|
|
832
|
+
break;
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
return leaks;
|
|
837
|
+
}
|
|
838
|
+
async function taishanPiPortableTextFiles(releaseRoot) {
|
|
839
|
+
const candidates = [
|
|
840
|
+
"toolchain/qt6-rk3566-llvm-toolchain.cmake",
|
|
841
|
+
"qt-target/qt6-rk3566-llvm-6.8.3/bin/target_qt.conf",
|
|
842
|
+
"qt-target/qt6-rk3566-llvm-6.8.3/lib/cmake/Qt6/Qt6Dependencies.cmake",
|
|
843
|
+
"qt-target/qt6-rk3566-llvm-6.8.3/lib/cmake/Qt6/qt.toolchain.cmake",
|
|
844
|
+
"qt-target/qt6-rk3566-llvm-6.8.3/lib/cmake/Qt6BuildInternals/QtBuildInternalsExtra.cmake",
|
|
845
|
+
"qt-target/qt6-rk3566-llvm-6.8.3/mkspecs/qdevice.pri",
|
|
846
|
+
"qt-target/qt6-rk3566-llvm-6.8.3/mkspecs/qmodule.pri",
|
|
847
|
+
"qt-target/qt6-rk3566-llvm-6.8.3/mkspecs/modules/qt_lib_core_private.pri",
|
|
848
|
+
"qt-target/qt6-rk3566-llvm-6.8.3/mkspecs/modules/qt_lib_gui_private.pri",
|
|
849
|
+
"qt-target/qt6-rk3566-llvm-6.8.3/mkspecs/modules/qt_lib_serialport.pri",
|
|
850
|
+
"qt-target/qt6-rk3566-llvm-6.8.3/mkspecs/modules/qt_lib_serialport_private.pri",
|
|
851
|
+
"qt-target/qt6-rk3566-llvm-6.8.3/mkspecs/modules/qt_lib_serialbus.pri",
|
|
852
|
+
"qt-target/qt6-rk3566-llvm-6.8.3/mkspecs/modules/qt_lib_serialbus_private.pri",
|
|
853
|
+
"qt-target/qt6-rk3566-llvm-6.8.3/lib/pkgconfig/Qt6SerialPort.pc",
|
|
854
|
+
"qt-target/qt6-rk3566-llvm-6.8.3/lib/pkgconfig/Qt6SerialBus.pc",
|
|
855
|
+
"qt-target/qt6-rk3566-llvm-6.8.3/mkspecs/modules/qt_ext_openxr_loader.pri",
|
|
856
|
+
"qt-host/qt6-host-macos-6.8.3/lib/cmake/Qt6BuildInternals/QtBuildInternalsExtra.cmake",
|
|
857
|
+
"qt-host/qt6-host-macos-6.8.3/mkspecs/modules/qt_lib_serialport.pri",
|
|
858
|
+
"qt-host/qt6-host-macos-6.8.3/mkspecs/modules/qt_lib_serialport_private.pri",
|
|
859
|
+
"qt-host/qt6-host-macos-6.8.3/mkspecs/modules/qt_lib_serialbus.pri",
|
|
860
|
+
"qt-host/qt6-host-macos-6.8.3/mkspecs/modules/qt_lib_serialbus_private.pri",
|
|
861
|
+
"qt-host/qt6-host-macos-6.8.3/mkspecs/modules/qt_ext_openxr_loader.pri"
|
|
862
|
+
];
|
|
863
|
+
const files = [];
|
|
864
|
+
for (const candidate of candidates) {
|
|
865
|
+
const file = join(releaseRoot, candidate);
|
|
866
|
+
if (await pathExists(file)) {
|
|
867
|
+
files.push(file);
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
for (const relativeDir of [
|
|
871
|
+
"qt-target/qt6-rk3566-llvm-6.8.3/lib/cmake/Qt6SerialPort",
|
|
872
|
+
"qt-target/qt6-rk3566-llvm-6.8.3/lib/cmake/Qt6SerialBus",
|
|
873
|
+
"qt-host/qt6-host-macos-6.8.3/lib/cmake/Qt6SerialPort",
|
|
874
|
+
"qt-host/qt6-host-macos-6.8.3/lib/cmake/Qt6SerialBus"
|
|
875
|
+
]) {
|
|
876
|
+
const dir = join(releaseRoot, relativeDir);
|
|
877
|
+
if (!await pathExists(dir)) {
|
|
878
|
+
continue;
|
|
879
|
+
}
|
|
880
|
+
for (const entry of await readdir(dir, { withFileTypes: true })) {
|
|
881
|
+
if (!entry.isFile()) {
|
|
882
|
+
continue;
|
|
883
|
+
}
|
|
884
|
+
const file = join(dir, entry.name);
|
|
885
|
+
if ([".cmake", ".pri", ".pc", ".json"].includes(extname(file))) {
|
|
886
|
+
files.push(file);
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
return files;
|
|
891
|
+
}
|
|
892
|
+
function taishanPiPortablePathReplacements(releaseRoot) {
|
|
893
|
+
const normalizedRoot = resolve(releaseRoot);
|
|
894
|
+
// Legacy development paths are recognized only so older staged packages can
|
|
895
|
+
// be rewritten into a portable installed layout during validation/repair.
|
|
896
|
+
return [
|
|
897
|
+
["@EMBEDLABS_RELEASE_ROOT@", normalizedRoot],
|
|
898
|
+
["/Users/kvell/kk-project/DBT-Agent-Project/llvm-build-tspi/scripts/qt6-rk3566-llvm-toolchain.cmake", join(normalizedRoot, "toolchain", "qt6-rk3566-llvm-toolchain.cmake")],
|
|
899
|
+
["/Users/kvell/kk-project/DBT-Agent-Project/llvm-build-tspi/.llvm-cross", join(normalizedRoot, "toolchain", "llvm-cross")],
|
|
900
|
+
["/Volumes/LLVM-TSPI/tspi-rk3566-llvm-release-minimal", normalizedRoot],
|
|
901
|
+
["/Volumes/LLVM-TSPI/sdk-tools/buildroot/output/rockchip_rk3566/host", join(normalizedRoot, "toolchain", "host")],
|
|
902
|
+
["/Volumes/LLVM-TSPI/qt6-host-macos-6.8.3", join(normalizedRoot, "qt-host", "qt6-host-macos-6.8.3")],
|
|
903
|
+
["/Volumes/LLVM-TSPI/qt6-rk3566-llvm-6.8.3", join(normalizedRoot, "qt-target", "qt6-rk3566-llvm-6.8.3")],
|
|
904
|
+
["/Volumes/LLVM-TSPI/qt-build-host-macos-6.8.3", join(normalizedRoot, "qt-host", "qt6-host-macos-6.8.3", ".build-info", "qt-build-host-macos-6.8.3")],
|
|
905
|
+
["/Volumes/LLVM-TSPI/qt-build-rk3566-llvm-6.8.3", join(normalizedRoot, "qt-target", "qt6-rk3566-llvm-6.8.3", ".build-info", "qt-build-rk3566-llvm-6.8.3")],
|
|
906
|
+
["/Volumes/LLVM-TSPI/qt-everywhere-src-6.8.3", join(normalizedRoot, "meta", "source", "qt-everywhere-src-6.8.3")],
|
|
907
|
+
["/Users/kvell/kk-project/DBT-Agent-Project/llvm-build-tspi", join(normalizedRoot, "meta", "source", "llvm-build-tspi")]
|
|
908
|
+
];
|
|
909
|
+
}
|
|
910
|
+
function taishanPiForbiddenPortablePathFragments() {
|
|
911
|
+
return [
|
|
912
|
+
"/Volumes/LLVM-TSPI",
|
|
913
|
+
"/Users/kvell/kk-project/DBT-Agent-Project"
|
|
914
|
+
];
|
|
915
|
+
}
|
|
916
|
+
function rewritePortablePathContent(content, replacements) {
|
|
917
|
+
let rewritten = content;
|
|
918
|
+
for (const [from, to] of replacements) {
|
|
919
|
+
rewritten = rewritten.split(from).join(to);
|
|
920
|
+
}
|
|
921
|
+
return rewritten;
|
|
922
|
+
}
|
|
923
|
+
function localToolchainValidationSummary(input) {
|
|
924
|
+
const boardName = input.boardId === DEFAULT_BOARD_ID
|
|
925
|
+
? "泰山派 1M-RK3566"
|
|
926
|
+
: input.boardId;
|
|
927
|
+
if (input.ok) {
|
|
928
|
+
if (input.boardId === DEFAULT_BOARD_ID && input.mode === "qt") {
|
|
929
|
+
return `${boardName} Qt 本地开发环境完整,可以继续 QtQuick 原型、一键交叉编译和真机部署。`;
|
|
930
|
+
}
|
|
931
|
+
return `${boardName} 本地开发环境完整,可以继续使用 ${input.mode} 模式。`;
|
|
932
|
+
}
|
|
933
|
+
const groups = input.missingGroups.length > 0 ? input.missingGroups.join("、") : "部分文件";
|
|
934
|
+
if (input.boardId === DEFAULT_BOARD_ID && input.mode === "qt") {
|
|
935
|
+
return `${boardName} Qt 本地开发环境不完整,缺少 ${groups}。这会影响一键交叉编译、实时预览或真机部署;请先执行 ${input.repairCommand} 补装缺失组件。`;
|
|
936
|
+
}
|
|
937
|
+
return `${boardName} 本地开发环境不完整,缺少 ${groups};请先执行 ${input.repairCommand} 补装缺失组件。`;
|
|
938
|
+
}
|
|
939
|
+
function normalizeLocalToolchainInstallMode(mode) {
|
|
940
|
+
const normalized = mode?.trim();
|
|
941
|
+
if (!normalized) {
|
|
942
|
+
return "qt";
|
|
943
|
+
}
|
|
944
|
+
if (LOCAL_TOOLCHAIN_INSTALL_MODES.includes(normalized)) {
|
|
945
|
+
return normalized;
|
|
946
|
+
}
|
|
947
|
+
throw new Error(`Unsupported local toolchain install mode ${normalized}; expected ${LOCAL_TOOLCHAIN_INSTALL_MODES.join(", ")}.`);
|
|
948
|
+
}
|
|
949
|
+
function requiredLocalToolchainChecks(mode, boardId) {
|
|
950
|
+
if (isRp2350MonitorBoardId(boardId)) {
|
|
951
|
+
return requiredRp2350MonitorChecks(mode);
|
|
952
|
+
}
|
|
953
|
+
const base = [
|
|
954
|
+
["release root", "."],
|
|
955
|
+
["boot resource image", "boot-workspace/out/resource.img"],
|
|
956
|
+
["boot image", "boot-workspace/out/boot.img"],
|
|
957
|
+
["boot DTB", "boot-workspace/out/tspi-rk3566-user-v10-linux.dtb"],
|
|
958
|
+
["package metadata", "meta"]
|
|
959
|
+
];
|
|
960
|
+
const rockchipTools = [
|
|
961
|
+
["Rockchip mkimage", "tools/mac/mkimage"],
|
|
962
|
+
["Rockchip dumpimage", "tools/mac/dumpimage"],
|
|
963
|
+
["Rockchip resource_tool", "tools/mac/resource_tool"],
|
|
964
|
+
["Rockchip rkdeveloptool", "tools/mac/rkdeveloptool"]
|
|
965
|
+
];
|
|
966
|
+
const compile = [
|
|
967
|
+
["C compiler", "toolchain/llvm-cross/bin/aarch64-linux-gnu-gcc"],
|
|
968
|
+
["C++ compiler", "toolchain/llvm-cross/bin/aarch64-linux-gnu-g++"],
|
|
969
|
+
["readelf", "toolchain/llvm-cross/bin/aarch64-linux-gnu-readelf"],
|
|
970
|
+
["host clang wrapper", "toolchain/host-tools/bin/clang-aarch64-linux-gnu"],
|
|
971
|
+
["host GCC libraries", "toolchain/host/lib/gcc"],
|
|
972
|
+
["target sysroot", "toolchain/host/aarch64-buildroot-linux-gnu/sysroot"],
|
|
973
|
+
["target include directory", "toolchain/host/aarch64-buildroot-linux-gnu/include"]
|
|
974
|
+
];
|
|
975
|
+
const qt = [
|
|
976
|
+
["Qt CMake", "qt-target/qt6-rk3566-llvm-6.8.3/bin/qt-cmake"],
|
|
977
|
+
["Qt target libraries", "qt-target/qt6-rk3566-llvm-6.8.3/lib"],
|
|
978
|
+
["Qt host tools", "qt-host/qt6-host-macos-6.8.3"],
|
|
979
|
+
["Qt host SerialPort CMake package", "qt-host/qt6-host-macos-6.8.3/lib/cmake/Qt6SerialPort/Qt6SerialPortConfig.cmake"],
|
|
980
|
+
["Qt host SerialBus CMake package", "qt-host/qt6-host-macos-6.8.3/lib/cmake/Qt6SerialBus/Qt6SerialBusConfig.cmake"],
|
|
981
|
+
["Qt target SerialPort library", "qt-target/qt6-rk3566-llvm-6.8.3/lib/libQt6SerialPort.so.6"],
|
|
982
|
+
["Qt target SerialPort CMake package", "qt-target/qt6-rk3566-llvm-6.8.3/lib/cmake/Qt6SerialPort/Qt6SerialPortConfig.cmake"],
|
|
983
|
+
["Qt target SerialBus library", "qt-target/qt6-rk3566-llvm-6.8.3/lib/libQt6SerialBus.so.6"],
|
|
984
|
+
["Qt target SerialBus CMake package", "qt-target/qt6-rk3566-llvm-6.8.3/lib/cmake/Qt6SerialBus/Qt6SerialBusConfig.cmake"],
|
|
985
|
+
["Qt board runtime SerialPort library", "userdata/rootfs/qt6-rk3566-llvm/lib/libQt6SerialPort.so.6"],
|
|
986
|
+
["Qt board runtime SerialBus library", "userdata/rootfs/qt6-rk3566-llvm/lib/libQt6SerialBus.so.6"],
|
|
987
|
+
["QtQuick live preview", "toolkit-runtime/qtquick-live-preview/bin/embed-qml-live-preview"]
|
|
988
|
+
];
|
|
989
|
+
const images = [
|
|
990
|
+
["base boot image", "images/current/boot.img"],
|
|
991
|
+
["base rootfs image", "images/current/rootfs.img"],
|
|
992
|
+
["base image parameter", "images/current/parameter.txt"]
|
|
993
|
+
];
|
|
994
|
+
const full = [
|
|
995
|
+
["rootfs overlay", "userdata/rootfs"]
|
|
996
|
+
];
|
|
997
|
+
if (mode === "minimal") {
|
|
998
|
+
return [...base, ...rockchipTools];
|
|
999
|
+
}
|
|
1000
|
+
if (mode === "compile") {
|
|
1001
|
+
return [...base, ...compile];
|
|
1002
|
+
}
|
|
1003
|
+
if (mode === "qt") {
|
|
1004
|
+
return [...base, ...compile, ...qt];
|
|
1005
|
+
}
|
|
1006
|
+
if (mode === "images") {
|
|
1007
|
+
return [...base, ...rockchipTools, ...images];
|
|
1008
|
+
}
|
|
1009
|
+
return [...base, ...rockchipTools, ...compile, ...qt, ...images, ...full];
|
|
1010
|
+
}
|
|
1011
|
+
function requiredRp2350MonitorChecks(mode) {
|
|
1012
|
+
const armToolchainDir = rp2350ArmToolchainDirName();
|
|
1013
|
+
const executableSuffix = platform() === "win32" ? ".exe" : "";
|
|
1014
|
+
const monitorLauncher = platform() === "win32"
|
|
1015
|
+
? "toolkit-runtime/rp2350-monitor/ui/bin/embed-labs-logic-analyzer.cmd"
|
|
1016
|
+
: "toolkit-runtime/rp2350-monitor/ui/bin/embed-labs-logic-analyzer";
|
|
1017
|
+
const base = [
|
|
1018
|
+
["release root", "."],
|
|
1019
|
+
];
|
|
1020
|
+
const runtime = [
|
|
1021
|
+
["RP2350 Monitor UI", "toolkit-runtime/rp2350-monitor/ui/index.html"],
|
|
1022
|
+
["RP2350 Monitor bridge", "toolkit-runtime/rp2350-monitor/ui/bridge/rpmon_bridge.py"],
|
|
1023
|
+
["RP2350 Monitor CLI", "toolkit-runtime/rp2350-monitor/tools/rpmon_cli.py"],
|
|
1024
|
+
["RP2350 picotool", `toolkit-runtime/rp2350-monitor/tools/picotool${executableSuffix}`],
|
|
1025
|
+
["RP2350 Monitor logic analyzer", monitorLauncher],
|
|
1026
|
+
["RP2350 Monitor AI operation contract", "toolkit-runtime/rp2350-monitor/ui/docs/ai-operation-contract.md"],
|
|
1027
|
+
["package metadata", "meta"]
|
|
1028
|
+
];
|
|
1029
|
+
if (platform() === "win32") {
|
|
1030
|
+
runtime.splice(4, 0, ["RP2350 Monitor bundled Python", "toolkit-runtime/rp2350-monitor/tools/python/python.exe"]);
|
|
1031
|
+
runtime.splice(5, 0, ["RP2350 Monitor pyserial", "toolkit-runtime/rp2350-monitor/tools/python/Lib/site-packages/serial/__init__.py"]);
|
|
1032
|
+
}
|
|
1033
|
+
const firmware = [
|
|
1034
|
+
["RP2350 Monitor UF2", "toolkit-runtime/rp2350-monitor/firmware/rp2350_monitor.uf2"],
|
|
1035
|
+
["RP2350 Monitor firmware source", "toolkit-runtime/rp2350-monitor/firmware/src/main.cpp"]
|
|
1036
|
+
];
|
|
1037
|
+
const initialFirmware = [
|
|
1038
|
+
["Pico 2 W initialization UF2", "rp2350-initial-firmware/pico2w/initial.uf2"],
|
|
1039
|
+
["ColorEasyPICO2 initialization UF2", "rp2350-initial-firmware/coloreasypico2/initial.uf2"]
|
|
1040
|
+
];
|
|
1041
|
+
const compile = [
|
|
1042
|
+
["Pico SDK", "rp2350-sdk/pico-sdk/pico_sdk_init.cmake"],
|
|
1043
|
+
["Pico SDK CMakeLists", "rp2350-sdk/pico-sdk/CMakeLists.txt"],
|
|
1044
|
+
["ARM bare-metal C compiler", `rp2350-sdk/toolchains/${armToolchainDir}/bin/arm-none-eabi-gcc${executableSuffix}`],
|
|
1045
|
+
["ARM bare-metal C++ compiler", `rp2350-sdk/toolchains/${armToolchainDir}/bin/arm-none-eabi-g++${executableSuffix}`],
|
|
1046
|
+
["picotool", `rp2350-sdk/picotool/install/picotool/picotool${executableSuffix}`]
|
|
1047
|
+
];
|
|
1048
|
+
if (mode === "compile") {
|
|
1049
|
+
return [...base, ...compile, ...initialFirmware];
|
|
1050
|
+
}
|
|
1051
|
+
if (mode === "firmware") {
|
|
1052
|
+
return [...base, ...runtime, ...firmware, ...initialFirmware];
|
|
1053
|
+
}
|
|
1054
|
+
if (mode === "full") {
|
|
1055
|
+
return [...base, ...runtime, ...firmware, ...initialFirmware, ...compile];
|
|
1056
|
+
}
|
|
1057
|
+
return [...base, ...runtime];
|
|
1058
|
+
}
|
|
1059
|
+
function rp2350ArmToolchainDirName() {
|
|
1060
|
+
if (platform() === "win32") {
|
|
1061
|
+
return "arm-gnu-toolchain-15.2.rel1-mingw-w64-x86_64-arm-none-eabi";
|
|
1062
|
+
}
|
|
1063
|
+
if (platform() === "linux" && arch() === "x64") {
|
|
1064
|
+
return "arm-gnu-toolchain-15.2.rel1-x86_64-arm-none-eabi";
|
|
1065
|
+
}
|
|
1066
|
+
if (platform() === "linux" && arch() === "arm64") {
|
|
1067
|
+
return "arm-gnu-toolchain-15.2.rel1-aarch64-arm-none-eabi";
|
|
1068
|
+
}
|
|
1069
|
+
return "arm-gnu-toolchain-15.2.rel1-darwin-arm64-arm-none-eabi";
|
|
1070
|
+
}
|
|
258
1071
|
export async function compileTaishanPiSingleFile(options) {
|
|
259
1072
|
assertAuthenticated(options.auth);
|
|
260
1073
|
const releaseRoot = await resolveLocalReleaseRoot(options.releaseRoot);
|
|
@@ -285,7 +1098,7 @@ export async function compileTaishanPiSingleFile(options) {
|
|
|
285
1098
|
export async function buildTaishanPiQtSmoke(options) {
|
|
286
1099
|
assertAuthenticated(options.auth);
|
|
287
1100
|
const releaseRoot = await resolveLocalReleaseRoot(options.releaseRoot);
|
|
288
|
-
const sourceDir = resolve(options.sourceDir ??
|
|
1101
|
+
const sourceDir = resolve(options.sourceDir ?? join(releaseRoot, "examples", "qt-smoke"));
|
|
289
1102
|
const buildDir = resolve(options.buildDir);
|
|
290
1103
|
const targetName = options.targetName ?? "qt_llvm_smoke";
|
|
291
1104
|
const qtCmake = join(releaseRoot, "qt-target", "qt6-rk3566-llvm-6.8.3", "bin", "qt-cmake");
|
|
@@ -324,15 +1137,14 @@ export async function buildTaishanPiQtSmoke(options) {
|
|
|
324
1137
|
}
|
|
325
1138
|
async function loadLocalToolchainMetadata(metadataRoot, channelName) {
|
|
326
1139
|
const explicitRoot = metadataRoot || process.env.EMBEDLABS_METADATA_ROOT?.trim();
|
|
327
|
-
|
|
328
|
-
if (!candidateRoot) {
|
|
1140
|
+
if (!explicitRoot) {
|
|
329
1141
|
return {
|
|
330
1142
|
channel: BUILT_IN_CHANNEL,
|
|
331
1143
|
manifests: new Map(Object.entries(BUILT_IN_MANIFESTS)),
|
|
332
1144
|
metadataRoot: undefined
|
|
333
1145
|
};
|
|
334
1146
|
}
|
|
335
|
-
const root = resolve(
|
|
1147
|
+
const root = resolve(explicitRoot);
|
|
336
1148
|
const channelPath = join(root, "channels", channelName, "index.json");
|
|
337
1149
|
const channel = JSON.parse(await readFile(channelPath, "utf8"));
|
|
338
1150
|
if (channel.schema !== "embedlabs.channel.v1") {
|
|
@@ -355,17 +1167,26 @@ async function loadLocalToolchainMetadata(metadataRoot, channelName) {
|
|
|
355
1167
|
return { channel, manifests, metadataRoot: root };
|
|
356
1168
|
}
|
|
357
1169
|
async function resolveLocalToolchainDownloadPlan(input) {
|
|
1170
|
+
const requestedBoardId = normalizeBoardId(input.boardId);
|
|
1171
|
+
const compatibleBoardIds = compatibleDownloadBoardIds(requestedBoardId);
|
|
358
1172
|
const channelUrl = downloadChannelUrl(input.channel);
|
|
359
1173
|
const channel = await fetchJson(channelUrl);
|
|
360
1174
|
if (channel.schema !== "embedlabs.download-channel.v1") {
|
|
361
1175
|
throw new Error(`Unexpected download channel schema ${channel.schema}.`);
|
|
362
1176
|
}
|
|
363
|
-
const
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
1177
|
+
const entries = channel.packages ?? [];
|
|
1178
|
+
let entry;
|
|
1179
|
+
for (const boardId of compatibleBoardIds) {
|
|
1180
|
+
entry = entries.find((item) => {
|
|
1181
|
+
return normalizeBoardId(item.board_id ?? "") === boardId
|
|
1182
|
+
&& item.host === input.host
|
|
1183
|
+
&& item.toolchain === input.toolchain
|
|
1184
|
+
&& (item.kind === undefined || item.kind === "toolchain-archive" || item.kind === "board-support-archive");
|
|
1185
|
+
});
|
|
1186
|
+
if (entry) {
|
|
1187
|
+
break;
|
|
1188
|
+
}
|
|
1189
|
+
}
|
|
369
1190
|
if (!entry?.manifest) {
|
|
370
1191
|
return undefined;
|
|
371
1192
|
}
|
|
@@ -374,23 +1195,28 @@ async function resolveLocalToolchainDownloadPlan(input) {
|
|
|
374
1195
|
if (manifest.id !== entry.id || manifest.version !== entry.version) {
|
|
375
1196
|
throw new Error(`Download manifest mismatch for ${entry.id}@${entry.version}.`);
|
|
376
1197
|
}
|
|
377
|
-
|
|
378
|
-
|
|
1198
|
+
const manifestBoardId = normalizeBoardId(manifest.board_id ?? "");
|
|
1199
|
+
if (!compatibleBoardIds.includes(manifestBoardId) || manifest.host !== input.host || manifest.toolchain !== input.toolchain) {
|
|
1200
|
+
throw new Error(`Download manifest does not match requested ${requestedBoardId}/${input.host}/${input.toolchain}.`);
|
|
379
1201
|
}
|
|
380
|
-
if (!manifest.archive?.file || !manifest.archive.sha256 || !Number.isFinite(manifest.archive.size_bytes))
|
|
381
|
-
|
|
1202
|
+
if ((!manifest.archive?.file || !manifest.archive.sha256 || !Number.isFinite(manifest.archive.size_bytes))
|
|
1203
|
+
&& (!Array.isArray(manifest.components) || manifest.components.length === 0)) {
|
|
1204
|
+
throw new Error(`Download manifest ${manifest.id}@${manifest.version} is missing archive/components metadata.`);
|
|
382
1205
|
}
|
|
383
|
-
const mirrors =
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
1206
|
+
const mirrors = manifest.archive
|
|
1207
|
+
? orderDownloadMirrors((manifest.mirrors ?? [])
|
|
1208
|
+
.filter((mirror) => mirror.enabled !== false && typeof mirror.url === "string" && mirror.url.length > 0)
|
|
1209
|
+
.map((mirror) => ({
|
|
1210
|
+
kind: mirror.kind || "unknown",
|
|
1211
|
+
enabled: mirror.enabled !== false,
|
|
1212
|
+
url: mirror.url,
|
|
1213
|
+
sha256: typeof mirror.sha256 === "string" ? mirror.sha256 : manifest.archive?.sha256,
|
|
1214
|
+
size_bytes: Number.isFinite(mirror.size_bytes) ? mirror.size_bytes : manifest.archive?.size_bytes
|
|
1215
|
+
})), manifest.download_policy?.preferred_order)
|
|
1216
|
+
: [];
|
|
1217
|
+
const components = downloadComponentsForBoard(requestedBoardId, (manifest.components ?? []).map((component) => normalizeDownloadComponent(component, manifest, manifestUrl)));
|
|
392
1218
|
const first = mirrors[0];
|
|
393
|
-
if (!first) {
|
|
1219
|
+
if (!first && components.length === 0) {
|
|
394
1220
|
return undefined;
|
|
395
1221
|
}
|
|
396
1222
|
return {
|
|
@@ -398,17 +1224,55 @@ async function resolveLocalToolchainDownloadPlan(input) {
|
|
|
398
1224
|
manifest_url: manifestUrl,
|
|
399
1225
|
package_id: manifest.id,
|
|
400
1226
|
version: manifest.version,
|
|
401
|
-
board_id:
|
|
1227
|
+
board_id: requestedBoardId,
|
|
402
1228
|
host: input.host,
|
|
403
1229
|
toolchain: input.toolchain,
|
|
404
|
-
source_url: first
|
|
405
|
-
mirror_kind: first
|
|
406
|
-
archive: {
|
|
1230
|
+
source_url: first?.url,
|
|
1231
|
+
mirror_kind: first?.kind,
|
|
1232
|
+
archive: manifest.archive ? {
|
|
407
1233
|
file: manifest.archive.file,
|
|
408
1234
|
size_bytes: manifest.archive.size_bytes,
|
|
409
1235
|
sha256: manifest.archive.sha256,
|
|
410
1236
|
content_type: manifest.archive.content_type
|
|
1237
|
+
} : undefined,
|
|
1238
|
+
mirrors,
|
|
1239
|
+
components: components.length > 0 ? components : undefined,
|
|
1240
|
+
default_mode: manifest.download_policy?.default_mode
|
|
1241
|
+
};
|
|
1242
|
+
}
|
|
1243
|
+
function normalizeDownloadComponent(component, manifest, manifestUrl) {
|
|
1244
|
+
if (!component.id || !component.version) {
|
|
1245
|
+
throw new Error(`Download manifest ${manifest.id}@${manifest.version} contains a component without id/version.`);
|
|
1246
|
+
}
|
|
1247
|
+
if (!component.archive?.file || !component.archive.sha256 || !Number.isFinite(component.archive.size_bytes)) {
|
|
1248
|
+
throw new Error(`Download manifest ${manifest.id}@${manifest.version} component ${component.id} is missing archive metadata.`);
|
|
1249
|
+
}
|
|
1250
|
+
const mirrors = orderDownloadMirrors((component.mirrors ?? [])
|
|
1251
|
+
.filter((mirror) => mirror.enabled !== false && typeof mirror.url === "string" && mirror.url.length > 0)
|
|
1252
|
+
.map((mirror) => ({
|
|
1253
|
+
kind: mirror.kind || "unknown",
|
|
1254
|
+
enabled: mirror.enabled !== false,
|
|
1255
|
+
url: new URL(mirror.url, manifestUrl).toString(),
|
|
1256
|
+
sha256: typeof mirror.sha256 === "string" ? mirror.sha256 : component.archive?.sha256,
|
|
1257
|
+
size_bytes: Number.isFinite(mirror.size_bytes) ? mirror.size_bytes : component.archive?.size_bytes
|
|
1258
|
+
})), manifest.download_policy?.preferred_order);
|
|
1259
|
+
const first = mirrors[0];
|
|
1260
|
+
if (!first) {
|
|
1261
|
+
throw new Error(`Download manifest ${manifest.id}@${manifest.version} component ${component.id} has no enabled mirrors.`);
|
|
1262
|
+
}
|
|
1263
|
+
return {
|
|
1264
|
+
id: component.id,
|
|
1265
|
+
version: component.version,
|
|
1266
|
+
role: component.role,
|
|
1267
|
+
install_modes: Array.isArray(component.install_modes) ? component.install_modes : undefined,
|
|
1268
|
+
archive: {
|
|
1269
|
+
file: component.archive.file,
|
|
1270
|
+
size_bytes: component.archive.size_bytes,
|
|
1271
|
+
sha256: component.archive.sha256,
|
|
1272
|
+
content_type: component.archive.content_type
|
|
411
1273
|
},
|
|
1274
|
+
source_url: first.url,
|
|
1275
|
+
mirror_kind: first.kind,
|
|
412
1276
|
mirrors
|
|
413
1277
|
};
|
|
414
1278
|
}
|
|
@@ -423,7 +1287,12 @@ function mirrorRank(kind, preferredOrder) {
|
|
|
423
1287
|
return index >= 0 ? index : preferredOrder.length + 1;
|
|
424
1288
|
}
|
|
425
1289
|
async function fetchJson(url) {
|
|
426
|
-
const response = await fetch(url, {
|
|
1290
|
+
const response = await fetch(url, {
|
|
1291
|
+
headers: {
|
|
1292
|
+
"accept-encoding": "identity"
|
|
1293
|
+
},
|
|
1294
|
+
signal: AbortSignal.timeout(DOWNLOAD_REQUEST_TIMEOUT_MS)
|
|
1295
|
+
});
|
|
427
1296
|
if (!response.ok) {
|
|
428
1297
|
throw new Error(`HTTP ${response.status} while loading ${url}`);
|
|
429
1298
|
}
|
|
@@ -467,14 +1336,157 @@ function resolvePackageRefs(packageId, channel, manifests, seen = new Set()) {
|
|
|
467
1336
|
return refs;
|
|
468
1337
|
}
|
|
469
1338
|
function boardPackageIdFor(boardId) {
|
|
470
|
-
|
|
1339
|
+
const normalized = normalizeBoardId(boardId);
|
|
1340
|
+
if (normalized === DEFAULT_BOARD_ID || normalized === "taishanpi" || normalized === "taishanpi-1m-rk3566") {
|
|
471
1341
|
return "embedlabs.board.taishanpi.1m-rk3566";
|
|
472
1342
|
}
|
|
473
|
-
if (
|
|
1343
|
+
if (normalized === COLOREASYPICO2_RP2350_BOARD_ID
|
|
1344
|
+
|| normalized === "coloreasypico2"
|
|
1345
|
+
|| normalized === "color-easy-pico2"
|
|
1346
|
+
|| normalized === "color-easy-pico-2"
|
|
1347
|
+
|| normalized === "color-easy-pico-2-rp2350-monitor"
|
|
1348
|
+
|| normalized === "ce-pico2") {
|
|
1349
|
+
return "embedlabs.board.coloreasypico2.rp2350-monitor";
|
|
1350
|
+
}
|
|
1351
|
+
if (normalized === PICO2W_RP2350_BOARD_ID
|
|
1352
|
+
|| normalized === "pico2w"
|
|
1353
|
+
|| normalized === "pico-2-w"
|
|
1354
|
+
|| normalized === "pico2"
|
|
1355
|
+
|| normalized === "rp2350"
|
|
1356
|
+
|| normalized === "rp2350-monitor") {
|
|
1357
|
+
return "embedlabs.board.pico2w.rp2350-monitor";
|
|
1358
|
+
}
|
|
1359
|
+
if (normalized.startsWith("embedlabs.board.")) {
|
|
474
1360
|
return boardId;
|
|
475
1361
|
}
|
|
476
1362
|
throw new Error(`Unsupported local toolchain board ${boardId}.`);
|
|
477
1363
|
}
|
|
1364
|
+
function packageIdForBoardFilter(boardId) {
|
|
1365
|
+
try {
|
|
1366
|
+
return boardPackageIdFor(boardId);
|
|
1367
|
+
}
|
|
1368
|
+
catch {
|
|
1369
|
+
return undefined;
|
|
1370
|
+
}
|
|
1371
|
+
}
|
|
1372
|
+
function boardIdForPackageManifest(manifest) {
|
|
1373
|
+
const explicit = manifest.board_id;
|
|
1374
|
+
if (explicit?.trim()) {
|
|
1375
|
+
return normalizeBoardId(explicit);
|
|
1376
|
+
}
|
|
1377
|
+
if (manifest.id === "embedlabs.board.taishanpi.1m-rk3566") {
|
|
1378
|
+
return DEFAULT_BOARD_ID;
|
|
1379
|
+
}
|
|
1380
|
+
if (manifest.id.startsWith("embedlabs.board.")) {
|
|
1381
|
+
return normalizeBoardId(manifest.id.slice("embedlabs.board.".length).replaceAll(".", "-"));
|
|
1382
|
+
}
|
|
1383
|
+
return normalizeBoardId([manifest.board, manifest.variant].filter(Boolean).join("-") || manifest.id);
|
|
1384
|
+
}
|
|
1385
|
+
function normalizeBoardId(boardId) {
|
|
1386
|
+
return boardId.trim().toLowerCase().replaceAll("_", "-");
|
|
1387
|
+
}
|
|
1388
|
+
function isRp2350MonitorBoardId(boardId) {
|
|
1389
|
+
const normalized = normalizeBoardId(boardId);
|
|
1390
|
+
return normalized === PICO2W_RP2350_BOARD_ID
|
|
1391
|
+
|| normalized === COLOREASYPICO2_RP2350_BOARD_ID
|
|
1392
|
+
|| normalized === "pico2w"
|
|
1393
|
+
|| normalized === "pico-2-w"
|
|
1394
|
+
|| normalized === "pico2"
|
|
1395
|
+
|| normalized === "rp2350"
|
|
1396
|
+
|| normalized === "rp2350-monitor"
|
|
1397
|
+
|| normalized === "coloreasypico2"
|
|
1398
|
+
|| normalized === "color-easy-pico2"
|
|
1399
|
+
|| normalized === "color-easy-pico-2"
|
|
1400
|
+
|| normalized === "ce-pico2";
|
|
1401
|
+
}
|
|
1402
|
+
function compatibleDownloadBoardIds(boardId) {
|
|
1403
|
+
const normalized = normalizeBoardId(boardId);
|
|
1404
|
+
if (normalized === COLOREASYPICO2_RP2350_BOARD_ID) {
|
|
1405
|
+
return [COLOREASYPICO2_RP2350_BOARD_ID, PICO2W_RP2350_BOARD_ID];
|
|
1406
|
+
}
|
|
1407
|
+
return [normalized];
|
|
1408
|
+
}
|
|
1409
|
+
function downloadComponentsForBoard(boardId, components) {
|
|
1410
|
+
const normalized = normalizeBoardId(boardId);
|
|
1411
|
+
if (normalized === DEFAULT_BOARD_ID) {
|
|
1412
|
+
return components.filter((component) => !isRp2350MonitorComponent(component));
|
|
1413
|
+
}
|
|
1414
|
+
return components;
|
|
1415
|
+
}
|
|
1416
|
+
function isRp2350MonitorComponent(component) {
|
|
1417
|
+
const text = `${component.id} ${component.role ?? ""} ${component.archive.file}`.toLowerCase();
|
|
1418
|
+
return text.includes("rp2350-monitor") || text.includes("pico2w-rp2350-monitor");
|
|
1419
|
+
}
|
|
1420
|
+
function compareVersionLike(left, right) {
|
|
1421
|
+
return left.localeCompare(right, undefined, { numeric: true, sensitivity: "base" });
|
|
1422
|
+
}
|
|
1423
|
+
function isRecord(value) {
|
|
1424
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
1425
|
+
}
|
|
1426
|
+
function packageHostSupport(packages, manifests, host) {
|
|
1427
|
+
const unsupportedPackages = [];
|
|
1428
|
+
for (const item of packages) {
|
|
1429
|
+
const manifest = manifests.get(item.id);
|
|
1430
|
+
if (manifest?.hosts?.length && !manifest.hosts.includes(host)) {
|
|
1431
|
+
unsupportedPackages.push(`${item.id}@${manifest.version}`);
|
|
1432
|
+
}
|
|
1433
|
+
}
|
|
1434
|
+
return {
|
|
1435
|
+
supported: unsupportedPackages.length === 0,
|
|
1436
|
+
unsupportedPackages
|
|
1437
|
+
};
|
|
1438
|
+
}
|
|
1439
|
+
function environmentNotes(input) {
|
|
1440
|
+
const notes = [];
|
|
1441
|
+
if (normalizeBoardId(input.boardId) === COLOREASYPICO2_RP2350_BOARD_ID) {
|
|
1442
|
+
notes.push("ColorEasyPICO2 uses the same RP2350/Pico SDK, ARM bare-metal toolchain, picotool, and optional RP2350 Monitor image package as Pico 2 W; Wi-Fi operations are not declared for this no-Wi-Fi board.");
|
|
1443
|
+
}
|
|
1444
|
+
if (isRp2350MonitorBoardId(input.boardId)) {
|
|
1445
|
+
notes.push("RP2350 Monitor is an optional hardware-control firmware image; the board environment itself is the Pico 2 W or ColorEasyPICO2 C/C++ SDK environment.");
|
|
1446
|
+
}
|
|
1447
|
+
if (isNativeWindowsTaishanPiHost(input.boardId, hostId())) {
|
|
1448
|
+
notes.push(taishanPiWindowsRequirementMessage(hostId()));
|
|
1449
|
+
notes.push("Check this computer with: embedlabs local wsl status");
|
|
1450
|
+
}
|
|
1451
|
+
if (input.status === "available") {
|
|
1452
|
+
notes.push("Environment is available but not installed on this computer.");
|
|
1453
|
+
}
|
|
1454
|
+
if (input.status === "update_available") {
|
|
1455
|
+
notes.push("A newer package is available; run the update command to refresh only the selected environment.");
|
|
1456
|
+
}
|
|
1457
|
+
if (input.status === "unsupported_host") {
|
|
1458
|
+
notes.push(`This host is missing platform support for: ${input.unsupportedPackages.join(", ")}`);
|
|
1459
|
+
}
|
|
1460
|
+
if (input.downloadError) {
|
|
1461
|
+
notes.push(`Download manifest could not be resolved yet: ${input.downloadError}`);
|
|
1462
|
+
}
|
|
1463
|
+
return notes;
|
|
1464
|
+
}
|
|
1465
|
+
function localToolchainInstallModesForDownload(download) {
|
|
1466
|
+
if (!download?.components?.length) {
|
|
1467
|
+
return [...LOCAL_TOOLCHAIN_INSTALL_MODES];
|
|
1468
|
+
}
|
|
1469
|
+
const modes = new Set();
|
|
1470
|
+
for (const component of download.components) {
|
|
1471
|
+
for (const mode of component.install_modes ?? []) {
|
|
1472
|
+
modes.add(mode);
|
|
1473
|
+
}
|
|
1474
|
+
}
|
|
1475
|
+
return modes.size > 0
|
|
1476
|
+
? [...modes].filter((mode) => LOCAL_TOOLCHAIN_INSTALL_MODES.includes(mode))
|
|
1477
|
+
: [...LOCAL_TOOLCHAIN_INSTALL_MODES];
|
|
1478
|
+
}
|
|
1479
|
+
function localToolchainEnvironmentComponent(component) {
|
|
1480
|
+
return {
|
|
1481
|
+
id: component.id,
|
|
1482
|
+
version: component.version,
|
|
1483
|
+
role: component.role,
|
|
1484
|
+
install_modes: component.install_modes,
|
|
1485
|
+
file: component.archive.file,
|
|
1486
|
+
size_bytes: component.archive.size_bytes,
|
|
1487
|
+
source_url: component.source_url
|
|
1488
|
+
};
|
|
1489
|
+
}
|
|
478
1490
|
function hostId() {
|
|
479
1491
|
if (platform() === "darwin" && arch() === "arm64") {
|
|
480
1492
|
return "darwin-arm64";
|
|
@@ -484,6 +1496,154 @@ function hostId() {
|
|
|
484
1496
|
}
|
|
485
1497
|
return `${platform()}-${arch()}`;
|
|
486
1498
|
}
|
|
1499
|
+
function isNativeWindowsTaishanPiHost(boardId, host) {
|
|
1500
|
+
return normalizeBoardId(boardId) === DEFAULT_BOARD_ID && host.startsWith("win32-");
|
|
1501
|
+
}
|
|
1502
|
+
function taishanPiWindowsExecutionRoute(host, status) {
|
|
1503
|
+
const actualHost = wslHostForWindowsHost(host);
|
|
1504
|
+
if (!host.startsWith("win32-")) {
|
|
1505
|
+
return {
|
|
1506
|
+
kind: "native",
|
|
1507
|
+
supported: false,
|
|
1508
|
+
required_host: "linux-x86_64",
|
|
1509
|
+
actual_host: host,
|
|
1510
|
+
windows_host: host,
|
|
1511
|
+
route: "wsl2",
|
|
1512
|
+
status: "wsl_not_applicable",
|
|
1513
|
+
status_command: "embedlabs local wsl status",
|
|
1514
|
+
install_command: "embedlabs local wsl status",
|
|
1515
|
+
reason: "WSL2 routing is only used from Windows hosts."
|
|
1516
|
+
};
|
|
1517
|
+
}
|
|
1518
|
+
if (!status?.wsl_available) {
|
|
1519
|
+
return {
|
|
1520
|
+
kind: "wsl2",
|
|
1521
|
+
supported: false,
|
|
1522
|
+
required_host: "linux-x86_64",
|
|
1523
|
+
actual_host: actualHost,
|
|
1524
|
+
windows_host: host,
|
|
1525
|
+
route: "wsl2",
|
|
1526
|
+
status: "wsl_missing",
|
|
1527
|
+
status_command: "embedlabs local wsl status",
|
|
1528
|
+
install_command: "embedlabs local wsl install --distribution Ubuntu",
|
|
1529
|
+
reason: "wsl.exe is not available on this Windows host."
|
|
1530
|
+
};
|
|
1531
|
+
}
|
|
1532
|
+
if (actualHost !== "linux-x86_64") {
|
|
1533
|
+
return {
|
|
1534
|
+
kind: "wsl2",
|
|
1535
|
+
supported: false,
|
|
1536
|
+
required_host: "linux-x86_64",
|
|
1537
|
+
actual_host: actualHost,
|
|
1538
|
+
windows_host: host,
|
|
1539
|
+
route: "wsl2",
|
|
1540
|
+
status: "architecture_mismatch",
|
|
1541
|
+
status_command: "embedlabs local wsl status",
|
|
1542
|
+
install_command: "embedlabs local wsl status",
|
|
1543
|
+
reason: `This Windows host maps WSL2 to ${actualHost}, but the current TaishanPi package requires linux-x86_64.`
|
|
1544
|
+
};
|
|
1545
|
+
}
|
|
1546
|
+
if (!status.usable) {
|
|
1547
|
+
return {
|
|
1548
|
+
kind: "wsl2",
|
|
1549
|
+
supported: false,
|
|
1550
|
+
required_host: "linux-x86_64",
|
|
1551
|
+
actual_host: actualHost,
|
|
1552
|
+
windows_host: host,
|
|
1553
|
+
route: "wsl2",
|
|
1554
|
+
status: "wsl_not_configured",
|
|
1555
|
+
status_command: "embedlabs local wsl status",
|
|
1556
|
+
install_command: "embedlabs local wsl install --distribution Ubuntu",
|
|
1557
|
+
reason: "No usable WSL2 distribution is configured."
|
|
1558
|
+
};
|
|
1559
|
+
}
|
|
1560
|
+
return {
|
|
1561
|
+
kind: "wsl2",
|
|
1562
|
+
supported: false,
|
|
1563
|
+
required_host: "linux-x86_64",
|
|
1564
|
+
actual_host: actualHost,
|
|
1565
|
+
windows_host: host,
|
|
1566
|
+
route: "wsl2",
|
|
1567
|
+
status: "package_missing",
|
|
1568
|
+
status_command: "embedlabs local wsl status",
|
|
1569
|
+
install_command: "embedlabs local wsl status",
|
|
1570
|
+
reason: "The Windows x64 WSL2 route is structurally compatible, but no TaishanPi linux-x86_64 package is published in the current stable channel."
|
|
1571
|
+
};
|
|
1572
|
+
}
|
|
1573
|
+
function wslHostForWindowsHost(host) {
|
|
1574
|
+
if (host === "win32-x64") {
|
|
1575
|
+
return "linux-x86_64";
|
|
1576
|
+
}
|
|
1577
|
+
if (host === "win32-arm64") {
|
|
1578
|
+
return "linux-arm64";
|
|
1579
|
+
}
|
|
1580
|
+
return undefined;
|
|
1581
|
+
}
|
|
1582
|
+
function taishanPiWindowsRequirementMessage(host) {
|
|
1583
|
+
if (host === "win32-arm64") {
|
|
1584
|
+
return "TaishanPi local compile, Qt, image, and Rockchip tooling is not available on native Windows ARM64 yet. Full parity requires a published linux-arm64/native Windows TaishanPi package, or a separately validated Windows x64 + WSL2/linux-x86_64 package.";
|
|
1585
|
+
}
|
|
1586
|
+
return "TaishanPi local compile, Qt, image, and Rockchip tooling is not available on native Windows yet. Windows x64 support requires WSL2/Linux x86_64 plus a published and validated TaishanPi linux-x86_64 package.";
|
|
1587
|
+
}
|
|
1588
|
+
function normalizeWindowsCommandText(value) {
|
|
1589
|
+
return value.replace(/\0/g, "").replace(/\r/g, "\n");
|
|
1590
|
+
}
|
|
1591
|
+
function parseWslDistributionList(value) {
|
|
1592
|
+
const distributions = [];
|
|
1593
|
+
const lines = value.split(/\n+/)
|
|
1594
|
+
.map((line) => line.trim())
|
|
1595
|
+
.filter(Boolean);
|
|
1596
|
+
for (const rawLine of lines) {
|
|
1597
|
+
if (/^(NAME|Windows Subsystem|Usage|Copyright|\-|用法|选项|命令)/i.test(rawLine)) {
|
|
1598
|
+
continue;
|
|
1599
|
+
}
|
|
1600
|
+
const isDefault = rawLine.startsWith("*");
|
|
1601
|
+
const line = rawLine.replace(/^\*\s*/, "").trim();
|
|
1602
|
+
const parts = line.split(/\s+/).filter(Boolean);
|
|
1603
|
+
if (parts.length === 0 || parts[0].includes(":")) {
|
|
1604
|
+
continue;
|
|
1605
|
+
}
|
|
1606
|
+
const maybeVersion = parts.at(-1);
|
|
1607
|
+
const version = maybeVersion && /^[12]$/.test(maybeVersion) ? maybeVersion : undefined;
|
|
1608
|
+
const state = version && parts.length >= 3 ? parts.at(-2) : parts.length >= 2 ? parts.at(-1) : undefined;
|
|
1609
|
+
distributions.push({
|
|
1610
|
+
name: parts[0],
|
|
1611
|
+
state,
|
|
1612
|
+
version,
|
|
1613
|
+
default: isDefault
|
|
1614
|
+
});
|
|
1615
|
+
}
|
|
1616
|
+
return distributions;
|
|
1617
|
+
}
|
|
1618
|
+
function parseWslOnlineDistributionList(value) {
|
|
1619
|
+
const distributions = [];
|
|
1620
|
+
const lines = value.split(/\n+/)
|
|
1621
|
+
.map((line) => line.trim())
|
|
1622
|
+
.filter(Boolean);
|
|
1623
|
+
let inTable = false;
|
|
1624
|
+
for (const rawLine of lines) {
|
|
1625
|
+
if (/^NAME\s+FRIENDLY NAME/i.test(rawLine)) {
|
|
1626
|
+
inTable = true;
|
|
1627
|
+
continue;
|
|
1628
|
+
}
|
|
1629
|
+
if (!inTable) {
|
|
1630
|
+
continue;
|
|
1631
|
+
}
|
|
1632
|
+
const isDefault = rawLine.startsWith("*");
|
|
1633
|
+
const line = rawLine.replace(/^\*\s*/, "").trim();
|
|
1634
|
+
const parts = line.split(/\s{2,}/).filter(Boolean);
|
|
1635
|
+
const name = parts[0]?.trim();
|
|
1636
|
+
if (!name || name.includes(":")) {
|
|
1637
|
+
continue;
|
|
1638
|
+
}
|
|
1639
|
+
distributions.push({
|
|
1640
|
+
name,
|
|
1641
|
+
friendly_name: parts.slice(1).join(" ").trim() || undefined,
|
|
1642
|
+
default: isDefault
|
|
1643
|
+
});
|
|
1644
|
+
}
|
|
1645
|
+
return distributions;
|
|
1646
|
+
}
|
|
487
1647
|
function resolveInstallRoot(installRoot) {
|
|
488
1648
|
return resolve(installRoot
|
|
489
1649
|
|| process.env.EMBEDLABS_HOME?.trim()
|
|
@@ -492,21 +1652,44 @@ function resolveInstallRoot(installRoot) {
|
|
|
492
1652
|
function localToolchainRegistryPath(installRoot) {
|
|
493
1653
|
return join(installRoot, "registry", "local-toolchains.json");
|
|
494
1654
|
}
|
|
495
|
-
async function writeCurrentRegistry(installRoot, latest, releaseRoot) {
|
|
1655
|
+
async function writeCurrentRegistry(installRoot, latest, releaseRoot, mode, source) {
|
|
496
1656
|
const registryPath = localToolchainRegistryPath(installRoot);
|
|
497
1657
|
await mkdir(dirname(registryPath), { recursive: true });
|
|
498
|
-
|
|
1658
|
+
let existing = {};
|
|
1659
|
+
try {
|
|
1660
|
+
existing = JSON.parse(await readFile(registryPath, "utf8"));
|
|
1661
|
+
}
|
|
1662
|
+
catch {
|
|
1663
|
+
existing = {};
|
|
1664
|
+
}
|
|
1665
|
+
const entry = {
|
|
499
1666
|
installed: true,
|
|
500
1667
|
board_id: latest.board_id,
|
|
501
1668
|
version: latest.version,
|
|
502
1669
|
channel: latest.channel,
|
|
503
1670
|
host: latest.host,
|
|
1671
|
+
mode,
|
|
504
1672
|
release_root: releaseRoot,
|
|
505
1673
|
packages: latest.packages,
|
|
1674
|
+
source,
|
|
1675
|
+
installed_components: source?.components,
|
|
1676
|
+
updated_at: new Date().toISOString()
|
|
1677
|
+
};
|
|
1678
|
+
const environments = isRecord(existing.environments)
|
|
1679
|
+
? { ...existing.environments }
|
|
1680
|
+
: {};
|
|
1681
|
+
environments[normalizeBoardId(latest.board_id)] = entry;
|
|
1682
|
+
const preserveTopLevel = latest.board_id !== DEFAULT_BOARD_ID
|
|
1683
|
+
&& typeof existing.release_root === "string"
|
|
1684
|
+
&& normalizeBoardId(String(existing.board_id ?? DEFAULT_BOARD_ID)) === DEFAULT_BOARD_ID;
|
|
1685
|
+
const topLevel = preserveTopLevel ? existing : entry;
|
|
1686
|
+
await writeFile(registryPath, `${JSON.stringify({
|
|
1687
|
+
...topLevel,
|
|
1688
|
+
environments,
|
|
506
1689
|
updated_at: new Date().toISOString()
|
|
507
1690
|
}, null, 2)}\n`, "utf8");
|
|
508
1691
|
}
|
|
509
|
-
async function resolveLocalReleaseRoot(releaseRoot) {
|
|
1692
|
+
async function resolveLocalReleaseRoot(releaseRoot, boardId = DEFAULT_BOARD_ID) {
|
|
510
1693
|
if (releaseRoot?.trim()) {
|
|
511
1694
|
return resolve(releaseRoot);
|
|
512
1695
|
}
|
|
@@ -514,7 +1697,7 @@ async function resolveLocalReleaseRoot(releaseRoot) {
|
|
|
514
1697
|
if (envRoot) {
|
|
515
1698
|
return resolve(envRoot);
|
|
516
1699
|
}
|
|
517
|
-
const current = await currentLocalToolchain(undefined,
|
|
1700
|
+
const current = await currentLocalToolchain(undefined, boardId);
|
|
518
1701
|
if (current.release_root) {
|
|
519
1702
|
return resolve(current.release_root);
|
|
520
1703
|
}
|
|
@@ -540,12 +1723,18 @@ async function sourceReleaseRootForInstall(options, latest, installRoot, tempDir
|
|
|
540
1723
|
source: { kind: "url", value: options.sourceUrl, downloaded_path: downloadedPath }
|
|
541
1724
|
};
|
|
542
1725
|
}
|
|
1726
|
+
if (latest.download?.components?.length) {
|
|
1727
|
+
return await componentSourceRootForInstall(options, latest.download, installRoot, tempDir);
|
|
1728
|
+
}
|
|
543
1729
|
if (latest.download) {
|
|
544
1730
|
const failures = [];
|
|
545
1731
|
for (const mirror of latest.download.mirrors) {
|
|
546
1732
|
if (!mirror.enabled) {
|
|
547
1733
|
continue;
|
|
548
1734
|
}
|
|
1735
|
+
if (!latest.download.archive) {
|
|
1736
|
+
continue;
|
|
1737
|
+
}
|
|
549
1738
|
const extractRoot = join(tempDir, `extract-${safeFileToken(mirror.kind)}`);
|
|
550
1739
|
try {
|
|
551
1740
|
const downloadedPath = await downloadToolchainArchive(mirror.url, installRoot, {
|
|
@@ -586,6 +1775,127 @@ async function sourceReleaseRootForInstall(options, latest, installRoot, tempDir
|
|
|
586
1775
|
}
|
|
587
1776
|
throw new Error("Local toolchain install could not resolve a source. Pass --source-url <tar.gz>, --source-release-root <path>, or configure EMBED_DOWNLOAD_BASE_URL.");
|
|
588
1777
|
}
|
|
1778
|
+
async function componentSourceRootForInstall(options, download, installRoot, tempDir) {
|
|
1779
|
+
const mode = normalizeLocalToolchainInstallMode(options.mode ?? download.default_mode);
|
|
1780
|
+
const components = selectedDownloadComponents(download.components ?? [], mode);
|
|
1781
|
+
if (components.length === 0) {
|
|
1782
|
+
throw new Error(`No local toolchain components selected for mode ${mode}.`);
|
|
1783
|
+
}
|
|
1784
|
+
const extractRoot = join(tempDir, "extract-components");
|
|
1785
|
+
await mkdir(extractRoot, { recursive: true });
|
|
1786
|
+
const installedComponents = [];
|
|
1787
|
+
const failures = [];
|
|
1788
|
+
for (const component of components) {
|
|
1789
|
+
let installed = false;
|
|
1790
|
+
for (const mirror of component.mirrors) {
|
|
1791
|
+
if (!mirror.enabled) {
|
|
1792
|
+
continue;
|
|
1793
|
+
}
|
|
1794
|
+
try {
|
|
1795
|
+
const downloadedPath = await downloadToolchainArchive(mirror.url, installRoot, {
|
|
1796
|
+
sha256: mirror.sha256 ?? component.archive.sha256,
|
|
1797
|
+
size_bytes: mirror.size_bytes ?? component.archive.size_bytes
|
|
1798
|
+
});
|
|
1799
|
+
const extracted = await runCommand(["tar", "-xzf", downloadedPath, "-C", extractRoot], tempDir);
|
|
1800
|
+
if (extracted.exit_code !== 0) {
|
|
1801
|
+
throw new Error(`Could not extract component ${component.id}: ${extracted.stderr_tail.join("\n")}`);
|
|
1802
|
+
}
|
|
1803
|
+
installedComponents.push({
|
|
1804
|
+
id: component.id,
|
|
1805
|
+
version: component.version,
|
|
1806
|
+
role: component.role,
|
|
1807
|
+
archive_file: component.archive.file,
|
|
1808
|
+
mirror_kind: mirror.kind,
|
|
1809
|
+
downloaded_path: downloadedPath,
|
|
1810
|
+
size_bytes: mirror.size_bytes ?? component.archive.size_bytes,
|
|
1811
|
+
sha256: mirror.sha256 ?? component.archive.sha256
|
|
1812
|
+
});
|
|
1813
|
+
installed = true;
|
|
1814
|
+
break;
|
|
1815
|
+
}
|
|
1816
|
+
catch (error) {
|
|
1817
|
+
failures.push(`${component.id}@${component.version}/${mirror.kind}: ${error instanceof Error ? error.message : String(error)}`);
|
|
1818
|
+
}
|
|
1819
|
+
}
|
|
1820
|
+
if (!installed) {
|
|
1821
|
+
throw new Error(`Could not install component ${component.id}@${component.version}: ${failures.join("; ")}`);
|
|
1822
|
+
}
|
|
1823
|
+
}
|
|
1824
|
+
return {
|
|
1825
|
+
path: extractRoot,
|
|
1826
|
+
source: {
|
|
1827
|
+
kind: "components",
|
|
1828
|
+
value: download.manifest_url,
|
|
1829
|
+
mirror_kind: "components",
|
|
1830
|
+
size_bytes: installedComponents.reduce((total, component) => total + component.size_bytes, 0),
|
|
1831
|
+
components: installedComponents
|
|
1832
|
+
}
|
|
1833
|
+
};
|
|
1834
|
+
}
|
|
1835
|
+
function selectedDownloadComponents(components, mode) {
|
|
1836
|
+
return components.filter((component) => {
|
|
1837
|
+
if (!component.install_modes?.length) {
|
|
1838
|
+
return true;
|
|
1839
|
+
}
|
|
1840
|
+
return component.install_modes.includes(mode);
|
|
1841
|
+
});
|
|
1842
|
+
}
|
|
1843
|
+
function installCopyPathsForBoard(boardId) {
|
|
1844
|
+
if (normalizeBoardId(boardId) === DEFAULT_BOARD_ID) {
|
|
1845
|
+
return INSTALL_COPY_PATHS.filter((relativePath) => {
|
|
1846
|
+
const normalized = relativePath.toLowerCase();
|
|
1847
|
+
return normalized !== "toolkit-runtime/rp2350-monitor"
|
|
1848
|
+
&& normalized !== "toolkit-runtime/rp2350-monitor/";
|
|
1849
|
+
});
|
|
1850
|
+
}
|
|
1851
|
+
return INSTALL_COPY_PATHS;
|
|
1852
|
+
}
|
|
1853
|
+
async function resolveInstallSourcePathForBoard(sourceRoot, relativePath, boardId) {
|
|
1854
|
+
const direct = resolve(sourceRoot, relativePath);
|
|
1855
|
+
if (await pathExists(direct)) {
|
|
1856
|
+
return direct;
|
|
1857
|
+
}
|
|
1858
|
+
if (!isRp2350MonitorBoardId(boardId)) {
|
|
1859
|
+
return direct;
|
|
1860
|
+
}
|
|
1861
|
+
const legacyRp2350Root = await findLegacyRp2350Root(sourceRoot);
|
|
1862
|
+
if (!legacyRp2350Root) {
|
|
1863
|
+
return direct;
|
|
1864
|
+
}
|
|
1865
|
+
if (relativePath === "rp2350-sdk") {
|
|
1866
|
+
return legacyRp2350Root;
|
|
1867
|
+
}
|
|
1868
|
+
if (relativePath === "rp2350-initial-firmware") {
|
|
1869
|
+
return resolve(legacyRp2350Root, "initial_firmware");
|
|
1870
|
+
}
|
|
1871
|
+
if (relativePath === "rp2350-examples") {
|
|
1872
|
+
return resolve(legacyRp2350Root, "validation");
|
|
1873
|
+
}
|
|
1874
|
+
return direct;
|
|
1875
|
+
}
|
|
1876
|
+
async function findLegacyRp2350Root(sourceRoot) {
|
|
1877
|
+
const direct = resolve(sourceRoot, "RP2350");
|
|
1878
|
+
if (await pathExists(resolve(direct, "pico-sdk", "pico_sdk_init.cmake"))) {
|
|
1879
|
+
return direct;
|
|
1880
|
+
}
|
|
1881
|
+
let entries;
|
|
1882
|
+
try {
|
|
1883
|
+
entries = await readdir(sourceRoot, { withFileTypes: true });
|
|
1884
|
+
}
|
|
1885
|
+
catch {
|
|
1886
|
+
return undefined;
|
|
1887
|
+
}
|
|
1888
|
+
for (const entry of entries) {
|
|
1889
|
+
if (!entry.isDirectory()) {
|
|
1890
|
+
continue;
|
|
1891
|
+
}
|
|
1892
|
+
const candidate = resolve(sourceRoot, entry.name, "RP2350");
|
|
1893
|
+
if (await pathExists(resolve(candidate, "pico-sdk", "pico_sdk_init.cmake"))) {
|
|
1894
|
+
return candidate;
|
|
1895
|
+
}
|
|
1896
|
+
}
|
|
1897
|
+
return undefined;
|
|
1898
|
+
}
|
|
589
1899
|
async function downloadToolchainArchive(sourceUrl, installRoot, expected) {
|
|
590
1900
|
const downloadsDir = join(installRoot, "cache", "downloads");
|
|
591
1901
|
await mkdir(downloadsDir, { recursive: true });
|
|
@@ -775,6 +2085,68 @@ async function runCommand(command, cwd) {
|
|
|
775
2085
|
});
|
|
776
2086
|
});
|
|
777
2087
|
}
|
|
2088
|
+
async function runCommandWithTimeout(command, cwd, timeoutMs) {
|
|
2089
|
+
return await new Promise((resolve) => {
|
|
2090
|
+
const child = spawn(command[0], command.slice(1), {
|
|
2091
|
+
cwd,
|
|
2092
|
+
env: process.env,
|
|
2093
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
2094
|
+
});
|
|
2095
|
+
let stdout = "";
|
|
2096
|
+
let stderr = "";
|
|
2097
|
+
let settled = false;
|
|
2098
|
+
const timer = setTimeout(() => {
|
|
2099
|
+
if (settled) {
|
|
2100
|
+
return;
|
|
2101
|
+
}
|
|
2102
|
+
stderr += `Command timed out after ${timeoutMs} ms.\n`;
|
|
2103
|
+
child.kill("SIGTERM");
|
|
2104
|
+
setTimeout(() => {
|
|
2105
|
+
if (!settled) {
|
|
2106
|
+
child.kill("SIGKILL");
|
|
2107
|
+
}
|
|
2108
|
+
}, 2_000).unref();
|
|
2109
|
+
}, timeoutMs);
|
|
2110
|
+
child.stdout.setEncoding("utf8");
|
|
2111
|
+
child.stderr.setEncoding("utf8");
|
|
2112
|
+
child.stdout.on("data", (chunk) => {
|
|
2113
|
+
stdout += chunk;
|
|
2114
|
+
});
|
|
2115
|
+
child.stderr.on("data", (chunk) => {
|
|
2116
|
+
stderr += chunk;
|
|
2117
|
+
});
|
|
2118
|
+
child.on("error", (error) => {
|
|
2119
|
+
if (settled) {
|
|
2120
|
+
return;
|
|
2121
|
+
}
|
|
2122
|
+
settled = true;
|
|
2123
|
+
clearTimeout(timer);
|
|
2124
|
+
stderr += `${error.message}\n`;
|
|
2125
|
+
resolve({
|
|
2126
|
+
command,
|
|
2127
|
+
cwd,
|
|
2128
|
+
exit_code: 127,
|
|
2129
|
+
stdout_tail: tailLines(stdout),
|
|
2130
|
+
stderr_tail: tailLines(stderr)
|
|
2131
|
+
});
|
|
2132
|
+
});
|
|
2133
|
+
child.on("close", (code) => {
|
|
2134
|
+
if (settled) {
|
|
2135
|
+
return;
|
|
2136
|
+
}
|
|
2137
|
+
settled = true;
|
|
2138
|
+
clearTimeout(timer);
|
|
2139
|
+
const timedOut = stderr.includes(`Command timed out after ${timeoutMs} ms.`);
|
|
2140
|
+
resolve({
|
|
2141
|
+
command,
|
|
2142
|
+
cwd,
|
|
2143
|
+
exit_code: timedOut ? 124 : code ?? 1,
|
|
2144
|
+
stdout_tail: tailLines(stdout),
|
|
2145
|
+
stderr_tail: tailLines(stderr)
|
|
2146
|
+
});
|
|
2147
|
+
});
|
|
2148
|
+
});
|
|
2149
|
+
}
|
|
778
2150
|
async function fileInfoFor(filePath) {
|
|
779
2151
|
const result = await runCommand(["file", filePath], dirname(filePath));
|
|
780
2152
|
return result.exit_code === 0 ? result.stdout_tail.join("\n") : undefined;
|