Skip to content

Commit

Permalink
add esp-matter support (#547)
Browse files Browse the repository at this point in the history
* add esp-matter support

* add esp-matter to examples

* add esp-matter bootstrap task after cloning

* fix boostrap task definition

* add esp-matter to doctor cmd output

* add use existing repository

* fix bootstrap task definition

* fix ui test ci

* update build ui test
  • Loading branch information
brianignacio5 authored Jul 15, 2022
1 parent fd2cac0 commit 8d0e530
Show file tree
Hide file tree
Showing 23 changed files with 258 additions and 25 deletions.
2 changes: 2 additions & 0 deletions docs/HARDWARE_SUPPORT.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ In addition to ESP-IDF chips, there are several boards configurations files impl
- [Espressif Audio Development Framework (ESP-ADF)](https://github.com/espressif/esp-adf) is the official audio development framework for the ESP32 and ESP32-S2 SoCs. The **Install ESP-ADF** will clone ESP-ADF to a selected directory and set `idf.espAdfPath` (`idf.espAdfPathWin` in Windows) configuration setting.

- [Espressif Mesh Development Framework (ESP-MDF)](https://github.com/espressif/esp-mdf) to develop with the [ESP-WIFI-MESH](https://docs.espressif.com/projects/esp-idf/en/stable/api-guides/mesh.html) networking protocol. The **Install ESP-MDF** will clone ESP-MDF to a selected directory and set `idf.espMdfPath` (`idf.espMdfPathWin` in Windows) configuration setting.

- [Espressif Matter Framework (ESP-Matter)](https://github.com/espressif/esp-matter) to develop with the [Matter](https://buildwithmatter.com/) unified IP-based connectivity protocol. The **Install ESP-Matter** will clone ESP-Matter to a selected directory and set `idf.espMatterPath` (`idf.espMatterPathWin` in Windows) configuration setting.
15 changes: 9 additions & 6 deletions docs/SETTINGS.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,18 @@ These settings are specific to [Application Log Tracing](./HEAP_TRACING.md).

These settings allow to support additional frameworks together with ESP-IDF

| Setting ID | Description |
| ------------------- | ------------------------------------------------------ |
| `idf.espAdfPath` | Path to locate ESP-ADF framework (ADF_PATH) |
| `idf.espAdfPathWin` | Path to locate ESP-ADF framework in Windows (ADF_PATH) |
| `idf.espMdfPath` | Path to locate ESP-MDF framework (MDF_PATH) |
| `idf.espMdfPathWin` | Path to locate ESP-MDF framework in Windows (MDF_PATH) |
| Setting ID | Description |
| ---------------------- | ---------------------------------------------------------------- |
| `idf.espAdfPath` | Path to locate ESP-ADF framework (ADF_PATH) |
| `idf.espAdfPathWin` | Path to locate ESP-ADF framework in Windows (ADF_PATH) |
| `idf.espMdfPath` | Path to locate ESP-MDF framework (MDF_PATH) |
| `idf.espMdfPathWin` | Path to locate ESP-MDF framework in Windows (MDF_PATH) |
| `idf.espMatterPath` | Path to locate ESP-Matter framework (ESP_MATTER_PATH) |
| `idf.espMatterPathWin` | Path to locate ESP-Matter framework in Windows (ESP_MATTER_PATH) |

The **Install ESP-ADF** command will clone ESP-ADF and set `idf.espAdfPath` (`idf.espAdfPathWin` in Windows).
The **Install ESP-MDF** command will clone ESP-MDF and set `idf.espMdfPath` (`idf.espMdfPathWin` in Windows).
The **Install ESP-Matter** command will clone ESP-MDF and set `idf.espMatterPath` (`idf.espMatterPathWin` in Windows).

The **Show Examples Projects** command allows you create a new project using one of the examples in ESP-IDF, ESP-ADF or ESP-MDF directory if related configuration settings are set.

Expand Down
2 changes: 2 additions & 0 deletions i18n/en/package.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"espIdf.searchInEspIdfDocs.title": "ESP-IDF: Search in documentation...",
"espIdf.getEspAdf.title": "ESP-IDF: Install ESP-ADF",
"espIdf.getEspMdf.title": "ESP-IDF: Install ESP-MDF",
"espIdf.getEspMatter.title": "ESP-IDF: Install ESP-Matter",
"espIdf.installPyReqs.title": "ESP-IDF: Install ESP-IDF extension Python Packages",
"espIdf.openDocUrl.title": "ESP-IDF: Open ESP-IDF Documentation...",
"espIdf.doctorCommand.title": "ESP-IDF: Doctor command",
Expand Down Expand Up @@ -66,6 +67,7 @@
"param.espIdfPath": "Path to locate ESP-IDF framework (IDF_PATH)",
"param.espAdfPath": "Path to locate ESP-ADF framework (ADF_PATH)",
"param.espMdfPath": "Path to locate ESP-MDF framework (MDF_PATH)",
"param.espMatterPath": "Path to locate ESP-Matter framework (ESP_MATTER_PATH)",
"param.toolsPath": "Path to locate ESP-IDF Tools (IDF_TOOLS_PATH)",
"param.exportPaths": "Paths to be appended to PATH",
"param.exportVars": "Variables to be added to system environment variables",
Expand Down
2 changes: 2 additions & 0 deletions i18n/es/package.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"espIdf.searchInEspIdfDocs.title": "ESP-IDF: Buscar en la documentación...",
"espIdf.getEspAdf.title": "ESP-IDF: Instalar ESP-ADF",
"espIdf.getEspMdf.title": "ESP-IDF: Instalar ESP-MDF",
"espIdf.getEspMatter.title": "ESP-IDF: Instalar ESP-Matter",
"espIdf.installPyReqs.title": "ESP-IDF: Instalar paquetes Python para extensión ESP-IDF",
"espIdf.openDocUrl.title": "ESP-IDF: Abrir documentación ESP-IDF...",
"espIdf.doctorCommand.title": "ESP-IDF: Comando Doctor",
Expand Down Expand Up @@ -70,6 +71,7 @@
"param.espIdfPath": "Ruta del entorno de trabajo ESP-IDF (IDF_PATH)",
"param.espAdfPath": "Ruta del entorno de trabajo ESP-ADF (ADF_PATH)",
"param.espMdfPath": "Ruta del entorno de trabajo ESP-MDF (MDF_PATH)",
"param.espMatterPath": "Ruta del entorno del trabajo ESP-Matter (ESP_MATTER_PATH)",
"param.cmakeCompilerArgs": "Argumentos para la tarea de compilación CMake",
"param.ninjaArgs": "Argumentos para la tarea de construcción Ninja",
"param.useIDFKConfigStyle": "Habilitar/Deshabilitar validación de estilo ESP-IDF para archivos Kconfig",
Expand Down
2 changes: 2 additions & 0 deletions i18n/ru/package.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"espIdf.searchInEspIdfDocs.title": "ESP-IDF: Искать в документации...",
"espIdf.getEspAdf.title": "ESP-IDF: Установить ESP-ADF",
"espIdf.getEspMdf.title": "ESP-IDF: Установить ESP-MDF",
"espIdf.getEspMatter.title": "ESP-IDF: Установить ESP-Matter",
"espIdf.installPyReqs.title": "ESP-IDF: Установите пакеты Python расширения ESP-IDF",
"espIdf.openDocUrl.title": "ESP-IDF: Открыть документацию ...",
"espIdf.doctorCommand.title": "ESP-IDF: Команда врача",
Expand Down Expand Up @@ -66,6 +67,7 @@
"param.espIdfPath": "Путь фреймворкa ESP-IDF (IDF_PATH)",
"param.espAdfPath": "Путь фреймворка ESP-ADF (ADF_PATH)",
"param.espMdfPath": "Путь фреймворка ESP-MDF (MDF_PATH)",
"param.espMatterPath": "Путь фреймворка ESP-Matter (ESP_MATTER_PATH)",
"param.toolsPath": "Путь инструментов ESP-IDF (IDF_TOOLS_PATH)",
"param.exportPaths": "Пути, добавляемые к PATH",
"param.exportVars": "Переменные, которые нужно добавить к системным переменным окружения",
Expand Down
2 changes: 2 additions & 0 deletions i18n/zh-CN/package.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"espIdf.getCoverageReport.title": "ESP-IDF: 获取项目的 HTML 覆盖率报告",
"espIdf.getEspAdf.title": "ESP-IDF: 安装 ESP-ADF",
"espIdf.getEspMdf.title": "ESP-IDF: 安装 ESP-MDF",
"espIdf.getEspMatter.title": "ESP-IDF: 安装 ESP-Matter",
"espIdf.installPyReqs.title": "ESP-IDF: 安装 ESP-IDF 扩展 Python 包",
"espIdf.openDocUrl.title": "ESP-IDF: 打开 ESP-IDF 文档...",
"espIdf.doctorCommand.title": "ESP-IDF: 诊断命令",
Expand Down Expand Up @@ -70,6 +71,7 @@
"param.espIdfPath": "IDF_PATH 的路径",
"param.espAdfPath": "ADF_PATH 的路径",
"param.espMdfPath": "MDF_PATH 的路径",
"param.espMatterPath": "ESP_MATTER_PATH 的路径",
"param.useIDFKConfigStyle": "启用/禁用 ESP-IDF Kconfig 文件的样式验证",
"param.showOnboardingOnInit": "在扩展激活时显示 ESP-IDF 配置窗口",
"param.cmakeCompilerArgs": "CMake 编译任务的参数",
Expand Down
17 changes: 17 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
"onCommand:esp.rainmaker.backend.sync",
"onCommand:espIdf.getEspAdf",
"onCommand:espIdf.getEspMdf",
"onCommand:espIdf.getEspMatter",
"onCommand:espIdf.installPyReqs",
"onCommand:esp.webview.open.partition-table",
"onCommand:espIdf.webview.nvsPartitionEditor",
Expand Down Expand Up @@ -363,6 +364,12 @@
"description": "%param.espMdfPath%",
"scope": "resource"
},
"idf.espMatterPath": {
"type": "string",
"default": "${env:ESP_MATTER_PATH}",
"description": "%param.espMatterPath%",
"scope": "resource"
},
"idf.toolsPath": {
"type": "string",
"default": "${env:IDF_TOOLS_PATH}",
Expand All @@ -387,6 +394,12 @@
"description": "%param.espMdfPath%",
"scope": "resource"
},
"idf.espMatterPathWin": {
"type": "string",
"default": "${env:ESP_MATTER_PATH}",
"description": "%param.espMatterPath%",
"scope": "resource"
},
"idf.toolsPathWin": {
"type": "string",
"default": "${env:IDF_TOOLS_PATH}",
Expand Down Expand Up @@ -973,6 +986,10 @@
"command": "espIdf.getEspMdf",
"title": "%espIdf.getEspMdf.title%"
},
{
"command": "espIdf.getEspMatter",
"title": "%espIdf.getEspMatter.title%"
},
{
"command": "espIdf.installPyReqs",
"title": "%espIdf.installPyReqs.title%"
Expand Down
2 changes: 2 additions & 0 deletions package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"espIdf.searchInEspIdfDocs.title": "ESP-IDF: Search in documentation...",
"espIdf.getEspAdf.title": "ESP-IDF: Install ESP-ADF",
"espIdf.getEspMdf.title": "ESP-IDF: Install ESP-MDF",
"espIdf.getEspMatter.title": "ESP-IDF: Install ESP-Matter",
"espIdf.installPyReqs.title": "ESP-IDF: Install ESP-IDF extension Python Packages",
"espIdf.openDocUrl.title": "ESP-IDF: Open ESP-IDF Documentation...",
"espIdf.doctorCommand.title": "ESP-IDF: Doctor command",
Expand Down Expand Up @@ -66,6 +67,7 @@
"param.espIdfPath": "Path to locate ESP-IDF framework (IDF_PATH)",
"param.espAdfPath": "Path to locate ESP-ADF framework (ADF_PATH)",
"param.espMdfPath": "Path to locate ESP-MDF framework (MDF_PATH)",
"param.espMatterPath": "Path to locate ESP-Matter framework (ESP_MATTER_PATH)",
"param.toolsPath": "Path to locate ESP-IDF Tools (IDF_TOOLS_PATH)",
"param.exportPaths": "Paths to be appended to PATH",
"param.exportVars": "Variables to be added to system environment variables",
Expand Down
2 changes: 2 additions & 0 deletions schema.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
"espIdf.getCoverageReport.title",
"espIdf.getEspAdf.title",
"espIdf.getEspMdf.title",
"espIdf.getEspMatter.title",
"espIdf.installPyReqs.title",
"espIdf.openDocUrl.title",
"espIdf.clearDocsSearchResult.title",
Expand Down Expand Up @@ -141,6 +142,7 @@
"param.espIdfPath",
"param.espAdfPath",
"param.espMdfPath",
"param.espMatterPath",
"param.toolsPath",
"param.exportPaths",
"param.exportVars",
Expand Down
14 changes: 13 additions & 1 deletion src/common/abstractCloning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,19 @@ export class AbstractCloning {
target: "current",
},
{ label: "Choose a container directory...", target: "another" },
{
label: "Use existing repository",
target: "existing",
},
],
{ placeHolder: `Select a directory to save ${this.name}` }
);
if (!installDir) {
return;
}

let installDirPath: string;
if (installDir.target === "another") {
if (installDir.target === "another" || installDir.target === "existing") {
const chosenFolder = await window.showOpenDialog({
canSelectFolders: true,
canSelectFiles: false,
Expand All @@ -174,6 +179,13 @@ export class AbstractCloning {
}
installDirPath = toolsDir;
}

if (installDir.target === "existing") {
const target = idfConf.readParameter("idf.saveScope");
await idfConf.writeParameter(configurationId, installDirPath, target);
Logger.infoNotify(`${this.name} has been installed`);
return;
}
const resultFolder = basename(this.GITHUB_REPO).replace(".git", "");
const resultingPath = join(installDirPath, resultFolder);
const doesResultingPathExists = await dirExistPromise(resultingPath);
Expand Down
1 change: 1 addition & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export namespace ESP {
export const platformDepConfigurations: string[] = [
"idf.espIdfPath",
"idf.espAdfPath",
"idf.espMatterPath",
"idf.espMdfPath",
"idf.gitPath",
"idf.pythonBinPath",
Expand Down
123 changes: 123 additions & 0 deletions src/espMatter/espMatterDownload.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
/*
* Project: ESP-IDF VSCode Extension
* File Created: Monday, 18th October 2021 2:27:27 pm
* Copyright 2021 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 { pathExists } from "fs-extra";
import { join } from "path";
import {
ShellExecution,
ShellExecutionOptions,
TaskPanelKind,
TaskPresentationOptions,
TaskRevealKind,
TaskScope,
} from "vscode";
import { AbstractCloning } from "../common/abstractCloning";
import { readParameter } from "../idfConfiguration";
import { Logger } from "../logger/logger";
import { TaskManager } from "../taskManager";

export class EspMatterCloning extends AbstractCloning {
public static isBuildingGn: boolean;
public currWorkspace: string;
constructor(gitBinPath: string = "git") {
super(
"https://github.com/espressif/esp-matter.git",
"ESP-MATTER",
"master",
gitBinPath
);
}

public getShellExecution(
bootstrapFilePath: string,
shellOptions: ShellExecutionOptions
) {
return new ShellExecution(`source ${bootstrapFilePath}`, shellOptions);
}

public async startBootstrap() {
if (EspMatterCloning.isBuildingGn) {
throw new Error("ALREADY_BUILDING");
}
const matterPathDir = readParameter("idf.espMatterPath");
const espMatterPathExists = await pathExists(matterPathDir);
if (!espMatterPathExists) {
return;
}
const workingDir = join(
matterPathDir,
"connectedhomeip",
"connectedhomeip"
);
const bootstrapFilePath = join(workingDir, "scripts", "bootstrap.sh");
const bootstrapFilePathExists = await pathExists(bootstrapFilePath);
if (!bootstrapFilePathExists) {
return;
}
EspMatterCloning.isBuildingGn = true;
const shellOptions: ShellExecutionOptions = {
cwd: workingDir,
};
const buildGnExec = this.getShellExecution(bootstrapFilePath, shellOptions);
const isSilentMode = readParameter("idf.notificationSilentMode");
const showTaskOutput = isSilentMode
? TaskRevealKind.Always
: TaskRevealKind.Silent;

const matterBootstrapPresentationOptions = {
reveal: showTaskOutput,
showReuseMessage: false,
clear: true,
panel: TaskPanelKind.Dedicated,
} as TaskPresentationOptions;

TaskManager.addTask(
{
type: "esp-idf",
command: "ESP-Matter Bootstrap",
taskId: "idf-bootstrap-task",
},
TaskScope.Workspace,
"ESP-Matter Bootstrap",
buildGnExec,
["espIdf"],
matterBootstrapPresentationOptions
);
}
}

export async function getEspMatter() {
const gitPath = (await readParameter("idf.gitPath")) || "/usr/bin/git";
const espMatterInstaller = new EspMatterCloning(gitPath);
try {
await espMatterInstaller.getRepository("idf.espMatterPath");
await espMatterInstaller.startBootstrap();
await TaskManager.runTasks();
EspMatterCloning.isBuildingGn = false;
} catch (error) {
const msg =
error && error.message ? error.message : "Error bootstrapping esp-matter";
if (msg === "ALREADY_BUILDING") {
return Logger.errorNotify(
"ESP-Matter bootstrap is already running!",
error
);
}
Logger.errorNotify(msg, error);
EspMatterCloning.isBuildingGn = false;
}
}
14 changes: 11 additions & 3 deletions src/examples/ExamplesPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { Logger } from "../logger/logger";
import * as utils from "../utils";
import { createExamplesHtml } from "./createExamplesHtml";
import { ESP } from "../config";
import { getExamplesList } from "./Example";
import { getExamplesList, IExampleCategory } from "./Example";

const locDic = new LocDictionary("ExamplesPanel");

Expand Down Expand Up @@ -171,15 +171,23 @@ export class ExamplesPlanel {
}

private async obtainExamplesList(targetFrameworkFolder: string) {
const exampleListInfo = getExamplesList(targetFrameworkFolder);
const exampleListInfo: IExampleCategory = getExamplesList(
targetFrameworkFolder
);
this.panel.webview.postMessage({
command: "set_examples_path",
example_list: exampleListInfo,
});

const selectedExample = exampleListInfo.examples.length
? exampleListInfo.examples[0]
: exampleListInfo.subcategories.length
? exampleListInfo.subcategories[0]
: undefined;

this.panel.webview.postMessage({
command: "set_initial_example",
selected_example: exampleListInfo[0],
selected_example: selectedExample,
});
}
}
Loading

0 comments on commit 8d0e530

Please sign in to comment.