Skip to content

Commit

Permalink
update dockerfile devcontainer (#1109)
Browse files Browse the repository at this point in the history
* update dockerfile devcontainer

* update path reference in python env install

* fix lint

* try using env variable collection for py lib

* fix lint

* update vscode extension tester

* update yarn lock

* use node 16

* update nvm

* nvm quote

* update docs

* update menuconfig timeout switch

* disable welcome page
  • Loading branch information
brianignacio5 authored Jan 25, 2024
1 parent 872e4d2 commit 2b2e660
Show file tree
Hide file tree
Showing 18 changed files with 1,319 additions and 1,297 deletions.
15 changes: 8 additions & 7 deletions .github/actions/idf/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ ENV DISPLAY=":99"
ENV CODE_TESTS_PATH="out/test"
ENV CODE_VERSION="min"

ENV NODE_VERSION=14.19.0
RUN curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash
ENV NVM_DIR=/root/.nvm
RUN . "$NVM_DIR/nvm.sh" && nvm install ${NODE_VERSION}
RUN . "$NVM_DIR/nvm.sh" && nvm use v${NODE_VERSION}
RUN . "$NVM_DIR/nvm.sh" && nvm alias default v${NODE_VERSION}
ENV PATH="/root/.nvm/versions/node/v${NODE_VERSION}/bin/:${PATH}"
ENV NVM_DIR /usr/local/nvm
RUN mkdir -p $NVM_DIR
RUN curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.1/install.sh | bash
ENV NODE_VERSION v16.16.0
RUN . "${NVM_DIR}/nvm.sh" && nvm install ${NODE_VERSION} && nvm use --delete-prefix ${NODE_VERSION}

ENV NODE_PATH $NVM_DIR/versions/node/$NODE_VERSION/lib/node_modules
ENV PATH $NVM_DIR/versions/node/$NODE_VERSION/bin:$PATH
RUN node --version
RUN npm --version
RUN npm install --global typescript yarn
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,8 @@ We have implemented some utilities commands that can be used in tasks.json and l
- `espIdf.getOpenOcdScriptValue`: Return the value of OPENOCD_SCRIPTS from `idf.customExtraVars` or from system OPENOCD_SCRIPTS environment variable.
- `espIdf.getOpenOcdConfig`: Return the openOCD configuration files as string. Example `-f interface/ftdi/esp32_devkitj_v1.cfg -f board/esp32-wrover.cfg`.
- `espIdf.getProjectName`: Return the project name from current workspace folder `build/project_description.json`.
- `espIdf.getXtensaGcc`: Return the absolute path of the xtensa toolchain gcc for the ESP-IDF target given by `idf.adapterTargetName` configuration setting and `idf.customExtraPaths`.
- `espIdf.getXtensaGdb`: Return the absolute path of the xtensa toolchain gdb for the ESP-IDF target given by `idf.adapterTargetName` configuration setting and `idf.customExtraPaths`.
- `espIdf.getXtensaGcc`: Return the absolute path of the toolchain gcc for the ESP-IDF target given by `idf.adapterTargetName` configuration setting and `idf.customExtraPaths`.
- `espIdf.getXtensaGdb`: Return the absolute path of the toolchain gdb for the ESP-IDF target given by `idf.adapterTargetName` configuration setting and `idf.customExtraPaths`.

See an example in the [debugging](./docs/DEBUGGING.md) documentation.

Expand All @@ -215,16 +215,16 @@ If something is not working please check for any error on one of these:
> **NOTE:** Use `logLevel` in your <project-directory>/.vscode/launch.json to 3 or more to show more debug adapter output.
1. In Visual Studio Code select menu "View" -> Output -> ESP-IDF, ESP-IDF Debug Adapter, Heap Trace, OpenOCD and SDK Configuration Editor. This output information is useful to know what is happening in each tool.
2. Use the `ESP-IDF: Doctor Command` to generate a report of your configuration and it will be copied in your clipboard to paste anywhere.
1. In Visual Studio Code select menu **View** -> **Output** -> **ESP-IDF**. This output information is useful to know what is happening in the extension.
2. In Visual Studio Code select menu **View** then click **Command Palette...** and type `ESP-IDF: Doctor Command` to generate a report of your environment configuration and it will be copied in your clipboard to paste anywhere.
3. Check log file which can be obtained from:

- Windows: `%USERPROFILE%\.vscode\extensions\espressif.esp-idf-extension-VERSION\esp_idf_vsc_ext.log`
- Linux & MacOSX: `$HOME/.vscode/extensions/espressif.esp-idf-extension-VERSION/esp_idf_vsc_ext.log`

4. In Visual Studio Code, select menu "Help" -> `Toggle Developer Tools` and copy any error in the Console tab related to this extension.
4. In Visual Studio Code, select menu **Help** -> `Toggle Developer Tools` and copy any error in the Console tab related to this extension.

5. Make sure that your extension is properly configured as described in [JSON Manual Configuration](./docs/SETUP.md#JSON-Manual-Configuration). Visual Studio Code allows the user to configure settings at different levels: Global (User Settings), Workspace and Workspace Folder so make sure your project has the right settings. The `ESP-IDF: Doctor command` result might give the values from user settings instead of the workspace folder settings.
5. Make sure that your extension is properly configured as described in [JSON Manual Configuration](./docs/SETUP.md#JSON-Manual-Configuration). Visual Studio Code allows the user to configure settings at different levels: **Global (User Settings)**, **Workspace** and **Workspace Folder** so make sure your project has the right settings. The `ESP-IDF: Doctor command` result might give the values from user settings instead of the workspace folder settings.

6. Review the [OpenOCD troubleshooting FAQ](https://github.com/espressif/openocd-esp32/wiki/Troubleshooting-FAQ) related to the `OpenOCD` output, for application tracing, debug or any OpenOCD related issues.

Expand Down
6 changes: 5 additions & 1 deletion docs/tutorial/using-docker-container.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ For more information about `devcontainer.json`, please refer to the comments.
"terminal.integrated.defaultProfile.linux": "bash",
"idf.espIdfPath": "/opt/esp/idf",
"idf.customExtraPaths": "",
"idf.pythonBinPath": "/opt/esp/python_env/idf5.0_py3.8_env/bin/python",
"idf.pythonBinPath": "/opt/esp/python_env/idf5.3_py3.10_env/bin/python",
"idf.toolsPath": "/opt/esp",
"idf.gitPath": "/usr/bin/git"
},
Expand Down Expand Up @@ -260,6 +260,10 @@ the interface is the same as [Internal USB-serial](#internal-usb-serial), that i

<img src="../../media\tutorials\using_docker_container\container_flash_jtag.gif" alt="" height="">

### Additional steps for debugging

Make sure to run `ESP-IDF: Add OpenOCD rules file (For Linux users)` command and `ESP-IDF: Install ESP-IDF Python Packages` command to add openOCD rules and install debug adapter python packages in the docker container before running openOCD and starting a debug session with the ESP-IDF Debug Adapter.

## Debugging

After following [USB-JTAG](#usb-jtag), press `F5` to start to debug:
Expand Down
4 changes: 4 additions & 0 deletions docs/tutorial/wsl.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,10 @@ the interface is the same as [Internal USB-serial](#internal-usb-serial), that i
<img src="../../media\tutorials\using_docker_container\container_flash_jtag.gif" alt="" height="">
### Additional steps for debugging
Make sure to run `ESP-IDF: Add OpenOCD rules file (For Linux users)` command and `ESP-IDF: Install ESP-IDF Python Packages` command to add openOCD rules and install debug adapter python packages in the WSL before running openOCD and starting a debug session with the ESP-IDF Debug Adapter.
## Debugging
After following [USB-JTAG](#usb-jtag), press `F5` to start to debug:
Expand Down
2 changes: 1 addition & 1 deletion esp_debug_adapter
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"theme": "dark"
},
"engines": {
"vscode": "^1.68.0"
"vscode": "^1.82.0"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -1517,8 +1517,7 @@
"@types/sanitize-html": "^2.6.2",
"@types/tar-fs": "^2.0.1",
"@types/tmp": "0.0.33",
"@types/vscode": "^1.59.0",
"@types/vue-select": "^3.16.2",
"@types/vscode": "^1.82.0",
"@types/ws": "^7.2.5",
"@types/xml2js": "^0.4.11",
"@types/yauzl": "^2.9.1",
Expand Down Expand Up @@ -1554,7 +1553,7 @@
"typescript": "^5.2.2",
"vite": "^4.5.2",
"vsce": "^2.6.7",
"vscode-extension-tester": "^5.2.1",
"vscode-extension-tester": "^7.0.0",
"vscode-nls-dev": "^3.3.1",
"vue-hot-reload-api": "^2.3.2",
"vue-loader": "^17.2.2",
Expand Down
4 changes: 2 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1809,7 +1809,7 @@ export async function activate(context: vscode.ExtensionContext) {
PreCheck.perform([webIdeCheck], async () => {
try {
if (SetupPanel.isCreatedAndHidden()) {
SetupPanel.createOrShow(context.extensionPath);
SetupPanel.createOrShow(context);
return;
}
await vscode.window.withProgress(
Expand All @@ -1829,7 +1829,7 @@ export async function activate(context: vscode.ExtensionContext) {
progress,
workspaceRoot
);
SetupPanel.createOrShow(context.extensionPath, setupArgs);
SetupPanel.createOrShow(context, setupArgs);
} catch (error) {
Logger.errorNotify(error.message, error);
}
Expand Down
42 changes: 29 additions & 13 deletions src/pythonManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
// limitations under the License.

import { PyReqLog } from "./PyReqLog";
import { CancellationToken, OutputChannel } from "vscode";
import { CancellationToken, ExtensionContext, OutputChannel } from "vscode";
import * as utils from "./utils";
import { constants, pathExists } from "fs-extra";
import { Logger } from "./logger/logger";
import path from "path";
import { delimiter, dirname, join, sep } from "path";

export async function installEspIdfToolFromIdf(
espDir: string,
Expand All @@ -28,7 +28,7 @@ export async function installEspIdfToolFromIdf(
channel?: OutputChannel,
cancelToken?: CancellationToken
) {
const idfToolsPyPath = path.join(espDir, "tools", "idf_tools.py");
const idfToolsPyPath = join(espDir, "tools", "idf_tools.py");
const modifiedEnv: { [key: string]: string } = <{ [key: string]: string }>(
Object.assign({}, process.env)
);
Expand Down Expand Up @@ -62,10 +62,11 @@ export async function installPythonEnvFromIdfTools(
pyTracker: PyReqLog,
pythonBinPath: string,
gitPath: string,
context: ExtensionContext,
channel?: OutputChannel,
cancelToken?: CancellationToken
) {
const idfToolsPyPath = path.join(espDir, "tools", "idf_tools.py");
const idfToolsPyPath = join(espDir, "tools", "idf_tools.py");
const modifiedEnv: { [key: string]: string } = <{ [key: string]: string }>(
Object.assign({}, process.env)
);
Expand All @@ -74,12 +75,27 @@ export async function installPythonEnvFromIdfTools(
if (process.platform === "win32") {
let pathToGitDir: string;
if (gitPath && gitPath !== "git") {
pathToGitDir = path.dirname(gitPath);
pathToGitDir = dirname(gitPath);
}
const pathNameInEnv: string = Object.keys(process.env).find(
(k) => k.toUpperCase() == "PATH"
);
if (pathToGitDir) {
modifiedEnv.Path = pathToGitDir + path.delimiter + modifiedEnv.Path;
modifiedEnv[pathNameInEnv] =
pathToGitDir + delimiter + modifiedEnv[pathNameInEnv];
}
modifiedEnv.PYTHONNOUSERSITE = "1";
modifiedEnv[pathNameInEnv] =
dirname(pythonBinPath) +
sep +
"Lib" +
delimiter +
modifiedEnv[pathNameInEnv];
const collection = context.environmentVariableCollection;
collection.prepend(pathNameInEnv, join(dirname(pythonBinPath), "Lib"), {
applyAtShellIntegration: true,
applyAtProcessCreation: true,
});
}

const pyEnvPath = await getPythonEnvPath(espDir, idfToolsDir, pythonBinPath);
Expand All @@ -97,7 +113,7 @@ export async function installPythonEnvFromIdfTools(
process.platform === "win32"
? ["Scripts", "python.exe"]
: ["bin", "python"];
const virtualEnvPython = path.join(pyEnvPath, ...pyDir);
const virtualEnvPython = join(pyEnvPath, ...pyDir);
await installExtensionPyReqs(
virtualEnvPython,
espDir,
Expand All @@ -120,7 +136,7 @@ export async function installExtensionPyReqs(
cancelToken?: CancellationToken
) {
const reqDoesNotExists = " doesn't exist. Make sure the path is correct.";
const debugAdapterRequirements = path.join(
const debugAdapterRequirements = join(
utils.extensionContext.extensionPath,
"esp_debug_adapter",
"requirements.txt"
Expand All @@ -133,7 +149,7 @@ export async function installExtensionPyReqs(
return;
}
const espIdfVersion = await utils.getEspIdfFromCMake(espDir);
const constrainsFile = path.join(
const constrainsFile = join(
idfToolsDir,
`espidf.constraints.v${espIdfVersion}.txt`
);
Expand All @@ -142,7 +158,7 @@ export async function installExtensionPyReqs(
if (constrainsFileExists) {
constraintArg = `--constraint "${constrainsFile}" `;
} else {
const extensionConstraintsFile = path.join(
const extensionConstraintsFile = join(
utils.extensionContext.extensionPath,
`espidf.constraints.txt`
);
Expand Down Expand Up @@ -189,10 +205,10 @@ export async function installEspMatterPyReqs(
process.platform === "win32"
? ["Scripts", "python.exe"]
: ["bin", "python"];
const virtualEnvPython = path.join(pyEnvPath, ...pyDir);
const virtualEnvPython = join(pyEnvPath, ...pyDir);

const reqDoesNotExists = " doesn't exist. Make sure the path is correct.";
const matterRequirements = path.join(espMatterDir, "requirements.txt");
const matterRequirements = join(espMatterDir, "requirements.txt");
if (!utils.canAccessFile(matterRequirements, constants.R_OK)) {
Logger.warnNotify(matterRequirements + reqDoesNotExists);
if (channel) {
Expand Down Expand Up @@ -260,7 +276,7 @@ export async function getPythonEnvPath(
? majorMinorMatches[1]
: "x.x";
const resultVersion = `idf${espIdfVersion}_py${pythonVersion}_env`;
const idfPyEnvPath = path.join(idfToolsDir, "python_env", resultVersion);
const idfPyEnvPath = join(idfToolsDir, "python_env", resultVersion);

return idfPyEnvPath;
}
Expand Down
Loading

0 comments on commit 2b2e660

Please sign in to comment.