diff --git a/.prettierignore b/.prettierignore index 038577051..593326dfa 100644 --- a/.prettierignore +++ b/.prettierignore @@ -13,7 +13,8 @@ espressif_icon.png get_serial_list.py .yarnrc *.vsix - +export.ps1 +export.bat #dirs .vscode diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a8f9a862..f0f8d8e95 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,44 @@ All notable changes to the "Espressif IDF" extension will be documented in this file. +## [1.9.0](https://github.com/espressif/vscode-esp-idf-extension/releases/tag/v1.9.0) + +### Bug Fixes + +- [Update to latest Espressif icon](https://github.com/espressif/vscode-esp-idf-extension/pull/1294) +- [Use static monitor terminal instance](https://github.com/espressif/vscode-esp-idf-extension/pull/1289) +- [Update create from project examples UI UX](https://github.com/espressif/vscode-esp-idf-extension/pull/1278) +- [Fix display of monitor the device when flash fails](https://github.com/espressif/vscode-esp-idf-extension/pull/1286) +- [Update recommended cp command](https://github.com/espressif/vscode-esp-idf-extension/pull/1269) +- [Enhance telemetry reporting](https://github.com/espressif/vscode-esp-idf-extension/pull/1272) +- [Make readme easy to follow](https://github.com/espressif/vscode-esp-idf-extension/pull/1295) +- [Fix for pwsh users](https://github.com/espressif/vscode-esp-idf-extension/pull/1279) +- [Fix PR comment remove build flash telemetry](https://github.com/espressif/vscode-esp-idf-extension/pull/1328) +- [Fix duplicate output; Add notification for success](https://github.com/espressif/vscode-esp-idf-extension/pull/1290) +- [Add validation for debug session status for monitor start with no reset flag](https://github.com/espressif/vscode-esp-idf-extension/pull/1270) +- [Update dockerfile, add qemu executable options](https://github.com/espressif/vscode-esp-idf-extension/pull/1282) +- [Add IDF_PATH and IDF_TOOLS_PATH to newly created project settings](https://github.com/espressif/vscode-esp-idf-extension/pull/1332) +- [Fix unit tests not being refreshed](https://github.com/espressif/vscode-esp-idf-extension/pull/1338) +- [Remove old documentation and update links](https://github.com/espressif/vscode-esp-idf-extension/pull/1342) +- [walkthrough bugfixes](https://github.com/espressif/vscode-esp-idf-extension/pull/1354) +- [Use only major minor version in espidf constraint file](https://github.com/espressif/vscode-esp-idf-extension/pull/1360) + +### Features and enhancements + +- [Add Espressif documentation](https://github.com/espressif/vscode-esp-idf-extension/pull/1291) +- [Filter serial devices by default and allow user to disable chip id in serial port list](https://github.com/espressif/vscode-esp-idf-extension/pull/1276) +- [Compute Python path from IDF_TOOLS_PATH and IDF_PATH](https://github.com/espressif/vscode-esp-idf-extension/pull/1263) +- [Enable/Disable status bar icons in Commands Tree view](https://github.com/espressif/vscode-esp-idf-extension/pull/1314) +- [Hoist linker (ld) errors to VS Code 'Problems' window](https://github.com/espressif/vscode-esp-idf-extension/pull/1317) Thanks @GillesZunino ! +- [Support for multiple sdkconfig file in Project configuration editor](https://github.com/espressif/vscode-esp-idf-extension/pull/1252) +- [Disable cmds for Codespaces and redirect Flash monitor to Web extension](https://github.com/espressif/vscode-esp-idf-extension/pull/1297) +- [Support new IDF Size json format](https://github.com/espressif/vscode-esp-idf-extension/pull/1330) +- [Add check for missing compile_commands json](https://github.com/espressif/vscode-esp-idf-extension/pull/1271) +- [Enhance flash encryption with eFuse validation and more user information](https://github.com/espressif/vscode-esp-idf-extension/pull/1247) +- [Use idf_tools py export to get env variables](https://github.com/espressif/vscode-esp-idf-extension/pull/1343) +- [Add chinese translation for readme](https://github.com/espressif/vscode-esp-idf-extension/pull/1335) +- [Add extension walkthrough](https://github.com/espressif/vscode-esp-idf-extension/pull/1298) + ## [1.8.1](https://github.com/espressif/vscode-esp-idf-extension/releases/tag/v1.8.1) ### Bug Fixes diff --git a/export.bat b/export.bat new file mode 100644 index 000000000..9b6fea503 --- /dev/null +++ b/export.bat @@ -0,0 +1,7 @@ +DOSKEY idf.py=python.exe "%IDF_PATH%\tools\idf.py" $* +DOSKEY esptool.py=python.exe "%IDF_PATH%\components\esptool_py\esptool\esptool.py" $* +DOSKEY espefuse.py=python.exe "%IDF_PATH%\components\esptool_py\esptool\espefuse.py" $* +DOSKEY espsecure.py=python.exe "%IDF_PATH%\components\esptool_py\esptool\espsecure.py" $* +DOSKEY otatool.py=python.exe "%IDF_PATH%\components\app_update\otatool.py" $* +DOSKEY parttool.py=python.exe "%IDF_PATH%\components\partition_table\parttool.py" $* +cls \ No newline at end of file diff --git a/export.ps1 b/export.ps1 new file mode 100644 index 000000000..fe748e178 --- /dev/null +++ b/export.ps1 @@ -0,0 +1,33 @@ +# Define the Invoke-idfpy function +function global:Invoke-idfpy { + & python.exe ` + "$($env:IDF_PATH)\tools\idf.py" @args +} + +function global:esptool.py { + & python.exe ` + "$($env:IDF_PATH)\components\esptool_py\esptool\esptool.py" @args +} + +function global:espefuse.py { + & python.exe ` + "$($env:IDF_PATH)\components\esptool_py\esptool\espefuse.py" @args +} + +function global:espsecure.py { + & python.exe ` + "$($env:IDF_PATH)\components\esptool_py\esptool\espsecure.py" @args +} + +function global:otatool.py { + & python.exe ` + "$($env:IDF_PATH)\components\app_update\otatool.py" @args +} + +function global:parttool.py { + & python.exe ` + "$($env:IDF_PATH)\components\partition_table\parttool.py" @args +} + +# Create an alias for the function +New-Alias -Name idf.py -Value Invoke-idfpy -Force -Scope Global \ No newline at end of file diff --git a/src/checkExtensionSettings.ts b/src/checkExtensionSettings.ts index 658df0d87..6608ea7d7 100644 --- a/src/checkExtensionSettings.ts +++ b/src/checkExtensionSettings.ts @@ -16,27 +16,29 @@ * limitations under the License. */ import * as vscode from "vscode"; -import { - getSetupInitialValues, - isCurrentInstallValid, -} from "./setup/setupInit"; +import { isCurrentInstallValid } from "./setup/setupInit"; import { Logger } from "./logger/logger"; -import { NotificationMode, readParameter } from "./idfConfiguration"; -import { useIdfSetupSettings } from "./setup/setupValidation/espIdfSetup"; +import { readParameter } from "./idfConfiguration"; +import { + checkIdfSetup, + useIdfSetupSettings, +} from "./setup/setupValidation/espIdfSetup"; +import { getIdfMd5sum } from "./setup/espIdfJson"; +import { getEspIdfFromCMake } from "./utils"; +import { IdfSetup } from "./views/setup/types"; export async function checkExtensionSettings( - extensionPath: string, workspace: vscode.Uri, espIdfStatusBar: vscode.StatusBarItem ) { - const showSetupWindow = readParameter("idf.showOnboardingOnInit") as boolean; - if (!showSetupWindow) { - return; - } + const showWelcomePage = readParameter( + "idf.showOnboardingOnInit", + workspace + ) as boolean; try { const isExtensionConfigured = await isCurrentInstallValid(workspace); - if (isExtensionConfigured) { - await vscode.commands.executeCommand("espIdf.welcome.start"); + if (showWelcomePage && isExtensionConfigured) { + vscode.commands.executeCommand("espIdf.welcome.start"); return; } } catch (error) { @@ -45,73 +47,65 @@ export async function checkExtensionSettings( : "Checking if current install is valid throws an error."; Logger.error(msg, error, "checkExtensionSettings"); } - const notificationMode = readParameter( - "idf.notificationMode", - workspace - ) as string; - const ProgressLocation = - notificationMode === NotificationMode.All || - notificationMode === NotificationMode.Notifications - ? vscode.ProgressLocation.Notification - : vscode.ProgressLocation.Window; - await vscode.window.withProgress( - { - cancellable: false, - location: ProgressLocation, - title: "ESP-IDF: Loading initial configuration...", - }, - async ( - progress: vscode.Progress<{ message: string; increment: number }>, - cancelToken: vscode.CancellationToken - ) => { - try { - const setupArgs = await getSetupInitialValues( - extensionPath, - progress, - workspace - ); - setupArgs.espIdfStatusBar = espIdfStatusBar; - if (setupArgs.existingIdfSetups && setupArgs.existingIdfSetups.length) { - progress.report({ - increment: 5, - message: "ESP-IDF and tools found, configuring the extension...", - }); - const confTarget = readParameter( - "idf.saveScope" - ) as vscode.ConfigurationTarget; - const options = setupArgs.existingIdfSetups.map((existingSetup) => { - return { - label: `ESP-IDF ${existingSetup.version} in ${existingSetup.idfPath}`, - target: existingSetup, - }; - }); - const selectedSetup = await vscode.window.showQuickPick(options, { - placeHolder: "Select a ESP-IDF setup to use", - }); - if (!selectedSetup) { - return; - } - await useIdfSetupSettings( - selectedSetup.target, - confTarget, - workspace, - espIdfStatusBar - ); - } else if ( - typeof process.env.WEB_IDE === "undefined" && - showSetupWindow - ) { - vscode.commands.executeCommand("espIdf.setup.start", setupArgs); - } - } catch (error) { - const msg = error.message - ? error.message - : "Error loading initial configuration."; - Logger.errorNotify(msg, error, "checkExtensionSettings"); - if (showSetupWindow) { - vscode.commands.executeCommand("espIdf.setup.start"); - } - } - } + + if (!showWelcomePage) { + return; + } + + const actionItems = [ + "Open Setup wizard", + "Choose from existing ESP-IDF setups.", + ]; + + if (vscode.env.remoteName === "dev-container") { + actionItems.unshift("Use docker container configuration"); + } + + const action = await vscode.window.showInformationMessage( + "The extension configuration is not valid. Choose an action:", + ...actionItems ); + if (!action) { + return; + } + + if (action === "Use docker container configuration") { + const idfPath = "/opt/esp/idf"; + const idfToolsPath = "/opt/esp"; + const gitPath = "/usr/bin/git"; + const idfSetupId = getIdfMd5sum(idfPath); + const idfVersion = await getEspIdfFromCMake(idfPath); + const containerIdfSetup: IdfSetup = { + id: idfSetupId, + idfPath, + gitPath, + toolsPath: idfToolsPath, + version: idfVersion, + isValid: false, + }; + containerIdfSetup.isValid = await checkIdfSetup(containerIdfSetup); + + if (!containerIdfSetup.isValid) { + vscode.window.showInformationMessage( + "The docker container configuration is not valid" + ); + return; + } + + await useIdfSetupSettings( + containerIdfSetup, + vscode.ConfigurationTarget.WorkspaceFolder, + workspace, + espIdfStatusBar + ); + return; + } + + if (action === "Open Setup wizard") { + vscode.commands.executeCommand("espIdf.setup.start"); + return; + } else if (action === "Choose from existing ESP-IDF setups.") { + vscode.commands.executeCommand("espIdf.selectCurrentIdfVersion"); + return; + } } diff --git a/src/cmdTreeView/cmdStore.ts b/src/cmdTreeView/cmdStore.ts index 6637b5a03..69cb88dbf 100644 --- a/src/cmdTreeView/cmdStore.ts +++ b/src/cmdTreeView/cmdStore.ts @@ -27,7 +27,8 @@ export interface IDFCommandDescription { export enum IDFWebCommandKeys { Flash = "espIdfWeb.flash", - Monitor = "espIdfWeb.monitor" + Monitor = "espIdfWeb.monitor", + FlashAndMonitor = "espIdfWeb.flashAndMonitor" } export enum CommandKeys { diff --git a/src/extension.ts b/src/extension.ts index 3e3ce1392..00a48487f 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -1789,7 +1789,9 @@ export async function activate(context: vscode.ExtensionContext) { }); }); - registerIDFCommand("espIdf.createIdfTerminal", createIdfTerminal); + registerIDFCommand("espIdf.createIdfTerminal", () => + createIdfTerminal(context.extensionPath) + ); registerIDFCommand("espIdf.jtag_flash", () => flash(false, ESP.FlashType.JTAG) ); @@ -3630,11 +3632,7 @@ export async function activate(context: vscode.ExtensionContext) { Logger.warn(`Failed to handle URI Open, ${uri.toString()}`); }, }); - await checkExtensionSettings( - context.extensionPath, - workspaceRoot, - statusBarItems["currentIdfVersion"] - ); + checkExtensionSettings(workspaceRoot, statusBarItems["currentIdfVersion"]); // WALK-THROUGH let disposable = vscode.commands.registerCommand( @@ -4082,7 +4080,7 @@ function createQemuMonitor() { } const buildFlashAndMonitor = async (runMonitor: boolean = true) => { - PreCheck.perform([webIdeCheck, openFolderCheck], async () => { + PreCheck.perform([openFolderCheck], async () => { const notificationMode = idfConf.readParameter( "idf.notificationMode", workspaceRoot @@ -4113,6 +4111,11 @@ const buildFlashAndMonitor = async (runMonitor: boolean = true) => { if (!canContinue) { return; } + // Re route to ESP-IDF Web extension if using Codespaces or Browser + if (vscode.env.uiKind === vscode.UIKind.Web) { + vscode.commands.executeCommand(IDFWebCommandKeys.FlashAndMonitor); + return; + } progress.report({ message: "Flashing project into device...", increment: 60, @@ -4260,17 +4263,36 @@ async function startFlashing( } } -function createIdfTerminal() { +function createIdfTerminal(extensionPath: string) { PreCheck.perform([openFolderCheck], async () => { const modifiedEnv = await utils.appendIdfAndToolsToPath(workspaceRoot); + let shellArgs = []; + if (process.platform === "win32") { + if ( + vscode.env.shell.indexOf("powershell") !== -1 || + vscode.env.shell.indexOf("pwsh") !== -1 + ) { + shellArgs = ["-ExecutionPolicy", "Bypass", "-NoProfile"]; + } + } const espIdfTerminal = vscode.window.createTerminal({ name: "ESP-IDF Terminal", env: modifiedEnv, cwd: workspaceRoot.fsPath || modifiedEnv.IDF_PATH || process.cwd(), strictEnv: true, - shellArgs: [], + shellArgs, shellPath: vscode.env.shell, }); + if (process.platform === "win32") { + if (vscode.env.shell.indexOf("cmd.exe") !== -1) { + espIdfTerminal.sendText(path.join(extensionPath, "export.bat")); + } else if ( + vscode.env.shell.indexOf("powershell") !== -1 || + vscode.env.shell.indexOf("pwsh") !== -1 + ) { + espIdfTerminal.sendText(path.join(extensionPath, "export.ps1")); + } + } espIdfTerminal.show(); }); } diff --git a/src/ui-test/configure-test.ts b/src/ui-test/configure-test.ts index 16de06b53..cbc1e1fa0 100644 --- a/src/ui-test/configure-test.ts +++ b/src/ui-test/configure-test.ts @@ -31,7 +31,7 @@ describe("Configure extension", () => { before(async function () { this.timeout(100000); - await new Promise((res) => setTimeout(res, 2000)); + await new Promise((res) => setTimeout(res, 10000)); const notifications = await new Workbench().getNotifications(); for (let n of notifications) { await n.dismiss(); diff --git a/src/utils.ts b/src/utils.ts index ad444a230..9e1d9d962 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1120,9 +1120,11 @@ export async function appendIdfAndToolsToPath(curWorkspace: vscode.Uri) { `${process.env.PYTHON}` || `${path.join(process.env.IDF_PYTHON_ENV_PATH, "bin", "python")}`; - modifiedEnv.IDF_PYTHON_ENV_PATH = - path.dirname(path.dirname(pythonBinPath)) || - process.env.IDF_PYTHON_ENV_PATH; + const pythonBinPathExists = await pathExists(pythonBinPath); + + modifiedEnv.IDF_PYTHON_ENV_PATH = pythonBinPathExists + ? path.dirname(path.dirname(pythonBinPath)) + : process.env.IDF_PYTHON_ENV_PATH; const gitPath = idfConf.readParameter("idf.gitPath", curWorkspace) as string; let pathToGitDir; @@ -1145,9 +1147,10 @@ export async function appendIdfAndToolsToPath(curWorkspace: vscode.Uri) { (k) => k.toUpperCase() == "PATH" ); - const pythonBinPathExists = await pathExists(pythonBinPath); + const idfPathExists = await pathExists(modifiedEnv.IDF_PATH); + const idfToolsPathExists = await pathExists(modifiedEnv.IDF_TOOLS_PATH); - if (pythonBinPathExists) { + if (pythonBinPathExists && idfPathExists && idfToolsPathExists) { const idfToolsExportVars = await getEnvVarsFromIdfTools( modifiedEnv.IDF_PATH, modifiedEnv.IDF_TOOLS_PATH,