Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cl.exe being excluded for .c files and c/cpp caching. #9544

Merged
merged 2 commits into from
Jul 6, 2022

Conversation

sean-mcmanus
Copy link
Collaborator

  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 elahehrashedi, Colengms and a team 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
Collaborator 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.

@@ -449,8 +451,44 @@ export class DebugConfigurationProvider implements vscode.DebugConfigurationProv
}

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
Collaborator 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
Collaborator 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
Collaborator 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.

3 participants