Skip to content

Commit 50ed038

Browse files
committed
Add versioned zephyr sdk folders back
Signed-off-by: paulober <[email protected]>
1 parent 5a412f8 commit 50ed038

File tree

5 files changed

+50
-6
lines changed

5 files changed

+50
-6
lines changed

package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,12 @@
267267
"title": "Get path of the project release SBOM (rust only)",
268268
"category": "Raspberry Pi Pico",
269269
"enablement": "false"
270+
},
271+
{
272+
"command": "raspberry-pi-pico.getZephyrSDKPath",
273+
"title": "Get Zephyr SDK path",
274+
"category": "Raspberry Pi Pico",
275+
"enablement": "false"
270276
}
271277
],
272278
"configuration": {

src/commands/cmdIds.mts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export const GET_OPENOCD_ROOT = "getOpenOCDRoot";
2020
export const GET_SVD_PATH = "getSVDPath";
2121
export const GET_WEST_PATH = "getWestPath";
2222
export const GET_ZEPHYR_WORKSPACE_PATH = "getZephyrWorkspacePath";
23+
export const GET_ZEPHYR_SDK_PATH = "getZephyrSDKPath";
2324

2425
export const IMPORT_PROJECT = "importProject";
2526

src/commands/getPaths.mts

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { CommandWithResult } from "./command.mjs";
2-
import { commands, type Uri, window, workspace } from "vscode";
2+
import { commands, FileType, Uri, window, workspace } from "vscode";
33
import {
44
getPythonPath,
55
getPath,
@@ -41,6 +41,7 @@ import {
4141
GET_SVD_PATH,
4242
GET_TARGET,
4343
GET_WEST_PATH,
44+
GET_ZEPHYR_SDK_PATH,
4445
GET_ZEPHYR_WORKSPACE_PATH,
4546
} from "./cmdIds.mjs";
4647
import { getBoardFromZephyrProject } from "../utils/setupZephyr.mjs";
@@ -50,6 +51,7 @@ import {
5051
ZEPHYR_PICO2_W,
5152
ZEPHYR_PICO_W,
5253
} from "../models/zephyrBoards.mjs";
54+
import { compare } from "../utils/semverUtil.mjs";
5355

5456
export class GetPythonPathCommand extends CommandWithResult<string> {
5557
constructor() {
@@ -610,3 +612,37 @@ export class GetZephyrWorkspacePathCommand extends CommandWithResult<
610612
return result;
611613
}
612614
}
615+
616+
export class GetZephyrSDKPathCommand extends CommandWithResult<
617+
string | undefined
618+
> {
619+
constructor() {
620+
super(GET_ZEPHYR_SDK_PATH);
621+
}
622+
623+
async execute(): Promise<string | undefined> {
624+
const result = buildZephyrWorkspacePath();
625+
626+
if (result === null || !result) {
627+
return undefined;
628+
}
629+
const workspaceUri = Uri.file(result);
630+
631+
try {
632+
await workspace.fs.stat(workspaceUri);
633+
const contents = await workspace.fs.readDirectory(workspaceUri);
634+
const sdksDirectories = contents
635+
.filter(
636+
entry =>
637+
entry[1] === FileType.Directory &&
638+
entry[0].startsWith("zephyr-sdk-")
639+
)
640+
.map(([name]) => name.replace(/^zephyr-sdk-/, ""))
641+
.sort((a, b) => compare(b, a)); // sort descending
642+
643+
return joinPosix(result, `zephyr-sdk-${sdksDirectories[0]}`);
644+
} catch {
645+
return undefined;
646+
}
647+
}
648+
}

src/extension.mts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ import {
5454
GetSVDPathCommand,
5555
GetWestPathCommand,
5656
GetZephyrWorkspacePathCommand,
57+
GetZephyrSDKPathCommand,
5758
} from "./commands/getPaths.mjs";
5859
import {
5960
downloadAndInstallCmake,
@@ -158,6 +159,7 @@ export async function activate(context: ExtensionContext): Promise<void> {
158159
new GetSVDPathCommand(context.extensionUri),
159160
new GetWestPathCommand(),
160161
new GetZephyrWorkspacePathCommand(),
162+
new GetZephyrSDKPathCommand(),
161163
new CompileProjectCommand(),
162164
new RunProjectCommand(),
163165
new FlashProjectSWDCommand(),

src/utils/setupZephyr.mts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,6 @@ interface ZephyrSetupOutputs {
6262
const homeDirectory: string = homedir();
6363

6464
const zephyrManifestContent: string = `
65-
# Copyright (c) 2021 Nordic Semiconductor ASA
66-
# SPDX-License-Identifier: Apache-2.0
6765
manifest:
6866
self:
6967
west-commands: scripts/west-commands.yml
@@ -1240,7 +1238,7 @@ export async function setupZephyr(
12401238
cancellable: false,
12411239
},
12421240
async progress2 => {
1243-
// was -b ${zephyrWorkspaceDirectory} which results in zephyr-sdk-<version> in it
1241+
// was which results in zephyr-sdk-<version> in it
12441242
let westInstallSDKCommand: string = `"${westExe}" sdk install `;
12451243

12461244
const githubPat = Settings.getInstance()?.getString(
@@ -1254,9 +1252,10 @@ export async function setupZephyr(
12541252
);
12551253
westInstallSDKCommand += `--personal-access-token ${githubPat} `;
12561254
}
1255+
//`-d "${zephyrWorkspaceDirectory}/zephyr-sdk"`;
12571256
westInstallSDKCommand +=
1258-
"-t arm-zephyr-eabi " +
1259-
`-d "${zephyrWorkspaceDirectory}/zephyr-sdk"`;
1257+
// -b ${} results in zephyr-sdk-<version> folder
1258+
"-t arm-zephyr-eabi -b ${zephyrWorkspaceDirectory}";
12601259

12611260
result = await _runCommand(westInstallSDKCommand, {
12621261
cwd: zephyrWorkspaceDirectory,

0 commit comments

Comments
 (0)