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

Switch ESP-IDF versions #1173

Merged
merged 7 commits into from
Apr 25, 2024
Merged
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
1 change: 1 addition & 0 deletions i18n/en/package.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@
"espIdf.efuse.clearResults.title": "Clear eFuse Summary",
"espIdf.jtag_flash.title": "Flash (with JTag)",
"espIdf.selectFlashMethodAndFlash.title": "Select Flash Method",
"espIdf.selectCurrentIdfVersion.title": "Select Current ESP-IDF Version",
"idf.flashType.description": "Device flash method, UART or JTag",
"openocd.tcl.host.description": "Host for openocd tcl connection",
"openocd.tcl.port.description": "Port for openocd tcl connection",
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 @@ -150,6 +150,7 @@
"espIdf.efuse.clearResults.title": "Limpiar el resumen de eFuse",
"espIdf.jtag_flash.title": "Flash (con JTag)",
"espIdf.selectFlashMethodAndFlash.title": "Seleccione el método de programar",
"espIdf.selectCurrentIdfVersion.title": "Seleccione la versión ESP-IDF a usar",
"idf.flashType.description": "Método de flash del dispositivo, UART o JTag",
"openocd.tcl.host.description": "Anfitrión para conexión tcl openocd",
"openocd.tcl.port.description": "Puerto para conexión tcl openocd",
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 @@ -150,6 +150,7 @@
"espIdf.efuse.clearResults.title": "Очистить сводку eFuse",
"espIdf.jtag_flash.title": "Прошить (через JTag)",
"espIdf.selectFlashMethodAndFlash.title": "Выбрать метод прошивки",
"espIdf.selectCurrentIdfVersion.title": "Выберите текущую версию ESP-IDF",
"idf.flashType.description": "Метод прошивки устройства, UART или JTag",
"openocd.tcl.host.description": "Хост для подключения openocd tcl",
"openocd.tcl.port.description": "Порт для подключения openocd tcl",
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 @@ -150,6 +150,7 @@
"espIdf.efuse.clearResults.title": "清除 eFuse 摘要",
"espIdf.jtag_flash.title": "JTag 烧录",
"espIdf.selectFlashMethodAndFlash.title": "选择烧录方式烧录",
"espIdf.selectCurrentIdfVersion.title": "选择当前ESP-IDF版本",
"idf.flashType.description": "设备烧录方式,UART 或 JTag",
"openocd.tcl.host.description": "OpenOCD TCL 主机",
"openocd.tcl.port.description": "OpenOCD TCL 端口",
Expand Down
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1378,6 +1378,11 @@
"command": "espIdf.createSbom",
"title": "%espIdf.createSbom.title%",
"category": "ESP-IDF"
},
{
"command": "espIdf.selectCurrentIdfVersion",
"title": "%espIdf.selectCurrentIdfVersion.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 @@ -150,6 +150,7 @@
"espIdf.efuse.clearResults.title": "Clear eFuse Summary",
"espIdf.jtag_flash.title": "Flash (with JTag)",
"espIdf.selectFlashMethodAndFlash.title": "Select Flash Method",
"espIdf.selectCurrentIdfVersion.title": "Select Current ESP-IDF Version",
"idf.flashType.description": "Device flash method, UART or JTag",
"openocd.tcl.host.description": "Host for openocd tcl connection",
"openocd.tcl.port.description": "Port for openocd tcl connection",
Expand Down
1 change: 1 addition & 0 deletions schema.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@
"espIdf.efuse.clearResults.title",
"espIdf.jtag_flash.title",
"espIdf.selectFlashMethodAndFlash.title",
"espIdf.selectCurrentIdfVersion.title",
"idf.flashType.description",
"openocd.tcl.host.description",
"openocd.tcl.port.description",
Expand Down
7 changes: 5 additions & 2 deletions src/checkExtensionSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ import { useIdfSetupSettings } from "./setup/setupValidation/espIdfSetup";

export async function checkExtensionSettings(
extensionPath: string,
workspace: vscode.Uri
workspace: vscode.Uri,
espIdfStatusBar: vscode.StatusBarItem
) {
const showSetupWindow = readParameter("idf.showOnboardingOnInit") as boolean;
if (!showSetupWindow) {
Expand Down Expand Up @@ -62,6 +63,7 @@ export async function checkExtensionSettings(
progress,
workspace
);
setupArgs.espIdfStatusBar = espIdfStatusBar;
if (setupArgs.existingIdfSetups && setupArgs.existingIdfSetups.length) {
progress.report({
increment: 5,
Expand All @@ -85,7 +87,8 @@ export async function checkExtensionSettings(
await useIdfSetupSettings(
selectedSetup.target,
confTarget,
workspace
workspace,
espIdfStatusBar
);
} else if (
typeof process.env.WEB_IDE === "undefined" &&
Expand Down
31 changes: 27 additions & 4 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ import { getFileList, getTestComponents } from "./espIdf/unitTest/utils";
import { saveDefSdkconfig } from "./espIdf/menuconfig/saveDefConfig";
import { createSBOM, installEspSBOM } from "./espBom";
import { getEspHomeKitSdk } from "./espHomekit/espHomekitDownload";
import { getCurrentIdfSetup, selectIdfSetup } from "./versionSwitcher";

// Global variables shared by commands
let workspaceRoot: vscode.Uri;
Expand Down Expand Up @@ -276,7 +277,7 @@ export async function activate(context: vscode.ExtensionContext) {
// Create a status bar item with current workspace

// Status Bar Item with common commands
statusBarItems = createCmdsStatusBarItems();
statusBarItems = await createCmdsStatusBarItems();

// Create Kconfig Language Server Client
KconfigLangClient.startKconfigLangServer(context);
Expand Down Expand Up @@ -804,6 +805,15 @@ export async function activate(context: vscode.ExtensionContext) {
);
});

registerIDFCommand("espIdf.selectCurrentIdfVersion", () => {
PreCheck.perform([webIdeCheck, openFolderCheck], async () => {
const currentIdfSetup = await selectIdfSetup(
workspaceRoot,
statusBarItems["currentIdfVersion"]
);
});
});

registerIDFCommand("espIdf.customTask", async () => {
try {
const customTask = new CustomTask(workspaceRoot);
Expand Down Expand Up @@ -1222,7 +1232,7 @@ export async function activate(context: vscode.ExtensionContext) {
workspaceRoot
) as boolean;
if (enableStatusBar) {
statusBarItems = createCmdsStatusBarItems();
statusBarItems = await createCmdsStatusBarItems();
} else if (!enableStatusBar) {
for (let statusItem in statusBarItems) {
statusBarItems[statusItem].dispose();
Expand Down Expand Up @@ -1959,6 +1969,7 @@ export async function activate(context: vscode.ExtensionContext) {
progress,
workspaceRoot
);
setupArgs.espIdfStatusBar = statusBarItems["currentIdfVersion"];
SetupPanel.createOrShow(context, setupArgs);
} catch (error) {
Logger.errorNotify(error.message, error);
Expand Down Expand Up @@ -3444,7 +3455,11 @@ export async function activate(context: vscode.ExtensionContext) {
Logger.warn(`Failed to handle URI Open, ${uri.toString()}`);
},
});
await checkExtensionSettings(context.extensionPath, workspaceRoot);
await checkExtensionSettings(
context.extensionPath,
workspaceRoot,
statusBarItems["currentIdfVersion"]
);
}

async function getFrameworksPickItems() {
Expand Down Expand Up @@ -3603,7 +3618,7 @@ function registerTreeProvidersForIDFExplorer(context: vscode.ExtensionContext) {
);
}

function createCmdsStatusBarItems() {
async function createCmdsStatusBarItems() {
const enableStatusBar = idfConf.readParameter(
"idf.enableStatusBar"
) as boolean;
Expand All @@ -3625,8 +3640,16 @@ function createCmdsStatusBarItems() {
workspaceRoot
);
}
let currentIdfVersion = await getCurrentIdfSetup(workspaceRoot);
const statusBarItems: { [key: string]: vscode.StatusBarItem } = {};

statusBarItems["currentIdfVersion"] = createStatusBarItem(
"$(octoface) ESP-IDF v" + currentIdfVersion.version,
"ESP-IDF: Select current ESP-IDF version",
"espIdf.selectCurrentIdfVersion",
102
);

statusBarItems["port"] = createStatusBarItem(
"$(plug)" + port,
"ESP-IDF: Select Port to Use (COM, tty, usbserial)",
Expand Down
19 changes: 15 additions & 4 deletions src/setup/SetupPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
ExtensionContext,
Progress,
ProgressLocation,
StatusBarItem,
Uri,
ViewColumn,
WebviewPanel,
Expand Down Expand Up @@ -160,6 +161,7 @@ export class SetupPanel {
message.saveScope,
message.setupMode,
context,
setupArgs.espIdfStatusBar,
setupArgs.workspaceFolder,
setupArgs.onReqPkgs
);
Expand All @@ -182,6 +184,7 @@ export class SetupPanel {
message.saveScope,
setupArgs.workspaceFolder,
context,
setupArgs.espIdfStatusBar,
setupArgs.onReqPkgs
);
}
Expand Down Expand Up @@ -257,7 +260,8 @@ export class SetupPanel {
setupArgs.gitPath,
message.saveScope,
context,
setupArgs.workspaceFolder
setupArgs.workspaceFolder,
setupArgs.espIdfStatusBar
);
}
break;
Expand Down Expand Up @@ -300,7 +304,8 @@ export class SetupPanel {
await useIdfSetupSettings(
setupArgs.existingIdfSetups[message.selectedIdfSetup],
message.saveScope,
setupArgs.workspaceFolder
setupArgs.workspaceFolder,
setupArgs.espIdfStatusBar
);
this.panel.webview.postMessage({
command: "setIsInstalled",
Expand Down Expand Up @@ -379,6 +384,7 @@ export class SetupPanel {
saveScope: ConfigurationTarget,
setupMode: SetupMode,
context: ExtensionContext,
espIdfStatusBar: StatusBarItem,
workspaceFolderUri: Uri,
onReqPkgs?: string[]
) {
Expand Down Expand Up @@ -455,6 +461,7 @@ export class SetupPanel {
saveScope,
setupMode,
context,
espIdfStatusBar,
workspaceFolderUri,
idfGitPath,
progress,
Expand Down Expand Up @@ -531,6 +538,7 @@ export class SetupPanel {
saveScope: ConfigurationTarget,
workspaceFolderUri: Uri,
context: ExtensionContext,
espIdfStatusBar: StatusBarItem,
onReqPkgs?: string[]
) {
const notificationMode = idfConf.readParameter(
Expand Down Expand Up @@ -587,6 +595,7 @@ export class SetupPanel {
saveScope,
workspaceFolderUri,
context,
espIdfStatusBar,
progress,
cancelToken,
onReqPkgs
Expand All @@ -607,7 +616,8 @@ export class SetupPanel {
gitPath: string,
saveScope: ConfigurationTarget,
context: ExtensionContext,
workspaceFolderUri: Uri
workspaceFolderUri: Uri,
espIdfStatusBar: StatusBarItem
) {
const notificationMode = idfConf.readParameter(
"idf.notificationMode"
Expand Down Expand Up @@ -644,7 +654,8 @@ export class SetupPanel {
context,
progress,
cancelToken,
workspaceFolderUri
workspaceFolderUri,
espIdfStatusBar
);
} catch (error) {
this.setupErrHandler(error);
Expand Down
2 changes: 2 additions & 0 deletions src/setup/espIdfDownloadStep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export async function expressInstall(
saveScope: vscode.ConfigurationTarget,
setupMode: SetupMode,
context: vscode.ExtensionContext,
espIdfStatusBar: vscode.StatusBarItem,
workspaceFolderUri: vscode.Uri,
gitPath?: string,
progress?: vscode.Progress<{ message: string; increment?: number }>,
Expand Down Expand Up @@ -130,6 +131,7 @@ export async function expressInstall(
saveScope,
workspaceFolderUri,
context,
espIdfStatusBar,
progress,
cancelToken,
onReqPkgs
Expand Down
15 changes: 0 additions & 15 deletions src/setup/installPyReqs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,21 +100,6 @@ export async function installPyReqs(
return;
}

export async function installExtensionPyReqs(
idfToolsDir: string,
pythonBinPath: string,
espIdfPath: string
) {
const logTracker = new PyReqLog(sendPyReqLog);
await pythonManager.installExtensionPyReqs(
pythonBinPath,
espIdfPath,
idfToolsDir,
logTracker,
OutputChannel.init()
);
}

export function sendPyReqLog(log: string) {
SetupPanel.postMessage({
command: "updatePyReqsLog",
Expand Down
6 changes: 4 additions & 2 deletions src/setup/pyReqsInstallStep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ export async function createPyReqs(
context: vscode.ExtensionContext,
progress: vscode.Progress<{ message: string; increment?: number }>,
cancelToken: vscode.CancellationToken,
workspaceFolderUri: vscode.Uri
workspaceFolderUri: vscode.Uri,
espIdfStatusBar: vscode.StatusBarItem
) {
SetupPanel.postMessage({
command: "updatePyVEnvStatus",
Expand All @@ -55,7 +56,8 @@ export async function createPyReqs(
toolsPath,
gitPath,
saveScope,
workspaceFolderUri
workspaceFolderUri,
espIdfStatusBar
);
let idfPathVersion = await getEspIdfFromCMake(idfPath);
await addIdfPath(idfPath, virtualEnvPath, idfPathVersion, toolsPath, gitPath);
Expand Down
18 changes: 8 additions & 10 deletions src/setup/setupInit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import {
ConfigurationTarget,
Progress,
Uri,
window,
workspace,
WorkspaceFolder,
} from "vscode";
import { ConfigurationTarget, Progress, StatusBarItem, Uri } from "vscode";
import { IdfToolsManager } from "../idfToolsManager";
import * as utils from "../utils";
import { getEspIdfTags, getEspIdfVersions } from "./espIdfVersionList";
Expand All @@ -37,6 +30,7 @@ import {
} from "./existingIdfSetups";
import { checkPyVenv } from "./setupValidation/pythonEnv";
import { packageJson } from "../utils";
import { getCurrentIdfSetup } from "../versionSwitcher";

export interface ISetupInitArgs {
espIdfPath: string;
Expand All @@ -52,6 +46,7 @@ export interface ISetupInitArgs {
pythonVersions: string[];
saveScope: number;
workspaceFolder: Uri;
espIdfStatusBar: StatusBarItem;
}

export interface IPreviousInstallResult {
Expand Down Expand Up @@ -318,7 +313,8 @@ export async function saveSettings(
toolsPath: string,
gitPath: string,
saveScope: ConfigurationTarget,
workspaceFolderUri: Uri
workspaceFolderUri: Uri,
espIdfStatusBar: StatusBarItem
) {
const confTarget =
saveScope ||
Expand Down Expand Up @@ -363,6 +359,8 @@ export async function saveSettings(
confTarget,
workspaceFolder
);
let currentIdfVersion = await getCurrentIdfSetup(workspaceFolder);
espIdfStatusBar.text = "$(octoface) ESP-IDF v" + currentIdfVersion.version;
await createIdfSetup(espIdfPath, toolsPath, pythonBinPath, gitPath);
window.showInformationMessage("ESP-IDF has been configured");
Logger.infoNotify("ESP-IDF has been configured");
}
Loading
Loading