Skip to content

Commit fdf7ee2

Browse files
docs: Add podman-vscode-build skill (project-chip#72579)
* docs: Add podman-vscode-build skill Change-Id: Id8bc6d6cdb5d022f71615dc9b180808dc28c59e9 * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent deb13a9 commit fdf7ee2

2 files changed

Lines changed: 234 additions & 0 deletions

File tree

.agents/skills.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@ etc.) to assist with development and code review in the Matter repository.
1919
Pull Request descriptions.
2020
- **Triggers**: Use when preparing or writing descriptions for pull requests.
2121

22+
### Podman VSCode Build
23+
24+
- **Location**: `.agents/skills/podman-vscode-build/`
25+
- **Purpose**: Guidelines for building and testing Matter examples using
26+
Podman with the official vscode build image in a non-interactive
27+
environment.
28+
- **Triggers**: Use when running builds or tests inside a Podman container,
29+
especially when targeting embedded or cross-compiled platforms.
30+
2231
## Using Skills
2332

2433
AI agents will automatically discover and load these skills when they are
Lines changed: 225 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,225 @@
1+
---
2+
name: podman-vscode-build
3+
description:
4+
Guidelines for building Matter examples and running tests using Podman with
5+
the vscode image in a non-interactive environment.
6+
---
7+
8+
# Building and Testing Matter with Podman (VSCode Build Image)
9+
10+
This skill provides guidelines and instructions for configuring, launching, and
11+
executing build/test commands within a Podman container using the official
12+
`ghcr.io/project-chip/chip-build-vscode` image.
13+
14+
Podman runs rootless, which avoids file ownership complications (where files
15+
generated in the container are owned by root on the host) commonly encountered
16+
with Docker.
17+
18+
---
19+
20+
## 1. Prerequisites & Host Configuration
21+
22+
Before launching Podman, you must configure storage to avoid namespace and user
23+
limit errors (e.g., insufficient UIDs or GIDs in the user namespace).
24+
25+
### Edit storage.conf
26+
27+
Edit or create `$HOME/.config/containers/storage.conf` to include:
28+
29+
```toml
30+
[storage]
31+
driver = "overlay"
32+
33+
[storage.options]
34+
ignore_chown_errors = "true"
35+
```
36+
37+
### System Reset & Verification
38+
39+
If you previously attempted to use Podman without this setting, you may need to
40+
reset the storage.
41+
42+
> [!CAUTION] Running `podman system reset` will delete all existing Podman
43+
> containers, images, and volumes.
44+
45+
1. Reset Podman:
46+
```bash
47+
podman system reset
48+
```
49+
2. Verify that `graphDriverName` is `overlay` (instead of `vfs`):
50+
```bash
51+
podman info | grep graphDriverName
52+
```
53+
54+
---
55+
56+
## 2. Locating the VSCode Image Tag
57+
58+
The correct tag for `ghcr.io/project-chip/chip-build-vscode` changes as
59+
dependencies are updated. To find the tag currently used in CI:
60+
61+
- Inspect the workflow files under `.github/workflows/` (such as `tests.yaml`
62+
or `build.yaml`) or the cloudbuild configurations under
63+
`integrations/cloudbuild/` (such as `chef.yaml`).
64+
- Search for the image reference
65+
`ghcr.io/project-chip/chip-build-vscode:<TAG>` to identify the correct
66+
version tag (e.g., `200`).
67+
68+
---
69+
70+
## 3. Starting the Container
71+
72+
To start a persistent vscode container in the background:
73+
74+
```bash
75+
podman run -dt --cap-add=SYS_PTRACE --name bld_vscode \
76+
--volume /path/to/connectedhomeip:/workspace \
77+
ghcr.io/project-chip/chip-build-vscode:<TAG> \
78+
/bin/sh
79+
```
80+
81+
_Replace `/path/to/connectedhomeip` with the absolute path to your local
82+
repository checkout, and `<TAG>` with the version tag found in step 2._
83+
84+
---
85+
86+
## 4. Non-Interactive Command Execution
87+
88+
Since agents run in a non-interactive environment, do **NOT** use interactive
89+
flags like `-it` (e.g. `podman exec -it ...`). Instead, execute commands
90+
directly or script them.
91+
92+
### Activation is Mandatory
93+
94+
Because `podman exec` does not load login shell initialization scripts, the
95+
Pigweed build environment is **not activated by default**. Sourcing the
96+
environment activation script is required prior to compiling.
97+
98+
- **Bootstrap**: Use `scripts/bootstrap.sh` if this is the first time setup
99+
inside the container, or if packages or submodules have changed.
100+
- **Activate**: Use `scripts/activate.sh` for subsequent runs.
101+
102+
Run the commands in a single subshell using `bash -c`:
103+
104+
```bash
105+
podman exec -w /workspace bld_vscode bash -c "source scripts/activate.sh && ./scripts/build/build_examples.py --target <target> build"
106+
```
107+
108+
### Sourcing Bootstrap for Specific Platforms
109+
110+
By default, running `bootstrap.sh` inside the container installs python
111+
requirements for host and Zephyr builds. To enable building for other specific
112+
embedded platforms (which downloads/configures additional pip dependencies),
113+
pass the platform names to the `-p` parameter:
114+
115+
```bash
116+
podman exec -w /workspace bld_vscode bash -c "source scripts/bootstrap.sh -p esp32,nrfconnect,silabs,telink"
117+
```
118+
119+
Supported platform identifiers include: `esp32`, `nrfconnect`, `silabs`,
120+
`telink`, `bouffalolab`, `mbed`, `ti`, `zephyr`.
121+
122+
### Additional ESP32 Setup
123+
124+
If building for the ESP32 platform, the ESP-IDF toolchain Python requirements
125+
inside the container must also be explicitly set up. Run the following command
126+
inside the container after bootstrapping:
127+
128+
```bash
129+
podman exec -w /workspace bld_vscode bash -c "/opt/espressif/esp-idf/install.sh"
130+
```
131+
132+
### Additional Nordic nRF Connect Setup
133+
134+
If compiling for Nordic nRF Connect targets, the pre-installed SDK files must be
135+
synchronized and updated before building. Discard local template modifications
136+
first, then run the update script inside the container:
137+
138+
```bash
139+
podman exec -w /workspace bld_vscode git -C /opt/NordicSemiconductor/nrfconnect/zephyr checkout -- zephyr-env.sh
140+
podman exec -w /workspace bld_vscode bash -c "source scripts/activate.sh && python3 scripts/setup/nrfconnect/update_ncs.py --update --shallow"
141+
```
142+
143+
---
144+
145+
## 5. Platform Build Examples & Output Directories
146+
147+
Using Podman with the official vscode image is particularly valuable when
148+
compiling for embedded or cross-compiled targets, as the image pre-packages all
149+
required toolchains and compilers.
150+
151+
Here are examples of compiling Matter applications (e.g., `all-devices-app` or
152+
`all-clusters-app`) for various platforms and where the executables/artifacts
153+
are generated:
154+
155+
### A. Linux ARM64 (e.g. Raspberry Pi)
156+
157+
- **Target**: `linux-arm64-all-devices-boringssl-no-ble-clang`
158+
- **Build Command**:
159+
```bash
160+
podman exec -w /workspace bld_vscode bash -c "source scripts/activate.sh && ./scripts/build/build_examples.py --target linux-arm64-all-devices-boringssl-no-ble-clang build"
161+
```
162+
- **Output Artifact**:
163+
`<checkout_root>/out/linux-arm64-all-devices-boringssl-no-ble-clang/all-devices-app`
164+
165+
### B. ESP32 (devkitc)
166+
167+
- **Target**: `esp32-devkitc-all-devices`
168+
- **Build Command**:
169+
```bash
170+
podman exec -w /workspace bld_vscode bash -c "source scripts/activate.sh && ./scripts/build/build_examples.py --target esp32-devkitc-all-devices build"
171+
```
172+
- **Output Artifacts**:
173+
`<checkout_root>/out/esp32-devkitc-all-devices/all-devices-app.elf` and
174+
`all-devices-app.bin`
175+
176+
### C. Silicon Labs EFR32 (brd4187c)
177+
178+
- **Target**: `efr32-brd4187c-all-devices`
179+
- **Build Command**:
180+
```bash
181+
podman exec -w /workspace bld_vscode bash -c "source scripts/activate.sh && ./scripts/build/build_examples.py --target efr32-brd4187c-all-devices build"
182+
```
183+
- **Output Artifacts**:
184+
`<checkout_root>/out/efr32-brd4187c-all-devices/matter-silabs-all-devices-example.out`
185+
(and `.hex` / `.s37`)
186+
187+
### D. Nordic nRF Connect (nrf52840dk)
188+
189+
_Note: Building with the Zephyr SDK toolchain requires setting
190+
`ZEPHYR_TOOLCHAIN_VARIANT=zephyr` explicitly._
191+
192+
- **Target**: `nrf-nrf52840dk-all-clusters`
193+
- **Build Command**:
194+
```bash
195+
podman exec -w /workspace bld_vscode bash -c "export ZEPHYR_TOOLCHAIN_VARIANT=zephyr && source scripts/activate.sh && ./scripts/build/build_examples.py --target nrf-nrf52840dk-all-clusters build"
196+
```
197+
- **Output Artifacts**:
198+
`<checkout_root>/out/nrf-nrf52840dk-all-clusters/merged.hex` (contains both
199+
bootloader and app) and `zephyr/zephyr.elf`
200+
201+
### E. Telink (tlsr9518adk80d)
202+
203+
- **Target**: `telink-tlsr9518adk80d-all-devices`
204+
- **Build Command**:
205+
```bash
206+
podman exec -w /workspace bld_vscode bash -c "source scripts/activate.sh && ./scripts/build/build_examples.py --target telink-tlsr9518adk80d-all-devices build"
207+
```
208+
- **Output Artifacts**:
209+
`<checkout_root>/out/telink-tlsr9518adk80d-all-devices/zephyr/zephyr.bin`
210+
211+
---
212+
213+
## 6. Accessing Build Artifacts
214+
215+
Because the repository root is mounted as a volume
216+
(`--volume /path/to/connectedhomeip:/workspace`), any build outputs written to
217+
`/workspace/out/` inside the container are **immediately accessible** on the
218+
host filesystem at `<checkout_root>/out/`.
219+
220+
There is **no need** to copy binaries using `podman cp`. You can access or run
221+
the built binary directly from your host repository checkout:
222+
223+
```bash
224+
cp out/<target>/<binary_name> /path/to/destination
225+
```

0 commit comments

Comments
 (0)