Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ For further context, see this discussion in the Zephyr project: https://github.c

## Additonal Zephyr Prerequisites

> On Raspberry Pi OS Trixie these come pre-installed.
> On Raspberry Pi OS Trixie all of those come pre-installed.

* **wget** - Required for sdk-ng to download toolchains. Install via your package manager (e.g., `brew install wget` on macOS or `sudo apt install wget` on Debian based Linux distributions).
* **wget** - Required for sdk-ng to download toolchains.

### Linux and macOS only

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,12 @@
"command": "raspberry-pi-pico.openUninstaller",
"title": "Open Uninstaller",
"category": "Raspberry Pi Pico"
},
{
"command": "raspberry-pi-pico.getGitPath",
"title": "Get git path",
"category": "Raspberry Pi Pico",
"enablement": "false"
}
],
"configuration": {
Expand Down
1 change: 1 addition & 0 deletions src/commands/cmdIds.mts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const GET_SVD_PATH = "getSVDPath";
export const GET_WEST_PATH = "getWestPath";
export const GET_ZEPHYR_WORKSPACE_PATH = "getZephyrWorkspacePath";
export const GET_ZEPHYR_SDK_PATH = "getZephyrSDKPath";
export const GET_GIT_PATH = "getGitPath";

export const IMPORT_PROJECT = "importProject";

Expand Down
23 changes: 22 additions & 1 deletion src/commands/getPaths.mts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import {
GET_CXX_COMPILER_PATH,
GET_ENV_PATH,
GET_GDB_PATH,
GET_GIT_PATH,
GET_OPENOCD_ROOT,
GET_PICOTOOL_PATH,
GET_PYTHON_PATH,
Expand All @@ -54,6 +55,7 @@ import {
ZEPHYR_PICO2_W,
ZEPHYR_PICO_W,
} from "../models/zephyrBoards.mjs";
import { ensureGit } from "../utils/gitUtil.mjs";

export class GetPythonPathCommand extends CommandWithResult<string> {
constructor() {
Expand Down Expand Up @@ -628,9 +630,28 @@ export class GetZephyrSDKPathCommand extends CommandWithResult<
await workspace.fs.stat(Uri.file(result));
const zephyrSdkVersion = await getZephyrSDKVersion();

return joinPosix(result, `zephyr-sdk-${zephyrSdkVersion}`);
return joinPosix(result, `zephyr-sdk-${zephyrSdkVersion ?? "unknown"}`);
} catch {
return undefined;
}
}
}

export class GetGitPathCommand extends CommandWithResult<string> {
constructor(private readonly _settings: Settings) {
super(GET_GIT_PATH);
}

async execute(): Promise<string> {
const gitPath = await ensureGit(this._settings, { returnPath: true });
if (
typeof gitPath !== "string" ||
gitPath.length === 0 ||
!gitPath.includes("/")
) {
return "";
}

return gitPath;
}
}
2 changes: 2 additions & 0 deletions src/extension.mts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import {
GetWestPathCommand,
GetZephyrWorkspacePathCommand,
GetZephyrSDKPathCommand,
GetGitPathCommand,
} from "./commands/getPaths.mjs";
import {
downloadAndInstallCmake,
Expand Down Expand Up @@ -184,6 +185,7 @@ export async function activate(context: ExtensionContext): Promise<void> {
new SbomTargetPathDebugCommand(),
new SbomTargetPathReleaseCommand(),
new OpenUninstallerCommand(context.extensionUri),
new GetGitPathCommand(settings),
];

// register all command handlers
Expand Down
1 change: 1 addition & 0 deletions src/utils/download.mts
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,7 @@ export async function downloadAndInstallSDK(
return false;
}

// TODO: option to parse already resolved path into this function
// TODO: this does take about 2s - may be reduced
const gitPath = await ensureGit(settings, { returnPath: true });
if (typeof gitPath !== "string" || gitPath.length === 0) {
Expand Down
33 changes: 20 additions & 13 deletions src/utils/projectGeneration/projectZephyr.mts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable max-len */
/* eslint-disable @typescript-eslint/naming-convention */
import { dirname, join } from "path";
import { join } from "path";
import { dirname as dirnamePosix } from "path/posix";
import Logger, { LoggerSource } from "../../logger.mjs";
import { unknownErrorToString } from "../errorHelper.mjs";
Expand All @@ -27,10 +27,12 @@ import {
import { homedir } from "os";
import {
GET_CHIP_UPPERCASE,
GET_GIT_PATH,
GET_OPENOCD_ROOT,
GET_PICOTOOL_PATH,
GET_TARGET,
GET_WEST_PATH,
GET_ZEPHYR_SDK_PATH,
GET_ZEPHYR_WORKSPACE_PATH,
} from "../../commands/cmdIds.mjs";
import { getZephyrSDKVersion, getZephyrVersion } from "../setupZephyr.mjs";
Expand Down Expand Up @@ -69,8 +71,7 @@ async function generateVSCodeConfig(
ninjaPath: string,
cmakePath: string,
te: TextEncoder = new TextEncoder(),
data: ZephyrSubmitMessageValue,
gitPath: string
data: ZephyrSubmitMessageValue
): Promise<boolean> {
const vsc = join(projectRoot, ".vscode");

Expand Down Expand Up @@ -164,7 +165,7 @@ async function generateVSCodeConfig(
toolchainPrefix: "arm-zephyr-eabi",
armToolchainPath:
// TODO: maybe just full get zephyr compiler path command
`\${command:${extensionName}.${GET_ZEPHYR_WORKSPACE_PATH}}/zephyr-sdk/arm-zephyr-eabi/bin`,
`\${command:${extensionName}.${GET_ZEPHYR_SDK_PATH}}/arm-zephyr-eabi/bin`,
// TODO: get chip dynamically maybe: chip: `\${command:${extensionName}.${GetChipCommand.id}}`,
// meaning only one cfg required
device: `\${command:${extensionName}.${GET_CHIP_UPPERCASE}}`,
Expand All @@ -179,6 +180,8 @@ async function generateVSCodeConfig(
openOCDLaunchCommands: ["adapter speed 5000"],
// TODO: add zephyr build support to support this.
rtos: "Zephyr",
// TODO: maybe get into launch target path command like in c/c++ projects
preLaunchTask: "Compile Project",
},
],
};
Expand All @@ -205,15 +208,13 @@ async function generateVSCodeConfig(
"terminal.integrated.env.windows": {
// remove gperf and dtc for now
// \${env:USERPROFILE}/.pico-sdk/dtc/${CURRENT_DTC_VERSION}/bin;\${env:USERPROFILE}/.pico-sdk/gperf/${CURRENT_GPERF_VERSION}
Path: `${dirname(
gitPath
)};\${env:USERPROFILE}/.pico-sdk/7zip;\${env:Path};`,
Path: "${env:USERPROFILE}/.pico-sdk/7zip;${env:Path};",
},
"terminal.integrated.env.osx": {
PATH: `${dirname(gitPath)}:\${env:PATH}:`,
PATH: "${env:PATH}:",
},
"terminal.integrated.env.linux": {
PATH: `${dirname(gitPath)}:\${env:PATH}:`,
PATH: "${env:PATH}:",
},
"raspberry-pi-pico.cmakeAutoConfigure": true,
"raspberry-pi-pico.useCmakeTools": false,
Expand Down Expand Up @@ -331,9 +332,15 @@ async function generateVSCodeConfig(
problemMatcher: "$gcc",
options: {
cwd: `\${command:${extensionName}.${GET_ZEPHYR_WORKSPACE_PATH}}`,
env: {
PATH: `\${command:${extensionName}.${GET_GIT_PATH}}:\${env:PATH}:`,
},
},
windows: {
options: {
env: {
Path: `\${command:${extensionName}.${GET_GIT_PATH}};\${env:Path};`,
},
shell: {
executable: "cmd.exe",
args: ["/d", "/c"],
Expand Down Expand Up @@ -365,6 +372,8 @@ async function generateVSCodeConfig(
panel: "dedicated",
},
problemMatcher: [],
dependsOrder: "sequence",
dependsOn: "Compile Project",
},
],
};
Expand Down Expand Up @@ -1170,8 +1179,7 @@ export async function generateZephyrProject(
latestVb: [string, VersionBundle],
ninjaPath: string,
cmakePath: string,
data: ZephyrSubmitMessageValue,
gitPath: string
data: ZephyrSubmitMessageValue
): Promise<boolean> {
const projectRoot = join(projectFolder, projectName);

Expand Down Expand Up @@ -1245,8 +1253,7 @@ export async function generateZephyrProject(
ninjaPath,
cmakePath,
te,
data,
gitPath
data
);
if (!result) {
Logger.debug(
Expand Down
Loading
Loading