Skip to content

Conversation

@brianignacio5
Copy link
Collaborator

@brianignacio5 brianignacio5 commented Sep 16, 2025

Make sure esp-clang and openocd include esp-clang and openocd-esp32 in their resulting binary path.

Update clang query driver to **

Fix compile-commands-dir using the wrong workspace when using the new project wizard.

Make sure OPENOCD_SCRIPTS matches the same from openOCD in PATH.

Remove venv and pip validation on setup wizard

Description

This pull request introduces several improvements and code cleanups related to binary detection and environment setup for ESP-IDF tools, especially around OpenOCD and Clangd integration. The changes enhance how the code locates tool binaries, sets up environment variables, and removes unnecessary Python environment checks.

Binary detection and environment setup improvements:

  • Updated the isBinInPath utility to accept an optional containerDir parameter, allowing it to more precisely detect binaries within specific directories (e.g., "esp-clang" or "openocd-esp32") and return the correct path only if the binary is in the intended container. [1] [2]
  • Enhanced appendIdfAndToolsToPath to automatically set the OPENOCD_SCRIPTS environment variable if the OpenOCD binary is found, improving script path configuration for debugging tools.

OpenOCD and Clangd integration:

  • Refactored OpenOCD management to use the detected binary path from isBinInPath (with "openocd-esp32" as a container), ensuring the correct binary is used for version checks and server spawning. [1] [2] [3]
  • Improved Clangd detection by searching for "clangd" within the "esp-clang" container directory, and simplified Clangd settings by removing the specific GCC query driver path and using a wildcard instead. [1] [2]

Python environment checks cleanup:

  • Removed redundant checks for pip and venv existence from both the Python manager and setup/install steps, streamlining the setup process and reducing unnecessary error handling. [1] [2] [3] [4]

Miscellaneous:

  • Minor code cleanups and parameter adjustments, such as removing unused imports and simplifying workspace folder handling in the new project panel. [1] [2]

These changes collectively make the ESP-IDF extension's toolchain setup more robust and maintainable, especially in environments with multiple tool versions or custom installations.

Fixes #1596
Fixes #1661

Type of change

Please delete options that are not relevant.

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

Steps to test this pull request

Having openocd in /usr/bin/openocd or /usr/bin/clangd in PATH, when running OpenOCD server or ESP-IDF: Configure project for ESP-Clang it should use the executable from IDF_TOOLS_PATH instead of /usr/bin.

  1. Click on "ESP-IDF: Configure project for ESP-Clang". Make sure no error about missing esp-clang.
  2. Execute OpenOCD Server. Make sure it doesn't use system /usr/bin/openocd
  3. From an existing ESP-IDF project, run the ESP-IDF: New Project wizard to create a new project.
  4. Observe results. In newly created project .vscode/settings.json you should see --query-driver=** and --compile-commands-dir= pointing to the current esp-idf project build directory. Before it was pointing to directory used to run ESP-IDF: New Project.
  • Expected behaviour:
    Clang settings in vscode/settings.json are --query-driver=** and --compile-commands-dir= points to current project build directory
    OpenOCD and clangd are used from IDF_TOOLS_PATH instead of system (/usr/bin for example)

  • Expected output:

How has this been tested?

Manual testing using steps above.

Test Configuration:

  • ESP-IDF Version: 5.5.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 self-assigned this Sep 16, 2025
@brianignacio5 brianignacio5 added this to the v1.11.0 milestone Sep 16, 2025
@brianignacio5 brianignacio5 added the bugfix Fixing some issue and bug in this PR label Sep 16, 2025
@github-actions
Copy link

github-actions bot commented Sep 16, 2025

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

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.

Could not reproduce the issue to confirm solution, but did not find any related regression.

@brianignacio5 brianignacio5 merged commit bfd33e3 into master Sep 22, 2025
6 checks passed
@brianignacio5 brianignacio5 deleted the bugfix/clang-openocd-binary-in-path branch September 22, 2025 05:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Fixing some issue and bug in this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

System openocd used instead of idf-tools installed version (VSC-1764) Configure ESP-Clang fails (VSC-1717)

4 participants