Skip to content

Commit

Permalink
Fixing bugs and updating functionality
Browse files Browse the repository at this point in the history
- Autodetecting runners
- Fixing path generation for Windows

Signed-off-by Jared Wolff <hello@jaredwolff.com>
  • Loading branch information
jaredwolff committed Jul 31, 2024
1 parent 736f49b commit 8772750
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 6 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
34 changes: 29 additions & 5 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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..",
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 8772750

Please sign in to comment.