Skip to content

Commit 055fba3

Browse files
committed
Experimental build selector fixes
1 parent 3ca14b2 commit 055fba3

File tree

4 files changed

+62
-10
lines changed

4 files changed

+62
-10
lines changed

src/extension.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,10 @@ export async function activate(context: vscode.ExtensionContext) {
586586
vscode.commands.registerCommand("zephyr-ide.add-build", async () => {
587587
if (wsConfig.activeSetupState && wsConfig.activeSetupState.westUpdated) {
588588
let result = await project.addBuild(wsConfig, context);
589+
console.log("Updating web view");
590+
console.log(result);
589591
vscode.commands.executeCommand("zephyr-ide.update-web-view");
592+
console.log("returning from adding build");
590593
return result;
591594
} else {
592595
vscode.window.showErrorMessage("Run `Zephyr IDE: West Update` first.");

src/project_utilities/build_selector.ts

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,24 +75,43 @@ async function getBoardlistWest(setupState: SetupState, folder: vscode.Uri | und
7575
}
7676

7777
let prevError: any;
78-
if (setupState.zephyrVersion === undefined) { return; }
78+
console.log("zephyrVersion");
79+
console.log(setupState.zephyrVersion);
80+
81+
if (setupState.zephyrVersion === undefined) {
82+
console.log("Returning because zephyrVersion is not set");
83+
return;
84+
}
7985
let res;
8086
let has_qualifiers = false;
8187
let has_revisions = false;
88+
console.log("Getting board list");
89+
8290
if (isVersionNumberGreater(setupState.zephyrVersion, 4, 1, 0)) {
91+
92+
console.log("Getting board list1");
8393
res = await executeShellCommandInPythonEnv("west boards -f '{name};{dir};{qualifiers};{revisions};{revision_default}'" + boardRootString, setupState.setupPath, setupState, false);
8494
has_qualifiers = true;
8595
has_revisions = true;
8696
} else if (isVersionNumberGreaterEqual(setupState.zephyrVersion, 3, 7, 0)) {
97+
console.log("Getting board list2");
8798
res = await executeShellCommandInPythonEnv("west boards -f '{name};{dir};{qualifiers}'" + boardRootString, setupState.setupPath, setupState, false);
8899
has_qualifiers = true;
89100
} else {
101+
102+
console.log("Getting board list3");
90103
res = await executeShellCommandInPythonEnv("west boards -f '{name};{dir}'" + boardRootString, setupState.setupPath, setupState, false);
91104
}
105+
console.log("Got board list");
106+
107+
console.log(res);
108+
console.log(res.stdout);
92109

93110
if (!res.stdout) {
94-
output.append(prevError);
95-
output.append(res.stderr);
111+
console.log("error");
112+
113+
console.log(prevError);
114+
console.log(res.stderr);
96115
vscode.window.showErrorMessage("Failed to run west boards command. See Zephyr IDE Output for error message");
97116
return;
98117
}
@@ -154,8 +173,8 @@ export async function pickBoard(setupState: SetupState, rootPath: string) {
154173
boardDirectories.push("Select Other Folder");
155174
const boardDirectoriesQpItems: QuickPickItem[] = boardDirectories.map(label => ({ label }));
156175

157-
const title = "Board Picker";
158-
176+
const title = "Board Dir Picker";
177+
console.log("picking directories");
159178
let pickPromise = showQuickPick({
160179
title,
161180
step: 1,
@@ -173,9 +192,11 @@ export async function pickBoard(setupState: SetupState, rootPath: string) {
173192
if (!pick) {
174193
return;
175194
};
195+
console.log("Did not");
176196

177197
let relBoardDir: string | undefined = path.relative(rootPath, (pick.label));
178198
if (pick.label === "Select Other Folder") {
199+
console.log("selecting other folder");
179200
const boarddir = await vscode.window.showOpenDialog({
180201
canSelectFiles: false,
181202
canSelectFolders: true,
@@ -192,13 +213,19 @@ export async function pickBoard(setupState: SetupState, rootPath: string) {
192213
}
193214

194215
let boardList;
216+
console.log("getting board list");
217+
console.log(relBoardDir);
218+
195219
if (relBoardDir) {
196220
boardList = await getBoardlistWest(setupState, vscode.Uri.file(path.join(rootPath, relBoardDir)));
197221
} else {
198222
boardList = await getBoardlistWest(setupState, undefined);
199223
}
224+
console.log("finished getting boar lsit");
200225

201226
if (!boardList) {
227+
console.log("empty board list");
228+
202229
return;
203230
}
204231

@@ -213,12 +240,17 @@ export async function pickBoard(setupState: SetupState, rootPath: string) {
213240
activeItem: undefined
214241
}).catch((error) => {
215242
console.error(error);
243+
244+
console.log("Pick Board error");
216245
return undefined;
217246
});
218247
pick = (await pickPromise as QuickPickItem);
219248
if (!pick) {
249+
console.log("Pick error");
250+
220251
return;
221252
};
253+
console.log(pick);
222254

223255
let pick_data = (pick as BoardItem);
224256

@@ -256,17 +288,20 @@ export async function pickBoard(setupState: SetupState, rootPath: string) {
256288
activeItem: revisionQPItems[revisionIndex]
257289
}).catch((error) => {
258290
console.error(error);
291+
292+
console.log("pick rev error");
259293
return undefined;
260294
});
261295
let pick = (await pickPromise as QuickPickItem);
262296
if (!pick) {
297+
298+
console.log("pick error");
263299
return;
264300
};
265301
revision = pick.label;
266302
}
267303

268-
269-
304+
console.log("returning board config");
270305
let boardConfig = {
271306
board: board,
272307
relBoardDir: relBoardDir,
@@ -280,6 +315,7 @@ export async function buildSelector(context: ExtensionContext, setupState: Setup
280315
const title = 'Add Build Configuration';
281316

282317
async function pickBoardStep(input: MultiStepInput, state: Partial<BuildConfig>) {
318+
console.log("picking board");
283319
let boardData = await pickBoard(setupState, rootPath);
284320
if (boardData) {
285321
state.relBoardDir = boardData.relBoardDir;

src/project_utilities/project.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,9 +505,13 @@ export async function addProject(wsConfig: WorkspaceConfig, context: vscode.Exte
505505

506506
export async function addBuildToProject(wsConfig: WorkspaceConfig, context: vscode.ExtensionContext, projectName: string) {
507507

508+
console.log(`Startign build1`);
508509
if (wsConfig.activeSetupState) {
509510

511+
console.log(`Startign build2`);
510512
let result = await buildSelector(context, wsConfig.activeSetupState, wsConfig.rootPath);
513+
514+
console.log(`build selector returned`);
511515
if (result && result.name !== undefined) {
512516
result.runnerConfigs = {};
513517
if (wsConfig.projects[projectName].buildConfigs[result.name]) {
@@ -517,7 +521,7 @@ export async function addBuildToProject(wsConfig: WorkspaceConfig, context: vsco
517521
return;
518522
}
519523
}
520-
524+
console.log(`Creating Build Configuration: ${result.name}`);
521525
vscode.window.showInformationMessage(`Creating Build Configuration: ${result.name}`);
522526
wsConfig.projects[projectName].buildConfigs[result.name] = result;
523527
wsConfig.projectStates[projectName].buildStates[result.name] = { runnerStates: {}, viewOpen: true };

src/test/workflow-integration.test.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ suite("Workflow Integration Test Suite", () => {
234234
if (mockQuickPick._onDidAcceptCallback) {
235235
mockQuickPick._onDidAcceptCallback();
236236
}
237-
}, 8000);
237+
}, 30000);
238238
},
239239
onDidTriggerButton: () => ({ dispose: () => { } }),
240240
onDidChangeSelection: (callback: any) => {
@@ -292,7 +292,7 @@ suite("Workflow Integration Test Suite", () => {
292292
if (mockInputBox._onDidAcceptCallback) {
293293
mockInputBox._onDidAcceptCallback();
294294
}
295-
}, 8000);
295+
}, 30000);
296296
},
297297
onDidAccept: (callback: any) => {
298298
mockInputBox._onDidAcceptCallback = callback;
@@ -445,6 +445,15 @@ suite("Workflow Integration Test Suite", () => {
445445
globalQuickPickCallCount = 0;
446446
globalInputBoxCallCount = 0;
447447
currentStep = "build-config";
448+
449+
// Check if west is available before attempting build config
450+
const ext = vscode.extensions.getExtension("mylonics.zephyr-ide");
451+
const wsConfig = ext?.exports?.getWorkspaceConfig();
452+
if (!wsConfig?.initialSetupComplete) {
453+
console.log("⚠️ Setup not complete, retrying in 10 seconds...");
454+
await new Promise((resolve) => setTimeout(resolve, 10000));
455+
}
456+
448457
result = await vscode.commands.executeCommand("zephyr-ide.add-build");
449458
assert.ok(result, "Build configuration should succeed");
450459

0 commit comments

Comments
 (0)