Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 45 additions & 14 deletions docs_espressif/en/additionalfeatures/multiple-projects.rst
Original file line number Diff line number Diff line change
Expand Up @@ -102,25 +102,56 @@ Use Multiple Build Configurations in the Same Workspace Folder

Use the ESP-IDF CMake `Multiple Build Configurations Example <https://github.com/espressif/esp-idf/tree/master/examples/build_system/cmake/multi_config>`_ to follow this tutorial.

Use the ``ESP-IDF: Open Project Configuration`` command to create two configuration profiles: ``prod1`` and ``prod2``. Set ``sdkconfig.prod_common;sdkconfig.prod1`` and ``sdkconfig.prod_common;sdkconfig.prod2`` in the sdkconfig defaults field as shown below:

.. image:: ../../../media/tutorials/project_conf/enterConfigName.png

.. image:: ../../../media/tutorials/project_conf/prod1.png

.. image:: ../../../media/tutorials/project_conf/prod2.png

After creating each profile and setting the configuration, click the ``Save`` button. Use the ``ESP-IDF: Select Project Configuration`` command to choose the configuration to override extension configuration settings.
.. note::

.. image:: ../../../media/tutorials/project_conf/selectConfig.png
The ESP-IDF ``multi_config`` example already ships with a ready-to-use ``CMakePresets.json`` and works out of the box. When you select a project configuration in this extension, the extension will automatically attach vendor settings under ``espressif/vscode-esp-idf`` for the chosen preset (for example, OpenOCD configuration and ``IDF_TARGET``) based on your currently selected board configuration and target in the extension.

Once a configuration profile is selected, it will appear in the status bar as shown before.
Define your configurations in ``CMakePresets.json`` (and optionally ``CMakeUserPresets.json``). Then use ``ESP-IDF: Select Project Configuration`` to choose among the discovered presets. The extension will apply the selected preset when building/flashing/monitoring.

.. image:: ../../../media/tutorials/project_conf/configInStatusBar.png
Typical entries in ``CMakePresets.json``:

Now, use the ``ESP-IDF: Build your Project`` command to build the project for ``prod1`` and ``prod2``. You will see binaries generated for each profile in the specified path. Use the ``ESP-IDF: Select Project Configuration`` command to switch between configurations.
.. code-block:: JSON

Use the ``ESP-IDF: Open Project Configuration`` command to modify, add, or delete the configuration profiles. To stop using these profiles, delete all configuration profiles.
{
"version": 3,
"configurePresets": [
{
"name": "default",
"binaryDir": "build/default",
"displayName": "Default (development)",
"description": "Development configuration",
"cacheVariables": {
"SDKCONFIG": "./build/default/sdkconfig"
}
},
{
"name": "prod1",
"binaryDir": "build/prod1",
"displayName": "Product 1",
"description": "Production configuration for product 1",
"cacheVariables": {
"SDKCONFIG_DEFAULTS": "sdkconfig.defaults.prod_common;sdkconfig.defaults.prod1",
"SDKCONFIG": "./build/prod1/sdkconfig"
}
},
{
"name": "prod2",
"binaryDir": "build/prod2",
"displayName": "Product 2",
"description": "Production configuration for product 2",
"cacheVariables": {
"SDKCONFIG_DEFAULTS": "sdkconfig.defaults.prod_common;sdkconfig.defaults.prod2",
"SDKCONFIG": "./build/prod2/sdkconfig"
}
}
]
}

Selecting presets:

1. Open Command Palette and run ``ESP-IDF: Select Project Configuration``.
2. Pick ``default``, ``prod1`` or ``prod2``.
3. Run ``ESP-IDF: Build Your Project`` to build with the selected preset. Switch presets any time via the same selection command.

