Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ get_serial_list.py
*.vsix
export.ps1
export.bat
*.code-profile

#dirs
.vscode
Expand Down
6 changes: 4 additions & 2 deletions l10n/bundle.l10n.es.json
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,9 @@
"Type 'SWITCH' to confirm switching to Release Mode": "Escriba 'SWITCH' para confirmar el cambio al Modo Release",
"Please type 'SWITCH' exactly to confirm": "Por favor escriba 'SWITCH' exactamente para confirmar",
"Switching to Release Mode cancelled by user": "Cambio al Modo Release cancelado por el usuario",
"User confirmed switching to Release Mode. Proceeding with flash encryption.": "Usuario confirmó el cambio al Modo Release. Procediendo con el cifrado de flash.",
"Connected ESP-IDF devkit detection is skipped while debugging. You can still select a target manually.": "La detección de devkit ESP-IDF conectados se omite durante la depuración. Aún puede seleccionar un objetivo manualmente.",
"Connected ESP-IDF devkit detection is not available for your {openOCDVersion} OpenOCD version. Required version is {minRequiredVersion} or higher. You can still select a target manually.": "La detección de devkit ESP-IDF conectados no está disponible para su versión de OpenOCD {openOCDVersion}. Se requiere la versión {minRequiredVersion} o superior. Aún puede seleccionar un objetivo manualmente."
"Connected ESP-IDF devkit detection is not available for your {openOCDVersion} OpenOCD version. Required version is {minRequiredVersion} or higher. You can still select a target manually.": "La detección de devkit ESP-IDF conectados no está disponible para su versión de OpenOCD {openOCDVersion}. Se requiere la versión {minRequiredVersion} o superior. Aún puede seleccionar un objetivo manualmente.",
"User confirmed switching to Release Mode. Proceeding with flash encryption.": "El usuario confirmó el cambio al Modo de Lanzamiento. Procediendo con el cifrado de flash.",
"Activate Anyway": "Activar de todos modos",
"No standard ESP-IDF project was found in this workspace. Do you want to activate the ESP-IDF extension anyway?": "No se encontró ningún proyecto ESP-IDF estándar en este espacio de trabajo. ¿Desea activar la extensión ESP-IDF de todos modos?"
}
6 changes: 4 additions & 2 deletions l10n/bundle.l10n.pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,9 @@
"Type 'SWITCH' to confirm switching to Release Mode": "Digite 'SWITCH' para confirmar a mudança para o Modo de Release",
"Please type 'SWITCH' exactly to confirm": "Por favor, digite 'SWITCH' exatamente para confirmar",
"Switching to Release Mode cancelled by user": "Mudança para o Modo de Release cancelada pelo usuário",
"User confirmed switching to Release Mode. Proceeding with flash encryption.": "Usuário confirmou a mudança para o Modo de Release. Prosseguindo com a criptografia flash.",
"Connected ESP-IDF devkit detection is skipped while debugging. You can still select a target manually.": "A detecção de devkit ESP-IDF conectados é ignorada durante a depuração. Você ainda pode selecionar um alvo manualmente.",
"Connected ESP-IDF devkit detection is not available for your {openOCDVersion} OpenOCD version. Required version is {minRequiredVersion} or higher. You can still select a target manually.": "A detecção de devkit ESP-IDF conectados não está disponível para sua versão do OpenOCD {openOCDVersion}. É necessária a versão {minRequiredVersion} ou superior. Você ainda pode selecionar um alvo manualmente."
"Connected ESP-IDF devkit detection is not available for your {openOCDVersion} OpenOCD version. Required version is {minRequiredVersion} or higher. You can still select a target manually.": "A detecção de devkit ESP-IDF conectados não está disponível para sua versão do OpenOCD {openOCDVersion}. É necessária a versão {minRequiredVersion} ou superior. Você ainda pode selecionar um alvo manualmente.",
"User confirmed switching to Release Mode. Proceeding with flash encryption.": "Usuário confirmou a mudança para o Modo de Lançamento. Prosseguindo com a criptografia da flash.",
"Activate Anyway": "Ativar mesmo assim",
"No standard ESP-IDF project was found in this workspace. Do you want to activate the ESP-IDF extension anyway?": "Nenhum projeto ESP-IDF padrão foi encontrado neste espaço de trabalho. Deseja ativar a extensão ESP-IDF mesmo assim?"
}
4 changes: 3 additions & 1 deletion l10n/bundle.l10n.ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -235,5 +235,7 @@
"Switching to Release Mode cancelled by user": "Переключение в Режим Релиза отменено пользователем",
"User confirmed switching to Release Mode. Proceeding with flash encryption.": "Пользователь подтвердил переключение в Режим Релиза. Продолжаем шифрование флеш-памяти.",
"Connected ESP-IDF devkit detection is skipped while debugging. You can still select a target manually.": "Обнаружение подключенных ESP-IDF devkit пропускается во время отладки. Вы все еще можете выбрать цель вручную.",
"Connected ESP-IDF devkit detection is not available for your {openOCDVersion} OpenOCD version. Required version is {minRequiredVersion} or higher. You can still select a target manually.": "Обнаружение подключенных ESP-IDF devkit недоступно для вашей версии OpenOCD {openOCDVersion}. Требуется версия {minRequiredVersion} или выше. Вы все еще можете выбрать цель вручную."
"Connected ESP-IDF devkit detection is not available for your {openOCDVersion} OpenOCD version. Required version is {minRequiredVersion} or higher. You can still select a target manually.": "Обнаружение подключенных ESP-IDF devkit недоступно для вашей версии OpenOCD {openOCDVersion}. Требуется версия {minRequiredVersion} или выше. Вы все еще можете выбрать цель вручную.",
"Activate Anyway": "Активировать в любом случае",
"No standard ESP-IDF project was found in this workspace. Do you want to activate the ESP-IDF extension anyway?": "В этой рабочей области не найден стандартный проект ESP-IDF. Хотите активировать расширение ESP-IDF в любом случае?"
}
4 changes: 3 additions & 1 deletion l10n/bundle.l10n.zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -235,5 +235,7 @@
"Switching to Release Mode cancelled by user": "用户取消了切换到发布模式",
"User confirmed switching to Release Mode. Proceeding with flash encryption.": "用户确认切换到发布模式。继续进行闪存加密。",
"Connected ESP-IDF devkit detection is skipped while debugging. You can still select a target manually.": "调试时跳过已连接的 ESP-IDF 开发板检测。您仍可以手动选择目标。",
"Connected ESP-IDF devkit detection is not available for your {openOCDVersion} OpenOCD version. Required version is {minRequiredVersion} or higher. You can still select a target manually.": "您的 OpenOCD 版本 {openOCDVersion} 不支持已连接的 ESP-IDF 开发板检测功能。需要 {minRequiredVersion} 或更高版本。您仍可以手动选择目标。"
"Connected ESP-IDF devkit detection is not available for your {openOCDVersion} OpenOCD version. Required version is {minRequiredVersion} or higher. You can still select a target manually.": "您的 OpenOCD 版本 {openOCDVersion} 不支持已连接的 ESP-IDF 开发板检测功能。需要 {minRequiredVersion} 或更高版本。您仍可以手动选择目标。",
"Activate Anyway": "仍然激活",
"No standard ESP-IDF project was found in this workspace. Do you want to activate the ESP-IDF extension anyway?": "在当前工作区中未找到标准 ESP-IDF 项目。您是否仍要激活 ESP-IDF 扩展?"
}
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,6 @@
"onView:idfPartitionExplorer",
"onView:espRainmaker",
"onView:idfComponents",
"workspaceContains:**/project_description.json",
"workspaceContains:**/sdkconfig",
"workspaceContains:**/CMakeLists.txt"
],
"main": "./dist/extension",
Expand Down
53 changes: 52 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ import { ArduinoComponentInstaller } from "./espIdf/arduino/addArduinoComponent"
import { PartitionTableEditorPanel } from "./espIdf/partition-table";
import { ESPEFuseTreeDataProvider } from "./efuse/view";
import { ESPEFuseManager } from "./efuse";
import { constants, createFileSync, pathExists } from "fs-extra";
import { constants, createFileSync, pathExists, readFile } from "fs-extra";
import { getEspAdf } from "./espAdf/espAdfDownload";
import { getEspMdf } from "./espMdf/espMdfDownload";
import { SetupPanel } from "./setup/SetupPanel";
Expand Down Expand Up @@ -276,6 +276,57 @@ export async function activate(context: vscode.ExtensionContext) {
Telemetry.init(idfConf.readParameter("idf.telemetry") || false);
utils.setExtensionContext(context);
ChangelogViewer.showChangeLogAndUpdateVersion(context);

// Check for CMakeLists.txt and its content before full activation
if (PreCheck.isWorkspaceFolderOpen()) {
const cmakeListsFiles = await vscode.workspace.findFiles(
"**/CMakeLists.txt",
"**/{build,node_modules}/**"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we need node_modules? Isn't it from JavaScript Typescript projects ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

The build folder is also used in CMake project or many other kind of projects. The next validation is only for CMakeLists.txt so I'm just wondering why other files are needed here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The vscode.workspace.findFiles expects as a second argument an exclusion pattern. I just thought it would be good to ignore searching in file such as "node_modules" and "build", if they are present in the opened workspace.

This was the exact thing I wanted to discuss about this new implementation: I can remove the "node_modules" if you think it's unnecessary or add these exclusion patterns for other languages as well, to increase performance of vscode.workspace.findFiles

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh I see.

Remember that the extension is activated either by running command or "workspaceContains:**/CMakeLists.txt"

Later you can use loop of all workspaceFolders with a relative pattern per workspace folder validation for root only:

const relativePattern = new RelativePattern(workspaceFolderUri, "CMakeLists.txt");
const files = await workspace.findFiles(relativePattern);

The content you are validating is for ESP-IDF root CMakeLists.txt only, so no need to check additional places.

Copy link
Collaborator Author

@radurentea radurentea Jul 3, 2025

Choose a reason for hiding this comment

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

I have changed the implementation once again based on our discussion only needing the CMakeLists.txt from root level. There is no need to use workspace.findFiles() anymore. I've left more details in the commit description

);

let hasValidIdfProject = false;
for (const cmakeList of cmakeListsFiles) {
try {
const cmakeContent = await readFile(cmakeList.fsPath, "utf-8");
if (
cmakeContent.includes(
"include($ENV{IDF_PATH}/tools/cmake/project.cmake)"
)
) {
hasValidIdfProject = true;
break; // Found a valid project, activate immediately
}
} catch (error) {
Logger.error(
`Error reading ${cmakeList.fsPath} for activation check.`,
error,
"extension activate checkCMakeContent"
);
}
}

if (!hasValidIdfProject) {
// At least one CMakeLists.txt was found, but none are ESP-IDF projects.
const activateAnyway = await vscode.window.showInformationMessage(
vscode.l10n.t(
"No standard ESP-IDF project was found in this workspace. Do you want to activate the ESP-IDF extension anyway?"
),
{ modal: false },
{ title: vscode.l10n.t("Activate Anyway") }
);
if (
!activateAnyway ||
activateAnyway.title !== vscode.l10n.t("Activate Anyway")
) {
Logger.info("User chose not to activate the ESP-IDF extension.");
return; // Exit activation early
}
Logger.info(
"User chose to activate the ESP-IDF extension despite no standard ESP-IDF project was found."
);
}
}

debugAdapterManager = DebugAdapterManager.init(context);
OutputChannel.init();
const registerIDFCommand = (
Expand Down