Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

show only valid esp idf setups #908

Merged
merged 5 commits into from
Mar 30, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ Click <kbd>F1</kbd> to show Visual studio code actions, then type **ESP-IDF** to
| Add vscode configuration folder | | |
| Build, Flash and start a monitor on your device | <kbd>⌘</kbd> <kbd>I</kbd> <kbd>D</kbd> | <kbd>Ctrl</kbd> <kbd>E</kbd> <kbd>D</kbd> |
| Build your project | <kbd>⌘</kbd> <kbd>I</kbd> <kbd>B</kbd> | <kbd>Ctrl</kbd> <kbd>E</kbd> <kbd>B</kbd> |
| Clear saved IDF setups | | |
| Configure ESP-IDF extension | | |
| Configure Paths | | |
| Configure project sdkconfig for coverage | | |
Expand Down
1 change: 1 addition & 0 deletions i18n/en/package.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"espIdf.welcome.title": "Welcome",
"espIdf.projectConfigurationEditor.title": "Open Project Configuration",
"espIdf.projectConf.title": "Select project configuration",
"espIdf.clearSavedIdfSetups.title": "Clear saved IDF setups",
"esp.component-manager.ui.show.title": "Show Component Registry",
"esp.component-manager.cli.addDependencyError": "Error encountered while adding dependency to the component",
"debug.initConfig.name": "ESP-IDF Debug: Launch",
Expand Down
1 change: 1 addition & 0 deletions i18n/es/package.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"espIdf.welcome.title": "Bienvenido/a",
"espIdf.projectConfigurationEditor.title": "Abrir configuracion de proyecto",
"espIdf.projectConf.title": "Selecciona la configuración del proyecto",
"espIdf.clearSavedIdfSetups.title": "Limpiar configuraciones de IDF guardadas",
"debug.initConfig.name": "Lanzar Depuracion ESP-IDF:",
"debug.initConfig.description": "Nueva configuración para proyectos ESP-IDF",
"param.adapterTargetName": "Target para el ESP-IDF Debug Adapter",
Expand Down
1 change: 1 addition & 0 deletions i18n/ru/package.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"espIdf.welcome.title": "Добро пожаловать",
"espIdf.projectConfigurationEditor.title": "Открыть конфигурацию проекта",
"espIdf.projectConf.title": "Выберите конфигурацию проекта",
"espIdf.clearSavedIdfSetups.title": "Очистить сохраненные настройки IDF",
"esp.component-manager.ui.show.title": "Показать реестр компонентов",
"esp.component-manager.cli.addDependencyError": "Ошибка при добавлении зависимости к компоненту",
"debug.initConfig.name": "Отладка ESP-IDF: запуск",
Expand Down
1 change: 1 addition & 0 deletions i18n/zh-CN/package.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"espIdf.welcome.title": "欢迎",
"espIdf.projectConfigurationEditor.title": "打开项目配置",
"espIdf.projectConf.title": "选择项目配置",
"espIdf.clearSavedIdfSetups.title": "清除保存的IDF设置",
"esp.component-manager.ui.show.title": "显示组件注册表",
"esp.component-manager.cli.addDependencyError": "向组件添加依赖项时遇到错误",
"debug.initConfig.name": "ESP-IDF调试 启动",
Expand Down
121 changes: 63 additions & 58 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,64 +45,64 @@
],
"activationEvents": [
"onCommand:espIdf.createFiles",
"onCommand:espIdf.addArduinoAsComponentToCurFolder",
"onCommand:espIdf.createIdfTerminal",
"onCommand:espIdf.createVsCodeFolder",
"onCommand:espIdf.setPath",
"onCommand:espIdf.selectConfTarget",
"onCommand:espIdf.configDevice",
"onCommand:espIdf.menuconfig.start",
"onCommand:espIdf.cmakeListsEditor.start",
"onCommand:espIdf.setDefaultConfig",
"onCommand:espIdf.selectPort",
"onCommand:espIdf.setTarget",
"onCommand:espIdf.buildDevice",
"onCommand:espIdf.flashDevice",
"onCommand:espIdf.flashDFU",
"onCommand:espIdf.monitorDevice",
"onCommand:espIdf.pickAWorkspaceFolder",
"onCommand:espIdf.buildFlashMonitor",
"onCommand:espIdf.cleanProject",
"onCommand:espIdf.eraseFlash",
"onCommand:espIdf.size",
"onCommand:espIdf.fullClean",
"onCommand:espIdf.apptrace",
"onCommand:espIdf.heaptrace",
"onCommand:espIdf.openOCDCommand",
"onCommand:espIdf.apptrace.archive.refresh",
"onCommand:espIdf.apptrace.archive.showReport",
"onCommand:espIdf.apptrace.customize",
"onCommand:espIdf.getExtensionPath",
"onCommand:espIdf.getOpenOcdConfigs",
"onCommand:espIdf.genCoverage",
"onCommand:espIdf.partition.table.refresh",
"onCommand:espIdf.removeCoverage",
"onCommand:espIdf.searchInEspIdfDocs",
"onCommand:espIdf.setup.start",
"onCommand:espIdf.welcome.start",
"onCommand:espIdf.examples.start",
"onCommand:esp.rainmaker.backend.connect",
"onCommand:esp.rainmaker.backend.sync",
"onCommand:espIdf.getEspAdf",
"onCommand:espIdf.getEspMdf",
"onCommand:espIdf.getEspMatter",
"onCommand:espIdf.installEspMatterPyReqs",
"onCommand:espIdf.installPyReqs",
"onCommand:esp.webview.open.partition-table",
"onCommand:espIdf.webview.nvsPartitionEditor",
"onCommand:espIdf.selectOpenOcdConfigFiles",
"onCommand:espIdf.doctorCommand",
"onCommand:espIdf.createNewComponent",
"onCommand:espIdf.ninja.summary",
"onCommand:espIdf.newProject.start",
"onCommand:espIdf.setGcovConfig",
"onCommand:esp.component-manager.ui.show",
"onCommand:espIdf.monitorQemu",
"onView:idfAppTracer",
"onView:idfAppTraceArchive",
"onView:idfPartitionExplorer",
"onView:espRainmaker",
"onView:idfComponents",
"onCommand:espIdf.addArduinoAsComponentToCurFolder",
"onCommand:espIdf.createIdfTerminal",
"onCommand:espIdf.createVsCodeFolder",
"onCommand:espIdf.setPath",
"onCommand:espIdf.selectConfTarget",
"onCommand:espIdf.configDevice",
"onCommand:espIdf.menuconfig.start",
"onCommand:espIdf.cmakeListsEditor.start",
"onCommand:espIdf.setDefaultConfig",
"onCommand:espIdf.selectPort",
"onCommand:espIdf.setTarget",
"onCommand:espIdf.buildDevice",
"onCommand:espIdf.flashDevice",
"onCommand:espIdf.flashDFU",
"onCommand:espIdf.monitorDevice",
"onCommand:espIdf.pickAWorkspaceFolder",
"onCommand:espIdf.buildFlashMonitor",
"onCommand:espIdf.cleanProject",
"onCommand:espIdf.eraseFlash",
"onCommand:espIdf.size",
"onCommand:espIdf.fullClean",
"onCommand:espIdf.apptrace",
"onCommand:espIdf.heaptrace",
"onCommand:espIdf.openOCDCommand",
"onCommand:espIdf.apptrace.archive.refresh",
"onCommand:espIdf.apptrace.archive.showReport",
"onCommand:espIdf.apptrace.customize",
"onCommand:espIdf.getExtensionPath",
"onCommand:espIdf.getOpenOcdConfigs",
"onCommand:espIdf.genCoverage",
"onCommand:espIdf.partition.table.refresh",
"onCommand:espIdf.removeCoverage",
"onCommand:espIdf.searchInEspIdfDocs",
"onCommand:espIdf.setup.start",
"onCommand:espIdf.welcome.start",
"onCommand:espIdf.examples.start",
"onCommand:esp.rainmaker.backend.connect",
"onCommand:esp.rainmaker.backend.sync",
"onCommand:espIdf.getEspAdf",
"onCommand:espIdf.getEspMdf",
"onCommand:espIdf.getEspMatter",
"onCommand:espIdf.installEspMatterPyReqs",
"onCommand:espIdf.installPyReqs",
"onCommand:esp.webview.open.partition-table",
"onCommand:espIdf.webview.nvsPartitionEditor",
"onCommand:espIdf.selectOpenOcdConfigFiles",
"onCommand:espIdf.doctorCommand",
"onCommand:espIdf.createNewComponent",
"onCommand:espIdf.ninja.summary",
"onCommand:espIdf.newProject.start",
"onCommand:espIdf.setGcovConfig",
"onCommand:esp.component-manager.ui.show",
"onCommand:espIdf.monitorQemu",
"onView:idfAppTracer",
"onView:idfAppTraceArchive",
"onView:idfPartitionExplorer",
"onView:espRainmaker",
"onView:idfComponents",
"workspaceContains:**/project_description.json",
"workspaceContains:**/sdkconfig",
"workspaceContains:**/CMakeLists.txt"
Expand Down Expand Up @@ -1161,6 +1161,11 @@
"command": "espIdf.projectConf",
"title": "%espIdf.projectConf.title%",
"category": "ESP-IDF"
},
{
"command": "espIdf.clearSavedIdfSetups",
"title": "%espIdf.clearSavedIdfSetups.title%",
"category": "ESP-IDF"
}
],
"breakpoints": [
Expand Down
1 change: 1 addition & 0 deletions package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"espIdf.monitorQemu.title": "Monitor QEMU device",
"espIdf.qemuDebug.title": "Launch QEMU debug session",
"espIdf.createDevContainer.title": "Add docker container configuration",
"espIdf.clearSavedIdfSetups.title": "Clear saved IDF setups",
"espIdf.partition.table.refresh.title": "Refresh partition table",
"espIdf.flashBinaryToPartition.title": "Flash binary to partition...",
"espIdf.setMatterDevicePath.title": "Set ESP-MATTER Device Path (ESP_MATTER_DEVICE_PATH)",
Expand Down
1 change: 1 addition & 0 deletions schema.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@
"espIdf.customTask.title",
"espIdf.projectConfigurationEditor.title",
"espIdf.projectConf.title",
"espIdf.clearSavedIdfSetups.title",
"debug.initConfig.name",
"debug.initConfig.description",
"param.adapterTargetName",
Expand Down
5 changes: 5 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ import { PeripheralBaseNode } from "./espIdf/debugAdapter/nodes/base";
import { ExtensionConfigStore } from "./common/store";
import { projectConfigurationPanel } from "./project-conf/projectConfPanel";
import { ProjectConfigStore } from "./project-conf";
import { clearPreviousIdfSetups } from "./setup/existingIdfSetups";

// Global variables shared by commands
let workspaceRoot: vscode.Uri;
Expand Down Expand Up @@ -805,6 +806,10 @@ export async function activate(context: vscode.ExtensionContext) {
idfConf.chooseConfigurationTarget();
});

registerIDFCommand("espIdf.clearSavedIdfSetups", async () => {
await clearPreviousIdfSetups();
});

registerIDFCommand("espIdf.setPath", () => {
PreCheck.perform([webIdeCheck], async () => {
const selectFrameworkMsg = locDic.localize(
Expand Down
4 changes: 4 additions & 0 deletions src/setup/SetupPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import { installIdfGit, installIdfPython } from "./embedGitPy";
import { getOpenOcdRules } from "./addOpenOcdRules";
import { checkSpacesInPath } from "../utils";
import { useIdfSetupSettings } from "./setupValidation/espIdfSetup";
import { clearPreviousIdfSetups } from "./existingIdfSetups";

const locDic = new LocDictionary("SetupPanel");

Expand Down Expand Up @@ -291,6 +292,9 @@ export class SetupPanel {
await this.getOpenOcdRulesPath();
}
break;
case "cleanIdfSetups":
await clearPreviousIdfSetups();
break;
default:
break;
}
Expand Down
22 changes: 19 additions & 3 deletions src/setup/existingIdfSetups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ import { ESP } from "../config";
import { getEspIdfFromCMake } from "../utils";
import { IdfSetup } from "../views/setup/types";
import { getIdfMd5sum, loadEspIdfJson } from "./espIdfJson";
import { checkIdfSetup } from "./setupValidation/espIdfSetup";

export function getPreviousIdfSetups() {
export async function getPreviousIdfSetups() {
const setupKeys = ESP.GlobalConfiguration.store.getIdfSetupKeys();
const idfSetups: IdfSetup[] = [];
for (let idfSetupKey of setupKeys) {
Expand All @@ -30,12 +31,22 @@ export function getPreviousIdfSetups() {
undefined
);
if (idfSetup) {
idfSetup.isValid = await checkIdfSetup(idfSetup);
idfSetup.version = await getEspIdfFromCMake(idfSetup.idfPath);
idfSetups.push(idfSetup);
}
}
return idfSetups;
}

export async function clearPreviousIdfSetups() {
const setupKeys = ESP.GlobalConfiguration.store.getIdfSetupKeys();
for (let idfSetupKey of setupKeys) {
ESP.GlobalConfiguration.store.clear(idfSetupKey);
}
ESP.GlobalConfiguration.store.clear(ESP.GlobalConfiguration.IDF_SETUPS);
}

export async function createIdfSetup(
idfPath: string,
toolsPath: string,
Expand All @@ -51,7 +62,9 @@ export async function createIdfSetup(
toolsPath,
python: pythonPath,
version: idfVersion,
isValid: false
};
newIdfSetup.isValid = await checkIdfSetup(newIdfSetup);
addIdfSetup(newIdfSetup);
}

Expand All @@ -73,14 +86,17 @@ export async function loadIdfSetupsFromEspIdfJson(toolsPath: string) {
) {
let idfSetups: IdfSetup[] = [];
for (let idfInstalledKey of Object.keys(espIdfJson.idfInstalled)) {
idfSetups.push({
let setupConf: IdfSetup = {
id: idfInstalledKey,
idfPath: espIdfJson.idfInstalled[idfInstalledKey].path,
gitPath: espIdfJson.gitPath,
python: espIdfJson.idfInstalled[idfInstalledKey].python,
version: espIdfJson.idfInstalled[idfInstalledKey].version,
toolsPath: toolsPath,
});
isValid: false
} as IdfSetup;
setupConf.isValid = await checkIdfSetup(setupConf);
idfSetups.push(setupConf);
}
return idfSetups;
}
Expand Down
2 changes: 1 addition & 1 deletion src/setup/setupInit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export async function getSetupInitialValues(
const espIdfTagsList = await getEspIdfTags();
progress.report({ increment: 10, message: "Getting Python versions..." });
const pythonVersions = await getPythonList(extensionPath);
const idfSetups = getPreviousIdfSetups();
const idfSetups = await getPreviousIdfSetups();
const setupInitArgs = {
espIdfVersionsList,
espIdfTagsList,
Expand Down
3 changes: 3 additions & 0 deletions src/setup/setupValidation/espIdfSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ export async function useIdfSetupSettings(

export async function checkIdfSetup(setupConf: IdfSetup) {
try {
if (!setupConf.idfPath) {
return false;
}
const doesIdfPathExists = await pathExists(setupConf.idfPath);
if (!doesIdfPathExists) {
return false;
Expand Down
56 changes: 43 additions & 13 deletions src/views/setup/ExistingSetup.vue
Original file line number Diff line number Diff line change
@@ -1,35 +1,65 @@
<template>
<div class="centerize notification">
<div class="notification">
<div class="field install-btn">
<div class="control">
<button
@click="cleanIdfSetups"
class="button"
data-config-id="start-install-btn"
>
Clean IDF Setups
</button>
</div>
</div>
<div
class="notification install-choice"
v-for="(prevSetup, i) in idfSetups"
:key="prevSetup.id"
:data-config-id="prevSetup.idfPath"
@click="useIdfSetup(i)"
@click="goTo('/autoinstall', setupMode.express)"
>
<label :for="prevSetup.id" class="subtitle">
{{ prevSetup.idfPath }}</label
<label class="subtitle"> Search ESP-IDF in system...</label>
</div>
<div v-for="(prevSetup, i) in idfSetups" :key="prevSetup.id" class="my-1">
<div
class="notification install-choice"
v-show="prevSetup.isValid"
:data-config-id="prevSetup.idfPath"
@click="useIdfSetup(i)"
>
<p>IDF Version {{ prevSetup.version }}</p>
<p>Python: {{ prevSetup.python }}</p>
<p>IDF Tools Path: {{ prevSetup.toolsPath }}</p>
<p>Git path: {{ prevSetup.gitPath }}</p>
<label :for="prevSetup.id" class="subtitle">
{{ prevSetup.idfPath }}</label
>
<p>IDF Version: {{ prevSetup.version }}</p>
<p>Python path: {{ prevSetup.python }}</p>
<p>IDF Tools path: {{ prevSetup.toolsPath }}</p>
<p>Git path: {{ prevSetup.gitPath }}</p>
brianignacio5 marked this conversation as resolved.
Show resolved Hide resolved
</div>
</div>
</div>
</template>

<script lang="ts">
import { Component, Vue } from "vue-property-decorator";
import { Action, State } from "vuex-class";
import { IdfSetup } from "./types";
import { Action, Mutation, State } from "vuex-class";
import { IdfSetup, SetupMode } from "./types";
import { router } from "./main";

@Component
export default class existingSetup extends Vue {
@State("idfSetups") private storeIdfSetups: IdfSetup[];
@Action useIdfSetup: (id: number) => void;
@Action cleanIdfSetups: () => void;
@Mutation setSetupMode: (mode: SetupMode) => void;

get idfSetups() {
return this.storeIdfSetups;
}

get setupMode() {
return SetupMode;
}

goTo(route: string, setupMode: SetupMode) {
router.push(route);
this.setSetupMode(setupMode);
}
}
</script>
2 changes: 1 addition & 1 deletion src/views/setup/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
<label for="existing" class="subtitle" data-config-id="existing-setup"
>USE EXISTING SETUP</label
>
<p>Select existing ESP-IDF setup saved in the extension.</p>
<p>Select existing ESP-IDF setup saved in the extension or find ESP-IDF in your system.</p>
</div>
</div>
</div>
Expand Down
Loading