Skip to content

Commit

Permalink
Add support for PICO_BOARD_HEADER_DIRS as a semi-colon separated path…
Browse files Browse the repository at this point in the history
… list
  • Loading branch information
shalxmva committed Jan 6, 2025
1 parent 64b7396 commit 7ce1353
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions src/commands/switchBoard.mts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import {
cmakeGetPicoVar,
} from "../utils/cmakeUtil.mjs";
import { join } from "path";
import { resolve } from "path";
import { normalize } from "path";
import { compareLt } from "../utils/semverUtil.mjs";
import type UI from "../ui.mjs";
import { updateVSCodeStaticConfigs } from "../utils/vscodeConfigUtil.mjs";
Expand Down Expand Up @@ -49,12 +51,32 @@ export default class SwitchBoardCommand extends Command {
const ws = workspaceFolder.uri.fsPath;
const cMakeCachePath = join(ws, "build","CMakeCache.txt");

const picoBoardHeaderDirs = cmakeGetPicoVar(
let picoBoardHeaderDirs = cmakeGetPicoVar(
cMakeCachePath,
"PICO_BOARD_HEADER_DIRS");

if(picoBoardHeaderDirs){
boardHeaderDirList.push(picoBoardHeaderDirs);
if(picoBoardHeaderDirs.startsWith("'")){
const substrLen = picoBoardHeaderDirs.length-1;
picoBoardHeaderDirs = picoBoardHeaderDirs.substring(1,substrLen);
}

const picoBoardHeaderDirList = picoBoardHeaderDirs.split(";");
picoBoardHeaderDirList.forEach(
item => {
let boardPath = resolve(item);
const normalized = normalize(item);

//If path is not absolute, join workspace path
if(boardPath !== normalized){
boardPath = join(ws,normalized);
}

if(existsSync(boardPath)){
boardHeaderDirList.push(boardPath);
}
}
);
}
}

Expand Down

0 comments on commit 7ce1353

Please sign in to comment.