From c61a3c75306cc3944c2d4b3aa8ba23637aa800c6 Mon Sep 17 00:00:00 2001 From: Brian Ignacio Date: Thu, 30 May 2024 16:06:08 +0800 Subject: [PATCH] add esp insights framework support --- README.md | 1 + docs/tutorial/additional_frameworks.md | 2 ++ l10n/bundle.l10n.es.json | 1 + l10n/bundle.l10n.pt.json | 1 + l10n/bundle.l10n.ru.json | 1 + l10n/bundle.l10n.zh-CN.json | 1 + package.json | 17 +++++++++++ package.nls.es.json | 2 ++ package.nls.json | 2 ++ package.nls.pt.json | 2 ++ package.nls.ru.json | 2 ++ package.nls.zh-CN.json | 2 ++ src/config.ts | 1 + src/espInsights/espInsightsDownload.ts | 40 ++++++++++++++++++++++++++ src/extension.ts | 23 +++++++++++++++ src/newProject/newProjectInit.ts | 13 +++++++++ src/utils.ts | 6 ++++ 17 files changed, 117 insertions(+) create mode 100644 src/espInsights/espInsightsDownload.ts diff --git a/README.md b/README.md index 5f163fd40..d9ddc9ec3 100644 --- a/README.md +++ b/README.md @@ -132,6 +132,7 @@ Click F1 to show Visual studio code actions, then type **ESP-IDF** to | Install ESP-Matter | | | | Install ESP-Rainmaker | | | | Install ESP-HomeKit-SDK | | | +| Install ESP-Insights | | | | Launch IDF Monitor for CoreDump / GDB-Stub Mode | | | | Launch QEMU Server | | | | Launch QEMU Debug Session | | | diff --git a/docs/tutorial/additional_frameworks.md b/docs/tutorial/additional_frameworks.md index a54443557..c92c0c9ec 100644 --- a/docs/tutorial/additional_frameworks.md +++ b/docs/tutorial/additional_frameworks.md @@ -14,6 +14,8 @@ Besides ESP-IDF, you can install other frameworks to extend the extension functi 5. [ESP-HomeKit-SDK](https://github.com/espressif/esp-homekit-sdk) can be clone with the **Install ESP-HomeKit-SDK** command to the selected directory and set `idf.espHomeKitSdkPath` (`idf.espHomeKitSdkPathWin` in Windows) configuration setting. +6. [ESP-Insights](https://github.com/espressif/esp-insights) can be clone with the **Install ESP-Insights** command to the selected directory and set `idf.espInsightsPath` (`idf.espInsightsPathWin` in Windows) configuration setting. + > **NOTE:** You can also just set each configuration setting with the framework directory path if you already have them. For example, on Visual Studio Code menu `View` -> `Command Palette..`. -> type `Preferences: Open Settings (UI)` and search for ESP-ADF (or other framework) to manually set this path. > **NOTE:** Please review [ESP-IDF Settings](../SETTINGS.md) to see how to modify these configuration settings. diff --git a/l10n/bundle.l10n.es.json b/l10n/bundle.l10n.es.json index 835aa38e1..c80c8c290 100644 --- a/l10n/bundle.l10n.es.json +++ b/l10n/bundle.l10n.es.json @@ -123,6 +123,7 @@ "Use current ESP-Matter {matterPathDir}": "Utilice ESP-Matter actual {matterPathDir}", "Use current ESP-Rainmaker {rainmakerPathDir}": "Utilice ESP-Rainmaker actual {rainmakerPathDir}", "Use current ESP-HomeKit-SDK {espHomeKitPathDir}": "Utilice ESP-HomeKit-SDK actual {espHomeKitPathDir}", + "Use current ESP-Insights {espInsightsPathDir}": "Utilice ESP-Insights actual {espInsightsPathDir}", "Enter non empty string": "Introduzca una cadena que no esté vacía", "Enter a valid integer": "Introduzca un número entero válido", "ESP-IDF: Select Port to Use (COM, tty, usbserial)": "ESP-IDF: seleccione el puerto a usar (COM, tty, usbserial)", diff --git a/l10n/bundle.l10n.pt.json b/l10n/bundle.l10n.pt.json index 5abfb0e87..6ccfc5bd8 100644 --- a/l10n/bundle.l10n.pt.json +++ b/l10n/bundle.l10n.pt.json @@ -123,6 +123,7 @@ "Use current ESP-Matter {matterPathDir}": "Use ESP-Matter atual {matterPathDir}", "Use current ESP-Rainmaker {rainmakerPathDir}": "Use o ESP-Rainmaker atual {rainmakerPathDir}", "Use current ESP-HomeKit-SDK {espHomeKitPathDir}": "Use o ESP-HomeKit-SDK atual {espHomeKitPathDir}", + "Use current ESP-Insights {espInsightsPathDir}": "Use o ESP-Insights atual {espInsightsPathDir}", "Enter non empty string": "Insira uma string não vazia", "Enter a valid integer": "Insira um número inteiro válido", "ESP-IDF: Select Port to Use (COM, tty, usbserial)": "ESP-IDF: Selecione a porta a ser usada (COM, tty, usbserial)", diff --git a/l10n/bundle.l10n.ru.json b/l10n/bundle.l10n.ru.json index 433743b3d..73fc601c7 100644 --- a/l10n/bundle.l10n.ru.json +++ b/l10n/bundle.l10n.ru.json @@ -123,6 +123,7 @@ "Use current ESP-Matter {matterPathDir}": "Использовать текущий ESP-Matter {matterPathDir}", "Use current ESP-Rainmaker {rainmakerPathDir}": "Используйте текущую версию ESP-Rainmaker {rainmakerPathDir}.", "Use current ESP-HomeKit-SDK {espHomeKitPathDir}": "Использовать текущий ESP-HomeKit-SDK {espHomeKitPathDir}", + "Use current ESP-Insights {espInsightsPathDir}": "Использовать текущий ESP-Insights {espInsightsPathDir}", "Enter non empty string": "Введите непустую строку", "Enter a valid integer": "Введите допустимое целое число", "ESP-IDF: Select Port to Use (COM, tty, usbserial)": "ESP-IDF: выберите порт для использования (COM, tty, usbserial)", diff --git a/l10n/bundle.l10n.zh-CN.json b/l10n/bundle.l10n.zh-CN.json index 4c6fb5222..c0e54e118 100644 --- a/l10n/bundle.l10n.zh-CN.json +++ b/l10n/bundle.l10n.zh-CN.json @@ -123,6 +123,7 @@ "Use current ESP-Matter {matterPathDir}": "使用当前 ESP-Matter {matterPathDir}", "Use current ESP-Rainmaker {rainmakerPathDir}": "使用当前的 ESP-Rainmaker {rainmakerPathDir}", "Use current ESP-HomeKit-SDK {espHomeKitPathDir}": "使用当前的 ESP-HomeKit-SDK {espHomeKitPathDir}", + "Use current ESP-Insights {espInsightsPathDir}": "使用当前的 ESP-Insights {espInsightsPathDir}", "Enter non empty string": "输入非空字符串", "Enter a valid integer": "输入有效的整数", "ESP-IDF: Select Port to Use (COM, tty, usbserial)": "ESP-IDF:选择要使用的端口(COM、tty、usbserial)", diff --git a/package.json b/package.json index 7300fbdad..71f825643 100644 --- a/package.json +++ b/package.json @@ -427,6 +427,12 @@ "description": "%param.espRainmakerPath%", "scope": "resource" }, + "idf.espInsightsPath": { + "type": "string", + "default": "${env:INSIGHTS_PATH}", + "description": "%param.espInsightsPath%", + "scope": "resource" + }, "idf.espIdfPathWin": { "type": "string", "default": "${env:IDF_PATH}", @@ -463,6 +469,12 @@ "description": "%param.espHomeKitSdkPath%", "scope": "resource" }, + "idf.espInsightsPathWin": { + "type": "string", + "default": "${env:INSIGHTS_PATH}", + "description": "%param.espInsightsPath%", + "scope": "resource" + }, "idf.port": { "type": "string", "default": "/dev/ttyUSB1", @@ -1222,6 +1234,11 @@ "title": "%espIdf.getEspHomeKitSdk.title%", "category": "ESP-IDF" }, + { + "command": "espIdf.getEspInsights", + "title": "%espIdf.getEspInsights.title%", + "category": "ESP-IDF" + }, { "command": "espIdf.installEspMatterPyReqs", "title": "%espIdf.installEspMatterPyReqs.title%", diff --git a/package.nls.es.json b/package.nls.es.json index 83a4595b0..d580558cf 100644 --- a/package.nls.es.json +++ b/package.nls.es.json @@ -49,6 +49,7 @@ "espIdf.getEspMatter.title": "Instalar ESP-Matter", "espIdf.getEspMdf.title": "Instalar ESP-MDF", "espIdf.getEspRainmaker.title": "Instalar ESP-Rainmaker", + "espIdf.getEspInsights.title": "Instalar ESP-Insights", "espIdf.heaptrace.title": "Rastreo de montón", "espIdf.idfReconfigureTask.title": "ESP-IDF: Ejecute la tarea de reconfiguración de idf.py", "espIdf.importProject.title": "Importar proyecto ESP-IDF", @@ -121,6 +122,7 @@ "param.espMatterPath": "Ruta para localizar el framework ESP-Matter (ESP_MATTER_PATH)", "param.espMdfPath": "Ruta para localizar el framework ESP-MDF (MDF_PATH)", "param.espRainmakerPath": "Ruta para localizar el framework ESP-Rainmaker (RMAKER_PATH)", + "param.espInsightsPath": "Ruta para localizar el framework ESP-Insights (INSIGHTS_PATH)", "param.exportPaths": "Rutas que se agregarán a PATH", "param.exportVars": "Variables que se agregarán a las variables de entorno del sistema", "param.flashBaudRate": "Tasa de baudios de flasheo ESP-IDF", diff --git a/package.nls.json b/package.nls.json index fffc41f8a..d68638237 100644 --- a/package.nls.json +++ b/package.nls.json @@ -49,6 +49,7 @@ "espIdf.getEspMatter.title": "Install ESP-Matter", "espIdf.getEspMdf.title": "Install ESP-MDF", "espIdf.getEspRainmaker.title": "Install ESP-Rainmaker", + "espIdf.getEspInsights.title": "Install ESP-Insights", "espIdf.heaptrace.title": "Heap Trace", "espIdf.idfReconfigureTask.title": "ESP-IDF: Run idf.py reconfigure task", "espIdf.importProject.title": "Import ESP-IDF Project", @@ -121,6 +122,7 @@ "param.espMatterPath": "Path to locate ESP-Matter framework (ESP_MATTER_PATH)", "param.espMdfPath": "Path to locate ESP-MDF framework (MDF_PATH)", "param.espRainmakerPath": "Path to locate ESP-Rainmaker framework (RMAKER_PATH)", + "param.espInsightsPath": "Path to locate ESP-Insights framework (INSIGHTS_PATH)", "param.exportPaths": "Paths to be appended to PATH", "param.exportVars": "Variables to be added to system environment variables", "param.flashBaudRate": "ESP-IDF Flash Baud rate", diff --git a/package.nls.pt.json b/package.nls.pt.json index 7b33fe19b..9e42635b6 100644 --- a/package.nls.pt.json +++ b/package.nls.pt.json @@ -49,6 +49,7 @@ "espIdf.getEspMatter.title": "Instale ESP-Matter", "espIdf.getEspMdf.title": "Instale ESP-MDF", "espIdf.getEspRainmaker.title": "Instale ESP-Rainmaker", + "espIdf.getEspInsights.title": "Instale ESP-Insights", "espIdf.heaptrace.title": "Rastreamento de pilha", "espIdf.idfReconfigureTask.title": "ESP-IDF: Execute a tarefa de reconfiguração idf.py", "espIdf.importProject.title": "Importar projeto ESP-IDF", @@ -121,6 +122,7 @@ "param.espMatterPath": "Caminho para localizar a estrutura ESP-Matter (ESP_MATTER_PATH)", "param.espMdfPath": "Caminho para localizar a estrutura ESP-MDF (MDF_PATH)", "param.espRainmakerPath": "Caminho para localizar a estrutura ESP-Rainmaker (RMAKER_PATH)", + "param.espInsightsPath": "Caminho para localizar a estrutura ESP-Insights (INSIGHTS_PATH)", "param.exportPaths": "Caminhos a serem anexados ao PATH", "param.exportVars": "Variáveis ​​a serem adicionadas às variáveis ​​de ambiente do sistema", "param.flashBaudRate": "Taxa de transmissão de flash ESP-IDF", diff --git a/package.nls.ru.json b/package.nls.ru.json index f4dff5ba6..833f3a9e1 100644 --- a/package.nls.ru.json +++ b/package.nls.ru.json @@ -49,6 +49,7 @@ "espIdf.getEspMatter.title": "Установите ESP-Matter", "espIdf.getEspMdf.title": "Установить ЭСП-МДФ", "espIdf.getEspRainmaker.title": "Установите ESP-Rainmaker", + "espIdf.getEspInsights.title": "Установите ESP-Insights", "espIdf.heaptrace.title": "Трассировка кучи", "espIdf.idfReconfigureTask.title": "ESP-IDF: запустить задачу перенастройки idf.py", "espIdf.importProject.title": "Импортировать проект ESP-IDF", @@ -121,6 +122,7 @@ "param.espMatterPath": "Путь для поиска структуры ESP-Matter (ESP_MATTER_PATH)", "param.espMdfPath": "Путь для поиска платформы ESP-MDF (MDF_PATH)", "param.espRainmakerPath": "Путь к инфраструктуре ESP-Rainmaker (RMAKER_PATH)", + "param.espInsightsPath": "Путь к инфраструктуре ESP-Insights (INSIGHTS_PATH)", "param.exportPaths": "Пути для добавления в PATH", "param.exportVars": "Переменные, добавляемые в переменные системной среды", "param.flashBaudRate": "Скорость передачи флэш-памяти ESP-IDF", diff --git a/package.nls.zh-CN.json b/package.nls.zh-CN.json index 986bf1bdd..ea5bcf19f 100644 --- a/package.nls.zh-CN.json +++ b/package.nls.zh-CN.json @@ -49,6 +49,7 @@ "espIdf.getEspMatter.title": "安装 ESP-Matter", "espIdf.getEspMdf.title": "安装 ESP-MDF", "espIdf.getEspRainmaker.title": "安装 ESP-Rainmaker", + "espIdf.getEspInsights.title": "安装 ESP-Insights", "espIdf.heaptrace.title": "堆跟踪", "espIdf.idfReconfigureTask.title": "ESP-IDF: 运行IDF.py重新配置任务", "espIdf.importProject.title": "导入 ESP-IDF 项目", @@ -121,6 +122,7 @@ "param.espMatterPath": "定位 ESP-Matter 框架的路径 (ESP_MATTER_PATH)", "param.espMdfPath": "定位 ESP-MDF 框架的路径 (MDF_PATH)", "param.espRainmakerPath": "定位 ESP-Rainmaker 框架的路径 (RMAKER_PATH)", + "param.espInsightsPath": "定位 ESP-Insights 框架的路径 (INSIGHTS_PATH)", "param.exportPaths": "要附加到 PATH 的路径", "param.exportVars": "要添加到系统环境变量的变量", "param.flashBaudRate": "ESP-IDF 烧录波特率", diff --git a/src/config.ts b/src/config.ts index 83c838932..9a4c3906f 100644 --- a/src/config.ts +++ b/src/config.ts @@ -58,6 +58,7 @@ export namespace ESP { "idf.espMdfPath", "idf.espRainmakerPath", "idf.espHomeKitSdkPath", + "idf.espInsightsPath", "idf.gitPath", "idf.pythonBinPath", "idf.port", diff --git a/src/espInsights/espInsightsDownload.ts b/src/espInsights/espInsightsDownload.ts new file mode 100644 index 000000000..9b5a4ca0f --- /dev/null +++ b/src/espInsights/espInsightsDownload.ts @@ -0,0 +1,40 @@ +/* + * Project: ESP-IDF VSCode Extension + * File Created: Thursday, 30th May 2024 2:07:24 pm + * Copyright 2024 Espressif Systems (Shanghai) CO LTD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Uri } from "vscode"; +import { AbstractCloning } from "../common/abstractCloning"; +import { readParameter } from "../idfConfiguration"; + +export class EspInsightsCloning extends AbstractCloning { + constructor(gitBinPath: string = "git") { + super( + "https://github.com/espressif/esp-insights.git", + "ESP-Insights", + "main", + gitBinPath, + "https://gitee.com/EspressifSystems/esp-insights.git" + ); + } +} + +export async function getEspInsights(workspace: Uri) { + const gitPath = await readParameter("idf.gitPath", workspace) || "git"; + const insightsInstaller = new EspInsightsCloning(gitPath); + await insightsInstaller.getRepository("idf.espInsightsPath", workspace); +} + diff --git a/src/extension.ts b/src/extension.ts index cb3aacf95..4b256066f 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -149,6 +149,7 @@ import { checkDebugAdapterRequirements } from "./espIdf/debugAdapter/checkPyReqs import { CDTDebugConfigurationProvider } from "./cdtDebugAdapter/debugConfProvider"; import { CDTDebugAdapterDescriptorFactory } from "./cdtDebugAdapter/server"; import { IdfReconfigureTask } from "./espIdf/reconfigure/task"; +import { getEspInsights } from "./espInsights/espInsightsDownload"; // Global variables shared by commands let workspaceRoot: vscode.Uri; @@ -782,6 +783,10 @@ export async function activate(context: vscode.ExtensionContext) { getEspRainmaker(workspaceRoot) ); + registerIDFCommand("espIdf.getEspInsights", async () => + getEspInsights(workspaceRoot) + ); + registerIDFCommand("espIdf.setMatterDevicePath", async () => { if (process.platform === "win32") { return vscode.window.showInformationMessage( @@ -3633,6 +3638,11 @@ async function getFrameworksPickItems() { workspaceRoot ) as string; + const espInsightsPathDir = idfConf.readParameter( + "idf.espInsightsPath", + workspaceRoot + ) as string; + const pickItems = []; try { const doesIdfPathExists = await utils.dirExistPromise(espIdfPath); @@ -3700,6 +3710,19 @@ async function getFrameworksPickItems() { target: espHomeKitPathDir, }); } + + const doesEspInsightsExists = await utils.dirExistPromise( + espInsightsPathDir + ); + if (doesEspInsightsExists) { + pickItems.push({ + description: "ESP-Insights", + label: vscode.l10n.t(`Use current ESP-Insights {espInsightsPathDir}`, { + espInsightsPathDir, + }), + target: espInsightsPathDir, + }); + } } catch (error) { const errMsg = error.message ? error.message : "Error getting frameworks"; Logger.errorNotify(errMsg, error); diff --git a/src/newProject/newProjectInit.ts b/src/newProject/newProjectInit.ts index af7138767..ab90e0968 100644 --- a/src/newProject/newProjectInit.ts +++ b/src/newProject/newProjectInit.ts @@ -30,6 +30,7 @@ export interface INewProjectArgs { espAdfPath: string; espMdfPath: string; espHomeKitSdkPath: string; + espInsightsPath: string; boards: IdfBoard[]; components: IComponent[]; serialPortList: string[]; @@ -82,6 +83,10 @@ export async function getNewProjectArgs( "idf.espHomeKitSdkPath", workspace ) as string; + const espInsightsPath = idfConf.readParameter( + "idf.espInsightsPath", + workspace + ) as string; let templates: { [key: string]: IExampleCategory } = {}; templates["Extension"] = getExamplesList(extensionPath, "templates"); const idfExists = await dirExistPromise(espIdfPath); @@ -104,6 +109,13 @@ export async function getNewProjectArgs( const homeKitSdkTemplates = getExamplesList(espHomeKitSdkPath); templates["ESP-HOMEKIT-SDK"] = homeKitSdkTemplates; } + const espInsightsExists = await dirExistPromise( + espInsightsPath + ); + if (espInsightsExists) { + const espInsightsTemplates = getExamplesList(espInsightsPath); + templates["ESP-Insights"] = espInsightsTemplates; + } progress.report({ increment: 50, message: "Initializing wizard..." }); return { boards: espBoards, @@ -112,6 +124,7 @@ export async function getNewProjectArgs( espIdfPath: idfExists ? espIdfPath : undefined, espMdfPath: mdfExists ? espMdfPath : undefined, espHomeKitSdkPath: homekitSdkExists ? espHomeKitSdkPath: undefined, + espInsightsPath: espInsightsExists ? espInsightsPath : undefined, serialPortList, targetList, templates, diff --git a/src/utils.ts b/src/utils.ts index 2b64a6c22..f4bbbdfce 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -946,6 +946,12 @@ export function appendIdfAndToolsToPath(curWorkspace: vscode.Uri) { ); modifiedEnv.RMAKER_PATH = rainmakerPathDir || modifiedEnv.RMAKER_PATH; + const espInsightsPathDir = idfConf.readParameter( + "idf.espInsightsPath", + curWorkspace + ); + modifiedEnv.INSIGHTS_PATH = espInsightsPathDir || modifiedEnv.INSIGHTS_PATH; + const defaultToolsPath = path.join(containerPath, ".espressif"); const toolsPath = idfConf.readParameter( "idf.toolsPath",