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-1537] use IDF_TARGET in customExtraVars if no sdkconfig #1385

Merged
merged 2 commits into from
Jan 6, 2025

Conversation

brianignacio5
Copy link
Collaborator

@brianignacio5 brianignacio5 commented Dec 26, 2024

Description

To find the current IDF_TARGET the extension reads the sdkconfig in v1.9.0 but before there was a idf.adapterTargetName configuration setting which was used to resolve IDF_TARGET. The previous logic would fail if the current project is configure for a target (say esp32) but the configuration setting is set to (say esp32c3).

Reading from sdkconfig seems like a better approach, but what happens when you want to define a IDF_TARGET but no sdkconfig exists ? For this case we still need to persist this somehow. Now we would use idf.customExtraVars configuration setting and add IDF_TARGET when running the ESP-IDF: Set Espressif Device Target command. The extension will use this value when sdkconfig IDF_TARGET value doesn't exist.

Also add idf.customExtraVars to idfConfiguration.ts readParameter. When a user has a setting with value ${env:VARNAME} now it will also use idf.customExtraVars to resolve it. For example "idf.svdFilePath": "${workspaceFolder}/${env:IDF_TARGET}.svd"

Fixes #1363
Fixes #1386

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Steps to test this pull request

  1. Run the ESP-IDF: Set Espressif Device Target on a ESP-IDF project. This will create an sdkconfig file and build project.
  2. Delete the build directory and sdkconfig file.
  3. Run the ESP-IDF: Build your project command. The project should build with the target defined before instead of previously default esp32.
  • Expected behaviour:

The IDF_TARGET that was set in 1 is still used when sdkconfig has been deleted for other extension commands like ESP-IDF: Build your project.

  • Expected output:

The IDF_TARGET that was set in 1 is still used when sdkconfig has been deleted for other extension commands like ESP-IDF: Build your project.

How has this been tested?

Manual test by following steps above.

Test Configuration:

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

Checklist

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

@brianignacio5 brianignacio5 added this to the v1.9.1 milestone Dec 26, 2024
@brianignacio5 brianignacio5 self-assigned this Dec 26, 2024
Copy link

github-actions bot commented Dec 26, 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

@radurentea radurentea left a comment

Choose a reason for hiding this comment

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

LGTM

@Fabricio-ESP Fabricio-ESP changed the title use IDF_TARGET in customExtraVars if no sdkconfig [VSC-1537] use IDF_TARGET in customExtraVars if no sdkconfig Jan 3, 2025
@Fabricio-ESP
Copy link
Collaborator

Hi Brian,
What are the other 2 parameters added to the customExtraVars? Part of this solution, or anticipation for other changes?

"idf.customExtraVars": {
    "OPENOCD_SCRIPTS": "/home/virtual/esp/v5.0.7/Tools/tools/openocd-esp32/v0.12.0-esp32-20240318/openocd-esp32/share/openocd/scripts",
    "ESP_ROM_ELF_DIR": "/home/virtual/esp/v5.0.7/Tools/tools/esp-rom-elfs/20220823/",
    "IDF_TARGET": "esp32c3"

}

Tested on Windows and Ubuntu, it is working. The scenario with deleted sdkconfig was not considered with the previous change.

@brianignacio5 brianignacio5 merged commit d2ae042 into master Jan 6, 2025
6 checks passed
@brianignacio5
Copy link
Collaborator Author

Hi Brian, What are the other 2 parameters added to the customExtraVars? Part of this solution, or anticipation for other changes?

"idf.customExtraVars": {
    "OPENOCD_SCRIPTS": "/home/virtual/esp/v5.0.7/Tools/tools/openocd-esp32/v0.12.0-esp32-20240318/openocd-esp32/share/openocd/scripts",
    "ESP_ROM_ELF_DIR": "/home/virtual/esp/v5.0.7/Tools/tools/esp-rom-elfs/20220823/",
    "IDF_TARGET": "esp32c3"

}

Tested on Windows and Ubuntu, it is working. The scenario with deleted sdkconfig was not considered with the previous change.

This values were being set before this PR when configuring the extension. These env variables are generated from $IDF_PATH/tools/tools.json and also added in env vars in IDF when running $IDF_PATH/export.sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants