// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/python
{
	"name": "Python 3",
	// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
	"image": "mcr.microsoft.com/devcontainers/python:1-3.11-bookworm",

	// Features to add to the dev container. More info: https://containers.dev/features.
	// "features": {},
	"features": {
		"ghcr.io/devcontainers-contrib/features/apt-get-packages:1": {
			"packages": "usbutils,libusb-1.0,texinfo,libftdi1,libtinfo5,gdb-arm-none-eabi,gcc-arm-none-eabi,cmake"
		}
	},

	// Use 'forwardPorts' to make a list of ports inside the container available locally.
	// "forwardPorts": [],
	
	"runArgs": [
		"-v", "/dev/bus/usb:/dev/bus/usb", 
		"-v", "/usr/lib/udev/hwdb.bin:/usr/lib/udev/hwdb.bin:ro", 
		"-v", "/lib/udev/hwdb.bin:/lib/udev/hwdb.bin:ro", 
		"-v", "/usr/share/hwdata/usb.ids:/usr/share/hwdata/usb.ids:ro", 
		"-v", "/run/udev:/run/udev", 
		"-v", "/sys:/sys:ro",
		"--privileged",
		"--device-cgroup-rule", "c 188:* rmw",
		"--device-cgroup-rule", "c 166:* rmw"
	],

	"mounts": [
		{
			"source": "${localWorkspaceFolder}/../esphome",
			"target": "${containerWorkspaceFolder}/../esphome",
			"type": "bind"
		},
		{
			"source": "${localEnv:HOME}/.platformio",
			"target": "/home/vscode/.platformio",
			"type": "bind"
		},
		{
			"source": "${localWorkspaceFolder}/../rp2040",
			"target": "${containerWorkspaceFolder}/../rp2040",
			"type": "bind"
		},
		{
			"source": "/opt/openocd-rp2040",
			"target": "/opt/openocd-rp2040",
			"type": "bind"
		}
	],

	// Use 'postCreateCommand' to run commands after the container is created.
	"postCreateCommand": "pip3 install -r requirements.txt",

	// Configure tool-specific properties.
	"customizations": {
		"vscode": {
			"extensions": [
				"ms-vscode.cpptools-extension-pack",
				"jbenden.c-cpp-flylint",
				"ESPHome.esphome-vscode",
				"ms-python.vscode-pylance",
				"marus25.cortex-debug",
				"ms-vscode.cpptools",
				"ms-vscode.cmake-tools",
				"mikestead.dotenv",
				"ZixuanWang.linkerscript",
				"alefragnani.Bookmarks",
				"ciprianelies.arm-assembly-syntax"
			]
		}
	},

	// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
	// "remoteUser": "root"
}