Skip to content

Commit ddb8cda

Browse files
PILIX123pierreluc.robitaille
andauthored
Potential fix for hanging build (#4479)
* Potential fix for build hanging * Add entry to CHANGELOG --------- Co-authored-by: pierreluc.robitaille <[email protected]>
1 parent 94ec16e commit ddb8cda

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Bug Fixes:
2929
- Fix evaluation of conditions in presets. [#4425](https://github.com/microsoft/vscode-cmake-tools/issues/4425)
3030
- Fix ENOENT error at vscode startup on some circumstances [#2855](https://github.com/microsoft/vscode-cmake-tools/issues/2855) Contributed by STMicroelectronics
3131
- Fix repeat execution option in test presets [#4443](https://github.com/microsoft/vscode-cmake-tools/issues/4443)
32+
- Fix bug that makes some build hang [#4424](https://github.com/microsoft/vscode-cmake-tools/issues/4424) and [#4465](https://github.com/microsoft/vscode-cmake-tools/issues/4465)
3233

3334
## 1.20.53
3435

src/cmakeTaskProvider.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,13 @@ export class CMakeTaskProvider implements vscode.TaskProvider {
257257
// Fetch all CMake task from `tasks.json` files.
258258
const allTasks: vscode.Task[] = await vscode.tasks.fetchTasks({ type: CMakeTaskProvider.CMakeScriptType });
259259

260+
// Fetch CMake task from from task provider
261+
const workspaceFolderObj: vscode.WorkspaceFolder | undefined = vscode.workspace.getWorkspaceFolder(vscode.Uri.file(workspaceFolder));
262+
if (!workspaceFolderObj) {
263+
log.error(localize("workspace.folder.not.found", 'Workspace folder not found.'));
264+
return undefined;
265+
}
266+
260267
const tasks: (CMakeTask | undefined)[] = await Promise.all(allTasks.map(async (task: any) => {
261268
if (!task.definition.label || !task.group || (task.group && task.group.id !== vscode.TaskGroup.Build.id)) {
262269
return undefined;
@@ -281,7 +288,7 @@ export class CMakeTaskProvider implements vscode.TaskProvider {
281288
options: task.definition.options
282289
};
283290

284-
const buildTask: CMakeTask = new vscode.Task(definition, vscode.TaskScope.Workspace, task.definition.label, CMakeTaskProvider.CMakeSourceStr);
291+
const buildTask: CMakeTask = new vscode.Task(definition, workspaceFolderObj, task.definition.label, CMakeTaskProvider.CMakeSourceStr);
285292
buildTask.detail = task.detail;
286293
if (task.group.isDefault) {
287294
buildTask.isDefault = true;
@@ -331,12 +338,6 @@ export class CMakeTaskProvider implements vscode.TaskProvider {
331338
}
332339
}
333340

334-
// Fetch CMake task from from task provider
335-
const workspaceFolderObj: vscode.WorkspaceFolder | undefined = vscode.workspace.getWorkspaceFolder(vscode.Uri.file(workspaceFolder));
336-
if (!workspaceFolderObj) {
337-
log.error(localize("workspace.folder.not.found", 'Workspace folder not found.'));
338-
return undefined;
339-
}
340341
matchingTargetTasks.push(await CMakeTaskProvider.provideTask(CommandType.build, workspaceFolderObj, undefined, targets, presetName));
341342
const items: TaskMenu[] = matchingTargetTasks.map<TaskMenu>(task => ({ label: task.name, task: task, description: task.detail }));
342343
// Ask the user to pick a task.

0 commit comments

Comments
 (0)