Multiple ESP-IDF Versions
-------------------------
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
{
"$id": "https://dl.espressif.com/schemas/esp-idf-cmakepresets-schema-v1.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "ESP-IDF CMakePresets Extension v1.0",
"description": "Extends the official CMakePresets schema (v3) with strict ESP-IDF vendor fields; requires CMake >= 3.21.",
"allOf": [
{
"$ref": "https://raw.githubusercontent.com/Kitware/CMake/master/Help/manual/presets/schema.json"
},
{
"type": "object",
"properties": {
"version": {
"const": 3,
"description": "CMake Presets format version. Must be 3."
},
"cmakeMinimumRequired": {
"type": "object",
"properties": {
"major": { "type": "integer", "const": 3 },
"minor": { "type": "integer", "minimum": 21 },
"patch": { "type": "integer", "minimum": 0 }
},
"required": ["major", "minor"]
},
"configurePresets": {
"type": "array",
"items": {
"type": "object",
"properties": {
"vendor": {
"type": "object",
"properties": {
"espressif/vscode-esp-idf": {
"type": "object",
"properties": {
"schemaVersion": {
"type": "integer",
"enum": [1],
"description": "ESP-IDF vendor schema version."
},
"settings": {
"type": "array",
"items": {
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"compileArgs",
"ninjaArgs",
"flashBaudRate",
"monitorBaudRate",
"openOCD",
"tasks"
]
},
"value": {}
},
"required": ["type", "value"],
"additionalProperties": false,
"allOf": [
{
"if": { "properties": { "type": { "enum": ["compileArgs", "ninjaArgs"] } } },
"then": { "properties": { "value": { "type": "array", "items": { "type": "string" } } } }
},
{
"if": { "properties": { "type": { "enum": ["flashBaudRate", "monitorBaudRate"] } } },
"then": { "properties": { "value": { "type": "string" } } }
},
{
"if": { "properties": { "type": { "const": "openOCD" } } },
"then": {
"properties": {
"value": {
"type": "object",
"properties": {
"debugLevel": { "type": "integer" },
"configs": { "type": "array", "items": { "type": "string" } },
"args": { "type": "array", "items": { "type": "string" } }
},
"required": ["debugLevel", "configs", "args"],
"additionalProperties": false
}
}
}
},
{
"if": { "properties": { "type": { "const": "tasks" } } },
"then": {
"properties": {
"value": {
"type": "object",
"properties": {
"preBuild": { "type": "string" },
"preFlash": { "type": "string" },
"postBuild": { "type": "string" },
"postFlash": { "type": "string" }
},
"additionalProperties": false
}
}
}
}
]
}
}
},
"required": ["schemaVersion", "settings"],
"additionalProperties": false
}
},
"additionalProperties": true
}
}
}
}
},
"required": ["version", "cmakeMinimumRequired", "configurePresets"]
}
]
}
18 changes: 17 additions & 1 deletion l10n/bundle.l10n.es.json
Original file line number Diff line number Diff line change
Expand Up @@ -257,5 +257,21 @@
"Clear Build Error Hints": "Borrar Pistas de Error de Compilación",
"Clear OpenOCD Error Hints": "Borrar Pistas de Error de OpenOCD",
"Open Reference": "Abrir Referencia",
"Launch Debug": "Iniciar depuración"
"Launch Debug": "Iniciar depuración",
"Cancel": "Cancelar",
"OpenOCD Exit with non-zero error code {0}": "OpenOCD salió con un código de error distinto de cero {0}",
"Loaded {0} project configuration(s) from {1}: {2}. No configuration selected.": "Se cargaron {0} configuraciones de proyecto desde {1}: {2}. Ninguna configuración seleccionada.",
"Loaded {0} project configuration(s) from {1}: {2}": "Se cargaron {0} configuraciones de proyecto desde {1}: {2}",
"Failed to parse project configuration files": "Error al analizar los archivos de configuración del proyecto",
"New configurations added: {0}": "Nuevas configuraciones agregadas: {0}",
"Configurations removed: {0}": "Configuraciones eliminadas: {0}",
"Project configuration file has been deleted.": "Se ha eliminado el archivo de configuración del proyecto.",
"Project configuration file created with {0} configuration(s). Select one to use.": "Archivo de configuración del proyecto creado con {0} configuración(es). Seleccione una para usar.",
"Open editor": "Abrir editor",
"Configuration {0}": "Configuración {0}",
"No Configuration Selected": "Ninguna configuración seleccionada",
"No project configuration selected. Click to select one": "No se seleccionó ninguna configuración de proyecto. Haga clic para seleccionar una",
"Legacy Configs ({0})": "Configuraciones heredadas ({0})",
"Found legacy project configurations: {0}. Click to migrate to the new CMakePresets.json format.": "Se encontraron configuraciones de proyecto heredadas: {0}. Haga clic para migrar al nuevo formato CMakePresets.json.",
"Project Configuration changes have been saved": "Se han guardado los cambios de configuración del proyecto"
}
18 changes: 17 additions & 1 deletion l10n/bundle.l10n.pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -258,5 +258,21 @@
"Clear Build Error Hints": "Limpar Dicas de Erro de Compilação",
"Clear OpenOCD Error Hints": "Limpar Dicas de Erro do OpenOCD",
"Open Reference": "Abrir Referência",
"Launch Debug": "Iniciar depuração"
"Launch Debug": "Iniciar depuração",
"Cancel": "Cancelar",
"OpenOCD Exit with non-zero error code {0}": "OpenOCD saiu com código de erro diferente de zero {0}",
"Loaded {0} project configuration(s) from {1}: {2}. No configuration selected.": "{0} configuração(ões) de projeto carregada(s) de {1}: {2}. Nenhuma configuração selecionada.",
"Loaded {0} project configuration(s) from {1}: {2}": "{0} configuração(ões) de projeto carregada(s) de {1}: {2}",
"Failed to parse project configuration files": "Falha ao analisar os arquivos de configuração do projeto",
"New configurations added: {0}": "Novas configurações adicionadas: {0}",
"Configurations removed: {0}": "Configurações removidas: {0}",
"Project configuration file has been deleted.": "O arquivo de configuração do projeto foi excluído.",
"Project configuration file created with {0} configuration(s). Select one to use.": "Arquivo de configuração do projeto criado com {0} configuração(ões). Selecione uma para usar.",
"Open editor": "Abrir editor",
"Configuration {0}": "Configuração {0}",
"No Configuration Selected": "Nenhuma configuração selecionada",
"No project configuration selected. Click to select one": "Nenhuma configuração de projeto selecionada. Clique para selecionar uma",
"Legacy Configs ({0})": "Configurações legadas ({0})",
"Found legacy project configurations: {0}. Click to migrate to the new CMakePresets.json format.": "Foram encontradas configurações de projeto legadas: {0}. Clique para migrar para o novo formato CMakePresets.json.",
"Project Configuration changes have been saved": "As alterações na configuração do projeto foram salvas"
}
18 changes: 17 additions & 1 deletion l10n/bundle.l10n.ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -258,5 +258,21 @@
"Clear Build Error Hints": "Очистить подсказки по ошибкам сборки",
"Clear OpenOCD Error Hints": "Очистить подсказки по ошибкам OpenOCD",
"Open Reference": "Открыть ссылку",
"Launch Debug": "Запуск отладки"
"Launch Debug": "Запуск отладки",
"Cancel": "Отмена",
"OpenOCD Exit with non-zero error code {0}": "OpenOCD завершился с ненулевым кодом ошибки {0}",
"Loaded {0} project configuration(s) from {1}: {2}. No configuration selected.": "Загружено {0} конфигураций проекта из {1}: {2}. Конфигурация не выбрана.",
"Loaded {0} project configuration(s) from {1}: {2}": "Загружено {0} конфигураций проекта из {1}: {2}",
"Failed to parse project configuration files": "Не удалось проанализировать файлы конфигурации проекта",
"New configurations added: {0}": "Добавлены новые конфигурации: {0}",
"Configurations removed: {0}": "Конфигурации удалены: {0}",
"Project configuration file has been deleted.": "Файл конфигурации проекта был удален.",
"Project configuration file created with {0} configuration(s). Select one to use.": "Создан файл конфигурации проекта с {0} конфигурациями. Выберите одну для использования.",
"Open editor": "Открыть редактор",
"Configuration {0}": "Конфигурация {0}",
"No Configuration Selected": "Конфигурация не выбрана",
"No project configuration selected. Click to select one": "Конфигурация проекта не выбрана. Нажмите, чтобы выбрать",
"Legacy Configs ({0})": "Унаследованные конфигурации ({0})",
"Found legacy project configurations: {0}. Click to migrate to the new CMakePresets.json format.": "Найдены устаревшие конфигурации проекта: {0}. Нажмите, чтобы выполнить миграцию в новый формат CMakePresets.json.",
"Project Configuration changes have been saved": "Изменения конфигурации проекта сохранены"
}
18 changes: 17 additions & 1 deletion l10n/bundle.l10n.zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -258,5 +258,21 @@
"Clear Build Error Hints": "清除构建错误提示",
"Clear OpenOCD Error Hints": "清除 OpenOCD 错误提示",
"Open Reference": "打开参考",
"Launch Debug": "启动调试"
"Launch Debug": "启动调试",
"Cancel": "取消",
"OpenOCD Exit with non-zero error code {0}": "OpenOCD 以非零错误代码退出:{0}",
"Loaded {0} project configuration(s) from {1}: {2}. No configuration selected.": "已从 {1} 加载 {0} 个项目配置:{2}。未选择配置。",
"Loaded {0} project configuration(s) from {1}: {2}": "已从 {1} 加载 {0} 个项目配置:{2}",
"Failed to parse project configuration files": "解析项目配置文件失败",
"New configurations added: {0}": "已添加新配置:{0}",
"Configurations removed: {0}": "已移除配置:{0}",
"Project configuration file has been deleted.": "项目配置文件已删除。",
"Project configuration file created with {0} configuration(s). Select one to use.": "已创建包含 {0} 个配置的项目配置文件。请选择一个使用。",
"Open editor": "打开编辑器",
"Configuration {0}": "配置 {0}",
"No Configuration Selected": "未选择配置",
"No project configuration selected. Click to select one": "未选择项目配置。单击选择一个",
"Legacy Configs ({0})": "旧版配置({0})",
"Found legacy project configurations: {0}. Click to migrate to the new CMakePresets.json format.": "发现旧版项目配置:{0}。单击迁移到新的 CMakePresets.json 格式。",
"Project Configuration changes have been saved": "项目配置更改已保存"
}
15 changes: 15 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,15 @@
"main": "./dist/extension",
"l10n": "./l10n",
"contributes": {
"jsonValidation": [
{
"fileMatch": [
"CMakePresets.json",
"CMakeUserPresets.json"
],
"url": "./internal/com.espressif.idf.uploads/cmakepresets/esp-idf-cmakepresets-schema-v1.json"
}
],
"walkthroughs": [
{
"id": "espIdf.walkthrough.basic-usage",
Expand Down Expand Up @@ -1295,6 +1304,12 @@
"default": 60,
"scope": "resource",
"description": "%param.serialPortDetectionTimeout%"
},
"idf.saveLastProjectConfiguration": {
"type": "boolean",
"default": true,
"scope": "resource",
"description": "%param.saveLastProjectConfiguration%"
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -212,5 +212,6 @@
"command.errorHints.clearAll.title": "Clear All Error Hints",
"command.errorHints.clearBuild.title": "Clear Build Error Hints",
"command.errorHints.clearOpenOCD.title": "Clear OpenOCD Error Hints",
"Launch Debug": "Launch Debug"
"Launch Debug": "Launch Debug",
"param.saveLastProjectConfiguration": "Save and restore the last selected project configuration when reopening a workspace. When enabled, the extension will restore the last used configuration if it exists, otherwise no configuration will be selected. When disabled, no configuration will be selected by default."
}
2 changes: 1 addition & 1 deletion src/build/buildTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export class BuildTask {
let defaultCompilerArgs;
if (espIdfVersion === "x.x") {
Logger.warn(
"Could not determine ESP-IDF version. Using default compiler arguments for the latest known version."
"Could not determine ESP-IDF version. Using default compiler arguments for the latest known version."
);
defaultCompilerArgs = [
"-G",
Expand Down
4 changes: 2 additions & 2 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ export namespace ESP {
export namespace ProjectConfiguration {
export let store: ProjectConfigStore;
export const SELECTED_CONFIG = "SELECTED_PROJECT_CONFIG";
export const PROJECT_CONFIGURATION_FILENAME =
"esp_idf_project_configuration.json";
export const PROJECT_CONFIGURATION_FILENAME = "CMakePresets.json";
export const USER_CONFIGURATION_FILENAME = "CMakeUserPresets.json";
}

export enum BuildType {
Expand Down
Loading