Skip to content

Commit 9f1c322

Browse files
[VSC-1630 | 1527] Feature clang project configuration (#1489)
* add clang project configuration * add cmds and translations * add docs * include esp clang in setup and new project wizard * read trail comma json fix * add clangd format file
1 parent ee180ec commit 9f1c322

20 files changed

+208
-34
lines changed

docs_espressif/en/commands.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ All commands start with ``ESP-IDF:``.
3232
- Open a window with a setup wizard to install ESP-IDF, IDF Tools and Python virtual environment.
3333
* - Configure Project SDKConfig for Coverage
3434
- Set required values in your project SDKConfig to enable code coverage analysis.
35+
* - Configure project for ESP-Clang
36+
- Configure the current ESP-IDF project to use esp-clang as toolchain to use and configure LLVM Clang extension in settings.json.
3537
* - Create Project from Extension Template
3638
- Create an ESP-IDF project using one of the extension template projects.
3739
* - Create New ESP-IDF Component

docs_espressif/en/configureproject.rst

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,24 @@ For code navigation and C/C++ syntax highlighting, you can use `Microsoft C/C++
3232

3333
Usually C/C++ language extensions rely on a file called ``compile_commands.json``, which is located in your project build directory. You can generate this file using the ``ESP-IDF: Run idf.py reconfigure task``.
3434

35-
For LLVM clangd extension, only ``compile_commands.json`` is needed. For Microsoft C/C++ extension, a configuration file is located at ``{PROJECT_DIRECTORY_PATH}/.vscode/c_cpp_properties.json``. This file can be generated by creating a project using ``ESP-IDF: New Project``, ``ESP-IDF: Show Example Projects`` command, or by using the ``ESP-IDF: Add .vscode Configuration Folder`` command on an existing ESP-IDF projects.
35+
For `LLVM clangd extension <https://marketplace.visualstudio.com/items?itemName=llvm-vs-code-extensions.vscode-clangd>`_, the user can use the ``ESP-IDF: Configure project for ESP-Clang`` to configure this extension argument.
36+
The command will search for ``esp-clang`` in the configured ESP-IDF setup, the build directory from ``idf.buildPath`` (``idf.buildPathWin`` in Windows) and the GCC toolchain path from current ``IDF_TARGET`` and configured ESP-IDF setup and use these paths to configure clang path and arguments.
37+
38+
The result looks like this:
39+
40+
.. code-block:: JSON
41+
42+
{
43+
"clangd.path": "/Users/user/.espressif/tools/esp-clang/esp-18.1.2_20240912/esp-clang/bin/clangd",
44+
"clangd.arguments": [
45+
"--background-index",
46+
"--query-driver=/Users/user/.espressif/tools/xtensa-esp-elf/esp-14.2.0_20241119/xtensa-esp-elf/bin/xtensa-esp32-elf-gcc",
47+
"--compile-commands-dir=/path/to/esp-idf-project/build"
48+
]
49+
}
50+
51+
52+
For `Microsoft C/C++ extension <https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools>`_, a configuration file is located at ``{PROJECT_DIRECTORY_PATH}/.vscode/c_cpp_properties.json``. This file can be generated by creating a project using ``ESP-IDF: New Project``, ``ESP-IDF: Show Example Projects`` command, or by using the ``ESP-IDF: Add .vscode Configuration Folder`` command on an existing ESP-IDF projects.
3653

3754
The file structure is as follows:
3855

l10n/bundle.l10n.es.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@
165165
"Launch Websocket server and IDF Monitor": "Inicie el servidor Websocket y el monitor IDF",
166166
"Start/Stop QEMU Server": "Iniciar/detener el servidor QEMU",
167167
"Configure ESP-IDF Extension": "Configurar la extensión ESP-IDF",
168+
"esp-clang not found in PATH. Make sure esp-clang is installed.": "No se ha encontrado a esp-clang en PATH. Verifique la instalación de esp-clang.",
168169
"Select current ESP-IDF version": "Seleccione la versión actual de ESP-IDF",
169170
"Show Examples": "Mostrar ejemplos",
170171
"New Project Wizard": "Asistente para nuevos proyectos",
@@ -203,9 +204,7 @@
203204
"Yes": "",
204205
"No": "No",
205206
"Starting ESP-IDF settings cleanup...": "Iniciando limpieza de configuraciones ESP-IDF...",
206-
"Removed global setting: {0}": "Configuración global eliminada: {0}",
207-
"Removed workspace setting: {0}": "Configuración del espacio de trabajo eliminada: {0}",
208-
"Removed workspace folder setting: {0}": "Configuración de la carpeta del espacio de trabajo eliminada: {0}",
207+
"Removed {0} setting: {1}": "Configuración {0} eliminada: {1}",
209208
"Warning: Could not fully remove setting {0}: {1}": "Advertencia: No se pudo eliminar completamente la configuración {0}: {1}",
210209
"ESP-IDF settings removed successfully.": "Configuraciones de ESP-IDF eliminadas exitosamente.",
211210
"Failed to remove settings: {0}": "Error al eliminar las configuraciones: {0}",

l10n/bundle.l10n.pt.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@
164164
"Flash with DFU": "Flash com DFU",
165165
"Launch Websocket server and IDF Monitor": "Inicie o servidor Websocket e o IDF Monitor",
166166
"Start/Stop QEMU Server": "Iniciar/parar servidor QEMU",
167+
"esp-clang not found in PATH. Make sure esp-clang is installed.": "esp-clang não encontrado em PATH. Certifique-se de que o esp-clang está instalado.",
167168
"Configure ESP-IDF Extension": "Configurar extensão ESP-IDF",
168169
"Select current ESP-IDF version": "Selecione a versão atual do ESP-IDF",
169170
"Show Examples": "Mostrar exemplos",
@@ -203,9 +204,7 @@
203204
"Yes": "Sim",
204205
"No": "Não",
205206
"Starting ESP-IDF settings cleanup...": "Iniciando limpeza das configurações ESP-IDF...",
206-
"Removed global setting: {0}": "Configuração global removida: {0}",
207-
"Removed workspace setting: {0}": "Configuração do espaço de trabalho removida: {0}",
208-
"Removed workspace folder setting: {0}": "Configuração da pasta do espaço de trabalho removida: {0}",
207+
"Removed {0} setting: {1}": "Configuração ${0} removida: {1}",
209208
"Warning: Could not fully remove setting {0}: {1}": "Aviso: Não foi possível remover completamente a configuração {0}: {1}",
210209
"ESP-IDF settings removed successfully.": "Configurações ESP-IDF removidas com sucesso.",
211210
"Failed to remove settings: {0}": "Falha ao remover configurações: {0}",

l10n/bundle.l10n.ru.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@
164164
"Flash with DFU": "Прошивка через DFU",
165165
"Launch Websocket server and IDF Monitor": "Запуск сервера Websocket и монитора IDF",
166166
"Start/Stop QEMU Server": "Запуск/остановка сервера QEMU",
167+
"esp-clang not found in PATH. Make sure esp-clang is installed.": "esp-clang не найден в PATH. Убедитесь, что esp-clang установлен.",
167168
"Configure ESP-IDF Extension": "Настройка расширения ESP-IDF",
168169
"Select current ESP-IDF version": "Выбор текущей версии ESP-IDF",
169170
"Show Examples": "Показать примеры",
@@ -203,9 +204,7 @@
203204
"Yes": "Да",
204205
"No": "Нет",
205206
"Starting ESP-IDF settings cleanup...": "Начинается очистка настроек ESP-IDF...",
206-
"Removed global setting: {0}": "Удалена глобальная настройка: {0}",
207-
"Removed workspace setting: {0}": "Удалена настройка рабочего пространства: {0}",
208-
"Removed workspace folder setting: {0}": "Удалена настройка папки рабочего пространства: {0}",
207+
"Removed {0} setting: {1}": "Удалена {0} настройка: {1}",
209208
"Warning: Could not fully remove setting {0}: {1}": "Предупреждение: Не удалось полностью удалить настройку {0}: {1}",
210209
"ESP-IDF settings removed successfully.": "Настройки ESP-IDF успешно удалены.",
211210
"Failed to remove settings: {0}": "Не удалось удалить настройки: {0}",

l10n/bundle.l10n.zh-CN.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@
164164
"Flash with DFU": "通过 DFU 接口烧录项目",
165165
"Launch Websocket server and IDF Monitor": "启动 WebSocket 服务器和 IDF 监视器",
166166
"Start/Stop QEMU Server": "启动/停止 QEMU 服务器",
167+
"esp-clang not found in PATH. Make sure esp-clang is installed.": "在 PATH 中未找到 esp-clang。请确保已安装 esp-clang。",
167168
"Configure ESP-IDF Extension": "配置 ESP-IDF 扩展",
168169
"Select current ESP-IDF version": "选择当前的 ESP-IDF 版本",
169170
"Show Examples": "展示示例项目",
@@ -203,9 +204,7 @@
203204
"Yes": "",
204205
"No": "",
205206
"Starting ESP-IDF settings cleanup...": "正在开始清理ESP-IDF设置...",
206-
"Removed global setting: {0}": "已删除全局设置:{0}",
207-
"Removed workspace setting: {0}": "已删除工作区设置:{0}",
208-
"Removed workspace folder setting: {0}": "已删除工作区文件夹设置:{0}",
207+
"Removed {0} setting: {1}": "已删除 {0} 设置:{1}",
209208
"Warning: Could not fully remove setting {0}: {1}": "警告:无法完全删除设置 {0}:{1}",
210209
"ESP-IDF settings removed successfully.": "ESP-IDF设置已成功删除。",
211210
"Failed to remove settings: {0}": "删除设置失败:{0}",

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1756,6 +1756,11 @@
17561756
"title": "%espIdf.hexView.deleteElement.title%",
17571757
"category": "ESP-IDF",
17581758
"icon": "$(trash)"
1759+
},
1760+
{
1761+
"command": "espIdf.setClangSettings",
1762+
"title": "%espIdf.setClangSettings.title%",
1763+
"category": "ESP-IDF"
17591764
}
17601765
],
17611766
"breakpoints": [

package.nls.es.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
"espIdf.selectNotificationMode.title": "Seleccionar modo de notificación y salida",
8686
"espIdf.selectOpenOcdConfigFiles.title": "Seleccionar archivos de configuración de placa OpenOCD",
8787
"espIdf.selectPort.title": "Seleccionar puerto a usar (COM, tty, usbserial)",
88+
"espIdf.setClangSettings.title": "Configurar el proyecto para usar ESP-Clang",
8889
"espIdf.setGcovConfig.title": "Configurar SDKConfig del proyecto para cobertura",
8990
"espIdf.setMatterDevicePath.title": "Establecer Ruta del Dispositivo ESP-MATTER (ESP_MATTER_DEVICE_PATH)",
9091
"espIdf.setTarget.title": "Establecer Objetivo del Dispositivo Espressif",

package.nls.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
"espIdf.selectNotificationMode.title": "Select Output and Notification Mode",
8686
"espIdf.selectOpenOcdConfigFiles.title": "Select OpenOCD Board Configuration",
8787
"espIdf.selectPort.title": "Select Port to Use (COM, tty, usbserial)",
88+
"espIdf.setClangSettings.title": "Configure project for ESP-Clang",
8889
"espIdf.setGcovConfig.title": "Configure Project SDKConfig for Coverage",
8990
"espIdf.setMatterDevicePath.title": "Set ESP-MATTER Device Path (ESP_MATTER_DEVICE_PATH)",
9091
"espIdf.setTarget.title": "Set Espressif Device Target",

package.nls.pt.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
"espIdf.selectNotificationMode.title": "Selecione o modo de saída e notificação",
8686
"espIdf.selectOpenOcdConfigFiles.title": "Selecione a configuração da placa OpenOCD",
8787
"espIdf.selectPort.title": "Selecione a porta a ser usada (COM, tty, usbserial)",
88+
"espIdf.setClangSettings.title": "Configurar o projeto para ESP-Clang",
8889
"espIdf.setGcovConfig.title": "Configurar o projeto SDKConfig para cobertura",
8990
"espIdf.setMatterDevicePath.title": "Definir caminho do dispositivo ESP-MATTER (ESP_MATTER_DEVICE_PATH)",
9091
"espIdf.setTarget.title": "Definir destino do dispositivo Espressif",

0 commit comments

Comments
 (0)