-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
207 lines (166 loc) · 6.97 KB
/
Copy pathMakefile
File metadata and controls
207 lines (166 loc) · 6.97 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
202
203
204
205
206
207
# Byonk Makefile
# Build software and documentation
export PATH := $(HOME)/.cargo/bin:$(PATH)
.PHONY: all build release debug run clean docs docs-dev check fmt lint test ha-setup ha-check fonts fonts-setup fonts-check help
# Default target
all: release
# =============================================================================
# Software Build
# =============================================================================
# Build release binary (runs fmt and clippy first)
release: fmt lint
cargo build --release
# Build debug binary (runs fmt and clippy first)
debug: fmt lint
cargo build
# Alias for debug build
build: debug
# Local-testing env: use the developer's config.yaml + live screens/fonts.
# The shipped/embedded default (default-config.yaml) stays device-free; this
# only affects local `make run`/`watch`, not what byonk ships with.
DEV_RUN_ENV = CONFIG_FILE=config.yaml SCREENS_DIR=screens FONTS_DIR=fonts
# Run the server (debug mode)
run: fmt lint
$(DEV_RUN_ENV) cargo run
# Run the server (release mode)
run-release: release
$(DEV_RUN_ENV) ./target/release/byonk
# Run with auto-reload (requires cargo-watch)
watch:
$(DEV_RUN_ENV) cargo watch -x run
# Format code
fmt:
cargo fmt
# Run clippy linter
#
# --workspace --all-targets, because the bare form checks only the root
# package's non-test targets. That silently skipped every crate under
# crates/ and every test file in the repo.
lint:
cargo clippy --workspace --all-targets -- -D warnings
# Run tests
#
# --workspace: `cargo test` alone runs only the root package, so the
# eink-dither suite never ran here and a failing test in it still reported
# "All checks passed!".
test:
cargo test --workspace
# Coverage configuration for Homebrew Rust (set LLVM paths)
# For rustup users, these variables are not needed
LLVM_PREFIX ?= $(shell brew --prefix llvm 2>/dev/null || echo "")
ifneq ($(LLVM_PREFIX),)
export LLVM_COV := $(LLVM_PREFIX)/bin/llvm-cov
export LLVM_PROFDATA := $(LLVM_PREFIX)/bin/llvm-profdata
endif
# Run tests with coverage (requires cargo-llvm-cov)
# Install: cargo install cargo-llvm-cov
coverage:
cargo llvm-cov --html --open
# Generate coverage report for CI (lcov format)
coverage-ci:
cargo llvm-cov --lcov --output-path lcov.info
# Generate coverage report (text summary)
coverage-text:
cargo llvm-cov --summary-only
# Clean build artifacts
clean:
cargo clean
rm -rf docs/book
rm -f lcov.info
# =============================================================================
# Documentation (mdBook)
# =============================================================================
# Build documentation
docs:
cd docs && mdbook build
# Start documentation dev server
docs-dev:
cd docs && mdbook serve
# Generate sample screen images (auto-starts server if needed)
docs-samples: release
./docs/generate-samples.sh
# =============================================================================
# Development Helpers
# =============================================================================
# Check everything before commit
check: fmt lint test
@echo "All checks passed!"
# =============================================================================
# X11 Bitmap Fonts
# =============================================================================
#
# The importer needs only Python and fontTools -- no FontForge, no potrace and
# no X11 installation -- so the shipped fonts can be rebuilt and checked
# anywhere. Its venv is kept apart from the Home Assistant one so the two
# dependency sets cannot collide.
fonts-setup: ## create .venv-fonts (run once before 'make fonts')
uv venv --python 3.13 .venv-fonts
uv pip install --python .venv-fonts -r fonts/requirements.txt
fonts-check: ## run the importer's own tests
.venv-fonts/bin/python -m pytest fonts/tests -q
fonts: fonts-check ## rebuild the 26 X11 TTFs from their pinned BDF sources
.venv-fonts/bin/python fonts/x11-importer.py
# =============================================================================
# Home Assistant Integration
# =============================================================================
ha-setup:
uv venv --python 3.13 .venv
uv pip install --python .venv -r requirements_test.txt
ha-check: ## run ruff + pytest for the HA integration (run 'make ha-setup' once first)
.venv/bin/ruff check custom_components/byonk
.venv/bin/python -m pytest tests_ha -q
# =============================================================================
# Help
# =============================================================================
help:
@echo "Byonk Makefile"
@echo ""
@echo "Software:"
@echo " make build Build debug binary (runs fmt + clippy)"
@echo " make release Build release binary (runs fmt + clippy)"
@echo " make run Run server in debug mode"
@echo " make run-release Run server in release mode"
@echo " make watch Run with auto-reload (needs cargo-watch)"
@echo " make fmt Format code"
@echo " make lint Run clippy"
@echo " make test Run tests"
@echo " make check Format, lint, and test"
@echo " make clean Clean all build artifacts"
@echo ""
@echo "Coverage (requires cargo-llvm-cov):"
@echo " make coverage Generate HTML coverage report and open in browser"
@echo " make coverage-ci Generate lcov.info for CI integration"
@echo " make coverage-text Print coverage summary to terminal"
@echo ""
@echo "Documentation:"
@echo " make docs Build documentation"
@echo " make docs-dev Start docs dev server"
@echo " make docs-samples Generate sample images (auto-starts server)"
@echo ""
@echo "X11 bitmap fonts:"
@echo " make fonts-setup Create .venv-fonts (run once)"
@echo " make fonts-check Run the font importer's tests"
@echo " make fonts Rebuild the 26 X11 TTFs from pinned BDF sources"
@echo ""
@echo "Home Assistant VM:"
@echo " make ha-vm Boot the Home Assistant OS test VM (headless)"
@echo " make ha-vm-stop Stop a running test VM"
@echo " make ha-vm-clean Delete the test VM disk + varstore (full reset)"
@echo " make ha-deploy Sync the integration into the VM (needs SMB_USER/SMB_PASS)"
@echo " make ha-ssh Open an SSH shell in the VM (needs Terminal & SSH add-on)"
@echo " make ha-rebuild Sync server source + rebuild the add-on (SMB + SSH)"
@echo ""
@echo " make help Show this help"
.PHONY: ha-vm ha-vm-stop ha-vm-clean ha-deploy ha-ssh ha-rebuild
ha-vm: ## Boot the Home Assistant OS test VM (headless)
bash tools/ha-vm/run.sh
ha-vm-stop: ## Stop a running test VM
-pkill -f 'name byonk-haos'
ha-vm-clean: ## Delete the test VM disk + varstore (full reset)
rm -rf tools/ha-vm/work
ha-deploy: ## Sync custom_components/byonk into the running test VM (needs SMB_USER/SMB_PASS)
bash tools/ha-vm/deploy.sh
ha-ssh: ## Open an SSH shell in the test VM, or run a command: make ha-ssh CMD="ha addons info local_byonk"
bash tools/ha-vm/ssh.sh $(CMD)
ha-rebuild: ## Sync server source + rebuild the byonk add-on (needs SMB_USER/SMB_PASS + SSH setup)
bash tools/ha-vm/rebuild.sh