diff --git a/CHANGELOG.md b/CHANGELOG.md index a27c6df..aef43b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ All notable changes to the "zephyr-tools" extension will be documented in this file. +### [0.3.2] + +Changed: + +- Autodetecting available runners +- Fixing path generation in Windows + ### [0.3.1] Changed: diff --git a/package.json b/package.json index c8cbbf3..8886c7a 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "zephyr-tools", "displayName": "Circuit Dojo Zephyr SDK Tools", "description": "Used for building your Zephyr projects.", - "version": "0.3.1", + "version": "0.3.2", "license": "Apache-2.0", "publisher": "circuitdojo", "icon": "img/bulb.png", diff --git a/src/extension.ts b/src/extension.ts index 2f4edbb..1f295ea 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -1447,7 +1447,10 @@ async function flash(config: GlobalConfig, project: ProjectConfig) { // Tasks let taskName = "Zephyr Tools: Flash"; - let cmd = `west flash -d build/${project.board}/`; + + // Generate universal build path that works on windows & *nix + let buildPath = path.join("build", project.board?.split("/")[0] ?? ""); + let cmd = `west flash -d ${buildPath}`; // Add runner if it exists if (project.runner) { @@ -1779,12 +1782,30 @@ async function changeRunner(config: GlobalConfig, context: vscode.ExtensionConte rootPath = rootPaths[0].uri; } - console.log("Roto path: " + rootPath.fsPath); + let runners: string[] = ["default"]; + + // Get runners from $rootPath/zephyr/scripts/west_commands/runners + const runnersDir = path.join(rootPath.fsPath, "zephyr", "scripts", "west_commands", "runners"); + + try { + const files = fs.readdirSync(runnersDir); + const r = files.filter(file => file.endsWith(".py") && file !== "__init__.py").map(file => file.replace(".py", "")); + console.log(r); + + runners.push(...r); + vscode.window.showInformationMessage(`Runners: ${runners.join(", ")}`); + } catch (err) { + if (err instanceof Error) { + vscode.window.showErrorMessage(`Error reading runners directory: ${err.message}`); + } else { + vscode.window.showErrorMessage("An unknown error occurred while reading the runners directory."); + } + } - // Get runners - let runners: string[] = ["default", "jlink", "nrfjprog", "openocd", "pyocd", "qemu", "stlink"]; let args = ""; + console.log("Runners: " + runners); + // Prompt which board to use const result = await vscode.window.showQuickPick(runners, { placeHolder: "Pick your runner..", @@ -1908,8 +1929,11 @@ async function build( // Tasks let taskName = "Zephyr Tools: Build"; + // Generate universal build path that works on windows & *nix + let buildPath = path.join("build", project.board?.split("/")[0] ?? ""); + // Enable python env - let cmd = `west build -b ${project.board}${pristine ? " -p" : ""} -d build/${project.board}/${ + let cmd = `west build -b ${project.board}${pristine ? " -p" : ""} -d ${buildPath}${ project.sysbuild ? " --sysbuild" : "" }`; let exec = new vscode.ShellExecution(cmd, options);