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

[VSC-1409] Add check for missing compile_commands.json in IDF projects #1271

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

radurentea
Copy link
Collaborator

Description

This pull request adds a new feature to improve the user experience when working with ESP-IDF projects in VS Code, particularly when using the Microsoft C/C++ extension.

Key changes:

  1. Implements a check for the existence of the compile_commands.json file when opening an ESP-IDF project.
  2. If the file is missing, displays a notification to the user with an option to generate it.

For users using the Microsoft's C/C++ compile_commands.json file is crucial for proper IntelliSense functionality in ESP-IDF projects.

JIRA https://jira.espressif.com:8443/browse/VSC-1409

Type of change

  • New feature (non-breaking change which adds functionality)

Steps to test this pull request

  1. Open an ESP-IDF project that doesn't have a compile_commands.json file in its build directory.
  2. Verify that a notification appears, informing about the missing file and offering to generate it.
  3. Click the "Generate compile_commands.json" button and confirm that it triggers the espIdf.idfReconfigureTask command that generates the compile_command.json file in build folder of the project.

How has this been tested?

As described above

Test Configuration:

  • ESP-IDF Version: 5.3
  • OS (Windows,Linux and macOS): Windows 11

Checklist

  • PR Self Reviewed
  • Applied Code formatting
  • Added Documentation
  • Added Unit Test
  • Verified on all platforms - Windows,Linux and macOS

@radurentea radurentea self-assigned this Aug 5, 2024
Copy link

github-actions bot commented Aug 5, 2024

Download the artifacts for this pull request:
You can test these changes by installing this VSIX by click menu View -> Command Palette..., type Install from VSIX and then select downloaded esp-idf-extension.vsix file to install the extension.

Copy link
Collaborator

@brianignacio5 brianignacio5 left a comment

Choose a reason for hiding this comment

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

Few changes I consider would improve this PR

src/logger/utils.ts Outdated Show resolved Hide resolved
src/extension.ts Outdated Show resolved Hide resolved
src/extension.ts Outdated Show resolved Hide resolved
src/extension.ts Outdated Show resolved Hide resolved
@radurentea
Copy link
Collaborator Author

Hi @brianignacio5, thank you for the review!
I've made all the modifications, can you please take another look?

Copy link
Collaborator

@brianignacio5 brianignacio5 left a comment

Choose a reason for hiding this comment

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

LGTM

@radurentea
Copy link
Collaborator Author

Hi @AndriiFilippov, PTAL

Copy link

Pull request has been marked as stale since there are no activities, and this will be closed in 5 days if there are no further activities

@github-actions github-actions bot added the stale Stale PR or Issue label Aug 30, 2024
@brianignacio5 brianignacio5 removed the stale Stale PR or Issue label Aug 30, 2024
@radurentea
Copy link
Collaborator Author

Hi @Fabricio-ESP, PTAL

Copy link

Pull request has been marked as stale since there are no activities, and this will be closed in 5 days if there are no further activities

@github-actions github-actions bot added the stale Stale PR or Issue label Sep 26, 2024
@brianignacio5 brianignacio5 added this to the 1.9.0 milestone Sep 26, 2024
@radurentea radurentea added ongoing Ongoing Issue or PR, this label will be used for issue or PR which is to be excluded by stale bot and removed stale Stale PR or Issue labels Sep 30, 2024
@radurentea radurentea force-pushed the enhance/opening-projects-compile-error-solution branch from 5de3252 to f96d071 Compare October 1, 2024 07:45
@Fabricio-ESP
Copy link
Collaborator

Fabricio-ESP commented Oct 1, 2024

The extension is properly detecting the missing file in the builds folder and running the reconfigure command. Tested on Windows and Linux.

Side effect is that when opening a new project (from a example) the build folder does not exist yet, and the error notification will be triggered. Running the reconfigure command will generate the build for the ESP32 default target. If the user wants to change the target the build folder will need to recreated.

If the user has set multiple configuration profiles and the build folder have other names than "build" the extension is showing the error that the compile_commands.json is missing, but they are properly saved on each build folder, so there is something there to detect the file on this scenario.

src/extension.ts Show resolved Hide resolved
@Fabricio-ESP Fabricio-ESP changed the title Add check for missing compile_commands.json in IDF projects [VSC-1409] Add check for missing compile_commands.json in IDF projects Oct 22, 2024
@radurentea radurentea force-pushed the enhance/opening-projects-compile-error-solution branch from a85d68b to c8a4e82 Compare October 25, 2024 07:12
Copy link
Collaborator

@brianignacio5 brianignacio5 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator

@Fabricio-ESP Fabricio-ESP left a comment

Choose a reason for hiding this comment

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

Tested on Windows, WSL and Linux.
Reconfigure command working as expected.

- Removed helper function from logger/utils
- Moved code in already existing event listener
- Wrapped event listener with context.subscriptions.push()
- Localized messages displayed to user
We don't need to use "=" in the commands anymore
@radurentea radurentea force-pushed the enhance/opening-projects-compile-error-solution branch from bf43756 to 0fa8e6c Compare October 28, 2024 13:23
Copy link
Collaborator

@brianignacio5 brianignacio5 left a comment

Choose a reason for hiding this comment

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

Rebase issues.

@@ -129,12 +127,6 @@ export class BuildTask {
"-DPYTHON_DEPS_CHECKED=1",
"-DESP_PLATFORM=1",
];
} else if (useEqualSign) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

The rebase is removing changes from #1266 which are implemented in master.

Please update.

reconfigureArgs.push(`-B=${this.buildDirPath}`);
} else {
reconfigureArgs.push("-B", this.buildDirPath);
reconfigureArgs.splice(buildPathArgsIndex, 2);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same here removing changes in master from #1266

@@ -391,77 +392,81 @@ export async function activate(context: vscode.ExtensionContext) {
binTimestampEventFunc
);
context.subscriptions.push(buildWatcherCreateDisposable);

Copy link
Collaborator

Choose a reason for hiding this comment

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

Changes from 394 to 469 are not related to the PR proposal solution. While I think is good to add this to context subscription disposable array, the amount of changes are not necessary.

Please update to remove these changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ongoing Ongoing Issue or PR, this label will be used for issue or PR which is to be excluded by stale bot
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants