Updated VS Code (markdown)

Andrew Leech 2023-05-25 11:07:58 +10:00
parent f5778336cb
commit a0286149e2
1 changed files with 71 additions and 1 deletions

@ -60,3 +60,73 @@ Here's a copy of my `.vscode/settings.json` files:
# devcontainer
VS Code [devcontainer](https://code.visualstudio.com/docs/devcontainers/containers) feature allows your coding environment to be hosted inside a docker container, providing all the tools and consistent environment of that docker container, without needing to install everything onto your computer manually.
This can be set up quickly by adding a `.devcontainer.json` file to the root folder of your project, after which VS Code will ask in a popup if you want to re-open your project in the container.
Here's an example `.devcontainer.json` micropython project file you could base yours on:
``` json
{
"name": "Micropython Project",
"image": "micropython/unix:latest",
"containerEnv": {
"DEVCONTAINER": "1"
},
"runArgs": [
"-e",
"GIT_EDITOR=code --wait",
// Docker will clean up the container and remove the file system when
// the system exits
"--rm",
// -e will set environment variables
// SSH_AUTH_SOCK is used to specify the ssh permission files
"-eSSH_AUTH_SOCK=/run/user/1000/keyring/ssh",
// Specify the work directory as the local workspace folder
"-w${localWorkspaceFolder}",
// Tell docker to use the same user as the host is using. Value should
// match output of the command "id -u".
"--user=1000:1000",
"-eHOME=/home",
// Use the same display, and network ports, as the host. (This allows
// graphical applications, such as JFlashLite, to be launched in the
// container environment)
"--env=\"DISPLAY\"",
"--hostname=Micropython",
"--add-host=Micropython:127.0.0.1",
"--net=host",
// By default, docker does not allow access to the host computer's
// devices. This option adds permission for docker to access the host
// computer's decices, allowing utilities like JFlashLite to work
// properly
"--privileged"
],
"customizations": {
"vscode": {
"extensions": [
// Python development
"ms-python.python",
"ms-python.vscode-pylance",
// Extensions recommended by vscode for C++ development
"ms-vscode.cpptools-extension-pack",
"ms-vscode.makefile-tools",
// Allows user to debug ST devices, using the settings recommended in:
// https://gitlab.pi.planetinnovation.com.au/lonsdale/firmware/code-editor-settings
"marus25.cortex-debug",
// Other helpful extensions
"visualstudioexptteam.vscodeintellicode",
"redhat.vscode-yaml",
"esbenp.prettier-vscode",
]
}
},
"updateRemoteUserUID": true,
"mounts": [
// Map user ssh settings & auth to container for git use.
"source=${localEnv:HOME}/.ssh,target=${localEnv:HOME}/.ssh,type=bind,consistency=cached",
// Provide USB access to container
"type=bind,source=/dev/bus/usb,target=/dev/bus/usb",
// Provide docker-in-docker support
"type=bind,source=/var/run/docker.sock,target=/var/run/docker.sock"
]
}
```
The image used could be swapped from `micropython/unix:latest` to `espressif/idf:release-v4.4` if you want to compile for esp32, or one with arm-none-eabi-gcc like `registry.gitlab.com/alelec/docker-arm-none-eabi:latest` for building arm ports like stm32 or mimxrt.