Skip to content

Conversation

@sean-mcmanus
Copy link
Contributor

  1. Fix cl.exe build tasks not showing for .c files.
  2. Fix .c build tasks being cached for .cpp files (and vice versa).

I hit these bugs while investigating #9535 .

@sean-mcmanus sean-mcmanus added this to the 1.11.1 milestone Jul 6, 2022
@sean-mcmanus sean-mcmanus requested review from a team, Colengms and elahehrashedi July 6, 2022 01:51
const compiler_condition: (info: configs.KnownCompiler) => boolean = info =>
(
// Filter out c compilers for cpp files and vice versa, except for cl.exe, which handles both.
path.basename(info.path) === "cl.exe" ||
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check fixes cl.exe not appearing for .c files.

private async loadDetectedTasks(): Promise<void> {
if (!DebugConfigurationProvider.detectedBuildTasks || DebugConfigurationProvider.detectedBuildTasks.length === 0) {
DebugConfigurationProvider.detectedBuildTasks = await cppBuildTaskProvider.getTasks(true);
const editor: vscode.TextEditor | undefined = vscode.window.activeTextEditor;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These checks are taken from the start of getTask -- I didn't see a good way to refactor it so I didn't bother.

return;
}

if (fileIsCpp) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixes the same detectedBuildTasks cache being used for c and cpp.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One way is not to keep a cache and always load the tasks. It may help when a new compiler is being installed in the middle of a session. I added this cache so that we don't keep getting the tasks over and over again, but now I am not sure that it was the right decision. Which way you think is better? to keep the cache or to always load the tasks?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know. Using caches seems fine to me -- I see the cache get hit 2 times for every debug invocation and it's possible the list of compilers could be big, so it's hard to say how long that could potentially add to debug startup time. Installing a new compiler in the middle of a sessions seems pretty rare, and a user who did that and didn't see the new compiler added would probably guess they might need to reload VS Code.

@sean-mcmanus sean-mcmanus merged commit e172440 into main Jul 6, 2022
@sean-mcmanus sean-mcmanus deleted the seanmcm/fixBuildTaskIssues branch July 6, 2022 22:23
@github-actions github-actions bot locked and limited conversation to collaborators Aug 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants