-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJustfile
More file actions
201 lines (163 loc) · 7.89 KB
/
Justfile
File metadata and controls
201 lines (163 loc) · 7.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
# OS-agnostic build/test/release entrypoints. Mirrors the legacy Makefile
# targets 1:1; the Makefile is now a thin deprecation wrapper that defers
# to these recipes.
#
# Install just:
# mise install # picks up the version pinned in mise.toml
# brew install just # macOS / Linuxbrew
# scoop install just # Windows (scoop)
# cargo install just # any platform with Rust
#
# Run `just --list` to see all recipes.
set windows-shell := ["pwsh.exe", "-NoProfile", "-Command"]
binary := "onvif-simulator"
cli_out := if os_family() == "windows" { "bin/onvif-simulator.exe" } else { "bin/onvif-simulator" }
frontend_dist := "internal/gui/frontend/dist"
# Pinned mediamtx-rpicamera release tag. mediamtx-rpicamera lives in its own
# repo (bluenviron/mediamtx-rpicamera) with versioning independent from
# mediamtx itself; mediamtx v1.18.1 internally pins this same v2.5.6 (see
# its internal/staticsources/rpicamera/mtxrpicamdownloader/VERSION). Bump
# together with scripts/mtxrpicam.sha256 so the Pi build channel ships a
# reviewable, reproducible binary blob.
mtxrpicam_version := env_var_or_default('MTXRPICAM_VERSION', 'v2.5.6')
rpicam_dir_32 := "internal/rpicamera/mtxrpicam_32"
rpicam_dir_64 := "internal/rpicamera/mtxrpicam_64"
# Per-platform ffmpeg targets the simulator embeds for the MJPEG transcoder
# (Profile S §7.9). Bump with scripts/ffmpeg.sha256 in lockstep so each
# build channel ships a reproducible, hash-verified binary blob. Each tuple
# corresponds to one entry under internal/ffmpeg/binaries/<goos>_<goarch>/.
ffmpeg_targets := "linux_amd64 linux_arm64 linux_arm darwin_amd64 darwin_arm64 windows_amd64 windows_arm64"
docs_port := env_var_or_default('DOCS_PORT', '8080')
# Default: list all recipes.
default:
@just --list
# Build CLI and GUI binaries.
build: cli gui
# Build CLI/TUI binary.
cli:
go build -o {{cli_out}} ./cmd/cli
# Build GUI binary (requires Wails CLI).
gui: _frontend-dist
cd cmd/gui && wails build
# Build GUI for Windows (NSIS installer).
gui-windows: _frontend-dist
cd cmd/gui && wails build -nsis -platform windows/amd64
# Build GUI for macOS (amd64).
gui-darwin: _frontend-dist
cd cmd/gui && wails build -platform darwin/amd64
# Build GUI for Linux (amd64, webkit2_41 build tag).
gui-linux: _frontend-dist
cd cmd/gui && wails build -platform linux/amd64 -tags webkit2_41
# Ensure the frontend bundle exists. Skipped when already present so repeat
# invocations don't pay the npm install cost on every test/lint run.
[unix]
_frontend-dist:
@if [ ! -d "{{frontend_dist}}" ]; then cd internal/gui/frontend && npm install && npm run build; fi
# Ensure the frontend bundle exists. Skipped when already present so repeat
# invocations don't pay the npm install cost on every test/lint run.
[windows]
_frontend-dist:
@if (-not (Test-Path '{{frontend_dist}}')) { cd internal/gui/frontend && npm install && npm run build }
# Build CLI for both Raspberry Pi targets (arm + arm64).
cli-rpi: cli-rpi-arm cli-rpi-arm64
# Build CLI for Raspberry Pi 32-bit (linux/arm, ARMv7).
[unix]
cli-rpi-arm: rpicam-fetch
GOOS=linux GOARCH=arm GOARM=7 CGO_ENABLED=0 go build -tags rpicam -o bin/{{binary}}-rpi-arm ./cmd/cli
# Build CLI for Raspberry Pi 32-bit (linux/arm, ARMv7).
[windows]
cli-rpi-arm: rpicam-fetch
$env:GOOS = 'linux'; $env:GOARCH = 'arm'; $env:GOARM = '7'; $env:CGO_ENABLED = '0'; go build -tags rpicam -o bin/{{binary}}-rpi-arm ./cmd/cli
# Build CLI for Raspberry Pi 64-bit (linux/arm64).
[unix]
cli-rpi-arm64: rpicam-fetch
GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -tags rpicam -o bin/{{binary}}-rpi-arm64 ./cmd/cli
# Build CLI for Raspberry Pi 64-bit (linux/arm64).
[windows]
cli-rpi-arm64: rpicam-fetch
$env:GOOS = 'linux'; $env:GOARCH = 'arm64'; $env:CGO_ENABLED = '0'; go build -tags rpicam -o bin/{{binary}}-rpi-arm64 ./cmd/cli
# Fetch mtxrpicam helper binaries for the Pi channel (idempotent).
[unix]
rpicam-fetch:
./scripts/fetch-mtxrpicam.sh 32 {{mtxrpicam_version}} {{rpicam_dir_32}}
./scripts/fetch-mtxrpicam.sh 64 {{mtxrpicam_version}} {{rpicam_dir_64}}
# Fetch mtxrpicam helper binaries for the Pi channel (PowerShell on Windows).
[windows]
rpicam-fetch:
pwsh -NoProfile -File ./scripts/fetch-mtxrpicam.ps1 -WordSize 32 -Version '{{mtxrpicam_version}}' -DestDir '{{rpicam_dir_32}}'
pwsh -NoProfile -File ./scripts/fetch-mtxrpicam.ps1 -WordSize 64 -Version '{{mtxrpicam_version}}' -DestDir '{{rpicam_dir_64}}'
# Fetch a real ffmpeg binary for every supported (goos, goarch). Idempotent
# — fetch-ffmpeg.sh skips targets that already have a >= 1 MiB binary in
# place. Pin the per-archive SHA-256s in scripts/ffmpeg.sha256 before
# running; the script refuses unpinned downloads.
[unix]
ffmpeg-fetch:
for t in {{ffmpeg_targets}}; do \
goos="$(echo $t | cut -d_ -f1)"; \
goarch="$(echo $t | cut -d_ -f2-)"; \
./scripts/fetch-ffmpeg.sh "$goos" "$goarch"; \
done
# Fetch a real ffmpeg binary for every supported (goos, goarch). Idempotent.
# Windows: PowerShell ports under scripts/*.ps1 (same pins as fetch-ffmpeg.sh).
[windows]
ffmpeg-fetch:
foreach ($t in '{{ffmpeg_targets}}'.Split(' ')) { $parts = $t.Split('_', 2); pwsh -NoProfile -File ./scripts/fetch-ffmpeg.ps1 -Goos $parts[0] -Goarch $parts[1] }
# Cross-compile rpicam-tagged code for both Pi targets (no upstream fetch).
[unix]
rpicam-build-check:
GOOS=linux GOARCH=arm GOARM=7 CGO_ENABLED=0 go build -tags rpicam ./...
GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -tags rpicam ./...
# Cross-compile rpicam-tagged code for both Pi targets (no upstream fetch).
[windows]
rpicam-build-check:
$env:GOOS = 'linux'; $env:GOARCH = 'arm'; $env:GOARM = '7'; $env:CGO_ENABLED = '0'; go build -tags rpicam ./...
$env:GOOS = 'linux'; $env:GOARCH = 'arm64'; $env:CGO_ENABLED = '0'; go build -tags rpicam ./...
# Run go formatters across all packages.
format:
golangci-lint fmt ./...
# Run linter across all packages.
lint: _frontend-dist
golangci-lint run ./...
# Run unit tests (Go + frontend).
test: test-go test-frontend
# Run Go unit tests with the race detector.
test-go: _frontend-dist
go test -race ./internal/... ./cmd/...
# Run frontend unit tests with coverage.
test-frontend:
cd internal/gui/frontend && npm run test:coverage
# Run Go tests and print coverage summary.
coverage: _frontend-dist
go test ./internal/... ./cmd/... -coverprofile=coverage.out -covermode=atomic
go tool cover -func=coverage.out
# Run E2E SOAP suite against a running simulator (honors ONVIF_HOST, ONVIF_USERNAME, ONVIF_PASSWORD).
[unix]
e2e:
ONVIF_HOST="${ONVIF_HOST:-localhost:8080}" ONVIF_USERNAME="${ONVIF_USERNAME:-admin}" ONVIF_PASSWORD="${ONVIF_PASSWORD:-}" go test ./test/e2e/... -tags e2e -v
# Run E2E SOAP suite against a running simulator (honors ONVIF_HOST, ONVIF_USERNAME, ONVIF_PASSWORD).
[windows]
e2e:
if (-not $env:ONVIF_HOST) { $env:ONVIF_HOST = 'localhost:8080' }; \
if (-not $env:ONVIF_USERNAME) { $env:ONVIF_USERNAME = 'admin' }; \
if (-not $env:ONVIF_PASSWORD) { $env:ONVIF_PASSWORD = '' }; \
go test ./test/e2e/... -tags e2e -v
# Remove build artifacts. Scoped to ./bin and ./build/bin — the rest of
# ./build (Wails appicon, NSIS installer template, darwin Info.plist, …)
# is tracked source and must survive `clean`.
[unix]
clean:
rm -rf ./bin ./build/bin
# Remove build artifacts. Scoped to ./bin and ./build/bin — the rest of
# ./build (Wails appicon, NSIS installer template, darwin Info.plist, …)
# is tracked source and must survive `clean`.
[windows]
clean:
if (Test-Path ./bin) { Remove-Item -Recurse -Force ./bin }
if (Test-Path ./build/bin) { Remove-Item -Recurse -Force ./build/bin }
# One-time repo setup: install npm deps and wire up git hooks.
setup:
npm install
git config core.hooksPath .githooks
# Browse Go docs in a local browser. Override DOCS_PORT to use a different port.
manual:
go run ./cmd/manual -port={{docs_port}}