detached 5ce5026

docs: add PipeWire generator maintenance workflow

commit
5ce50261ef917a217551d2947144f7e4f6e005fc
author
brice · · 2026-04-09 07:49 UTC
parent
96c5c6a
signature
GPG VerifiedCD88F9E564E0102646FB6077A1A07C7C7C3E349D · arch-gpg Verified for the committer email
4 files · +91 -0
M README.md +7 -0
@@ -25,6 +25,13 @@ Mocks are generated by [mockery](https://github.com/vektra/mockery):
2525
2626 mockery
2727
28+### Maintainer workflow
29+
30+Maintainers can refresh the model from local PipeWire and SPA headers with:
31+
32+ ./scripts/sync-headers.sh
33+ go generate ./...
34+
2835 ## Requirements
2936
3037 - Go 1.23+
@@ -25,6 +25,13 @@ Mocks are generated by [mockery](https://github.com/vektra/mockery):
25 25
26 mockery26 mockery
27 27
28+### Maintainer workflow
29+
30+Maintainers can refresh the model from local PipeWire and SPA headers with:
31+
32+ ./scripts/sync-headers.sh
33+ go generate ./...
34+
28 ## Requirements35 ## Requirements
29 36
30 - Go 1.23+37 - Go 1.23+
A cmd/pipewiregen/README.md +57 -0
@@ -0,0 +1,57 @@
1+# pipewiregen
2+
3+The `pipewiregen` tool generates Go bindings for PipeWire and SPA libraries from JSON model files.
4+
5+## Usage
6+
7+### Generate bindings from checked-in models
8+
9+ go run ./cmd/pipewiregen
10+
11+This reads `gen/pipewire.json` and `gen/spa.json`, then emits:
12+- `internal/capi/*_gen.go` — raw function types and registration helpers
13+- `internal/ports/out/*_gen.go` — outbound port interfaces
14+
15+### Sync headers from system includes (maintainers)
16+
17+ ./scripts/sync-headers.sh
18+
19+Or run directly:
20+
21+ go run ./cmd/pipewiregen --sync-headers \
22+ --pipewire-include /usr/include/pipewire-0.3 \
23+ --spa-include /usr/include/spa-0.2 \
24+ --out-dir gen
25+
26+## Model format
27+
28+The JSON model files follow this structure:
29+
30+```json
31+{
32+ "libraries": [
33+ {"name": "pipewire", "soname": "libpipewire-0.3.so.0"}
34+ ],
35+ "groups": [
36+ {"name": "init", "interface": "InitAPI", "package": "out", "symbols": ["pw_init", "pw_deinit"]}
37+ ],
38+ "symbols": [
39+ {"name": "pw_init", "library": "pipewire", "group": "init", "signature": "func(argc *int32, argv ***byte)"}
40+ ]
41+}
42+```
43+
44+- `libraries`: Shared libraries to load
45+- `groups`: Symbol groupings that become Go interfaces
46+- `symbols`: Individual function symbols with their Go signatures
47+
48+## Architecture
49+
50+The generator follows a pipeline design:
51+
52+1. **parser**: Loads and validates JSON model files
53+2. **model**: Core data structures for libraries, groups, and symbols
54+3. **normalize**: PipeWire-specific naming conventions
55+4. **emitter**: Renders Go code from templates
56+
57+See the individual package directories for implementation details.
@@ -0,0 +1,57 @@
1+# pipewiregen
2+
3+The `pipewiregen` tool generates Go bindings for PipeWire and SPA libraries from JSON model files.
4+
5+## Usage
6+
7+### Generate bindings from checked-in models
8+
9+ go run ./cmd/pipewiregen
10+
11+This reads `gen/pipewire.json` and `gen/spa.json`, then emits:
12+- `internal/capi/*_gen.go` — raw function types and registration helpers
13+- `internal/ports/out/*_gen.go` — outbound port interfaces
14+
15+### Sync headers from system includes (maintainers)
16+
17+ ./scripts/sync-headers.sh
18+
19+Or run directly:
20+
21+ go run ./cmd/pipewiregen --sync-headers \
22+ --pipewire-include /usr/include/pipewire-0.3 \
23+ --spa-include /usr/include/spa-0.2 \
24+ --out-dir gen
25+
26+## Model format
27+
28+The JSON model files follow this structure:
29+
30+```json
31+{
32+ "libraries": [
33+ {"name": "pipewire", "soname": "libpipewire-0.3.so.0"}
34+ ],
35+ "groups": [
36+ {"name": "init", "interface": "InitAPI", "package": "out", "symbols": ["pw_init", "pw_deinit"]}
37+ ],
38+ "symbols": [
39+ {"name": "pw_init", "library": "pipewire", "group": "init", "signature": "func(argc *int32, argv ***byte)"}
40+ ]
41+}
42+```
43+
44+- `libraries`: Shared libraries to load
45+- `groups`: Symbol groupings that become Go interfaces
46+- `symbols`: Individual function symbols with their Go signatures
47+
48+## Architecture
49+
50+The generator follows a pipeline design:
51+
52+1. **parser**: Loads and validates JSON model files
53+2. **model**: Core data structures for libraries, groups, and symbols
54+3. **normalize**: PipeWire-specific naming conventions
55+4. **emitter**: Renders Go code from templates
56+
57+See the individual package directories for implementation details.
A pipewire/readme_test.go +20 -0
@@ -0,0 +1,20 @@
1+package pipewire
2+
3+import (
4+ "os"
5+ "strings"
6+ "testing"
7+)
8+
9+func TestReadmeMentionsGenerateAndMockery(t *testing.T) {
10+ b, err := os.ReadFile("../README.md")
11+ if err != nil {
12+ t.Fatalf("ReadFile returned error: %v", err)
13+ }
14+ text := string(b)
15+ for _, needle := range []string{"go generate ./...", "mockery", "gen/pipewire.json"} {
16+ if !strings.Contains(text, needle) {
17+ t.Fatalf("README missing %q", needle)
18+ }
19+ }
20+}
@@ -0,0 +1,20 @@
1+package pipewire
2+
3+import (
4+ "os"
5+ "strings"
6+ "testing"
7+)
8+
9+func TestReadmeMentionsGenerateAndMockery(t *testing.T) {
10+ b, err := os.ReadFile("../README.md")
11+ if err != nil {
12+ t.Fatalf("ReadFile returned error: %v", err)
13+ }
14+ text := string(b)
15+ for _, needle := range []string{"go generate ./...", "mockery", "gen/pipewire.json"} {
16+ if !strings.Contains(text, needle) {
17+ t.Fatalf("README missing %q", needle)
18+ }
19+ }
20+}
A scripts/sync-headers.sh +7 -0
@@ -0,0 +1,7 @@
1+#!/usr/bin/env bash
2+set -euo pipefail
3+
4+go run ./cmd/pipewiregen --sync-headers \
5+ --pipewire-include "${PIPEWIRE_INCLUDE_DIR:-/usr/include/pipewire-0.3}" \
6+ --spa-include "${SPA_INCLUDE_DIR:-/usr/include/spa-0.2}" \
7+ --out-dir gen
@@ -0,0 +1,7 @@
1+#!/usr/bin/env bash
2+set -euo pipefail
3+
4+go run ./cmd/pipewiregen --sync-headers \
5+ --pipewire-include "${PIPEWIRE_INCLUDE_DIR:-/usr/include/pipewire-0.3}" \
6+ --spa-include "${SPA_INCLUDE_DIR:-/usr/include/spa-0.2}" \
7+ --out-dir gen

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 8

↑↓ moveenter openesc close