-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathMakefile
More file actions
163 lines (132 loc) · 4.82 KB
/
Makefile
File metadata and controls
163 lines (132 loc) · 4.82 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
# Makefile for Papyrix Reader firmware
# Wraps PlatformIO commands for convenience
.PHONY: all build build-release release upload upload-release flash flash-release \
clean format check monitor size erase build-fs upload-fs sleep-screen gh-release changelog help \
test test-build test-run test-clean fontconvert-bin reader-test
# Default target
all: help
# Build targets
build: ## Build firmware (default environment)
pio run
build-release: ## Build release firmware
pio run -e gh_release
release: build-release ## Alias for build-release
# Upload targets
upload: ## Build and flash to device
pio run --target upload
upload-release: ## Build and flash release firmware
pio run -e gh_release --target upload
# Aliases
flash: upload ## Alias for upload
flash-release: upload-release ## Alias for upload-release
# Clean
clean: ## Clean build artifacts
pio run --target clean
# Code quality
format: ## Format code with clang-format
./bin/clang-format-fix
check: ## Run static analysis (cppcheck)
pio check
# Device/debug
monitor: ## Open serial monitor
pio device monitor
size: ## Show firmware size
pio run --target size
erase: ## Erase device flash
pio run --target erase
# Filesystem
build-fs: ## Build filesystem image
pio run --target buildfs
upload-fs: ## Upload filesystem to device
pio run --target uploadfs
# Release
tag: ## Create and push a version tag (triggers GitHub release)
@read -p "Enter tag version (e.g., 1.0.0): " TAG; \
if [[ $$TAG =~ ^[0-9]+\.[0-9]+\.[0-9]+$$ ]]; then \
git tag -a v$$TAG -m "v$$TAG"; \
git push origin v$$TAG; \
echo "Tag v$$TAG created and pushed successfully."; \
else \
echo "Invalid tag format. Please use X.Y.Z (e.g., 1.0.0)"; \
exit 1; \
fi
gh-release: build-release ## Create GitHub release with firmware
ifndef VERSION
$(error VERSION is required. Usage: make gh-release VERSION=0.1.1 [NOTES="..."])
endif
ifdef NOTES
gh release create v$(VERSION) .pio/build/gh_release/firmware.bin \
--repo bigbag/papyrix-reader \
--title "Papyrix v$(VERSION)" \
--notes "$(NOTES)"
else
gh release create v$(VERSION) .pio/build/gh_release/firmware.bin \
--repo bigbag/papyrix-reader \
--title "Papyrix v$(VERSION)" \
--generate-notes
endif
changelog: ## Generate CHANGELOG.md from git history
@echo "Generating CHANGELOG.md..."
@echo "" > CHANGELOG.md; \
previous_tag=0; \
for current_tag in $$(git tag --sort=-creatordate); do \
if [ "$$previous_tag" != 0 ]; then \
tag_date=$$(git log -1 --pretty=format:'%ad' --date=short $${previous_tag}); \
printf "\n## $${previous_tag} ($${tag_date})\n\n" >> CHANGELOG.md; \
git log $${current_tag}...$${previous_tag} --pretty=format:'* %s [[%an](mailto:%ae)]' --reverse | grep -v Merge >> CHANGELOG.md; \
printf "\n" >> CHANGELOG.md; \
fi; \
previous_tag=$${current_tag}; \
done; \
if [ "$$previous_tag" != 0 ]; then \
tag_date=$$(git log -1 --pretty=format:'%ad' --date=short $${previous_tag}); \
printf "\n## $${previous_tag} ($${tag_date})\n\n" >> CHANGELOG.md; \
git log $${previous_tag} --pretty=format:'* %s [[%an](mailto:%ae)]' --reverse | grep -v Merge >> CHANGELOG.md; \
printf "\n" >> CHANGELOG.md; \
fi
@echo "CHANGELOG.md generated successfully."
# Image conversion
sleep-screen: ## Convert image to sleep screen BMP
ifdef INPUT
ifdef OUTPUT
cd scripts && node create-sleep-screen.mjs ../$(INPUT) ../$(OUTPUT) $(ARGS)
else
@echo "Usage: make sleep-screen INPUT=<image> OUTPUT=<bmp> [ARGS='--dither --bits 8']"
endif
else
@echo "Usage: make sleep-screen INPUT=<image> OUTPUT=<bmp> [ARGS='--dither --bits 8']"
@echo "Example: make sleep-screen INPUT=photo.jpg OUTPUT=sleep.bmp"
endif
## Unit Tests:
test: test-build test-run ## Build and run all unit tests
test-build: ## Build unit tests
@mkdir -p test/build
@cd test/build && cmake .. -DCMAKE_BUILD_TYPE=Debug && cmake --build . --parallel
test-run: ## Run unit tests (build first if needed)
@if [ ! -d test/build/bin ]; then $(MAKE) test-build; fi
@test/scripts/run_tests.sh
test-clean: ## Clean test build artifacts
@rm -rf test/build
## Tools:
fontconvert-bin: ## Build Go fontconvert-bin tool (CJK .bin font converter)
$(MAKE) -C tools/fontconvert-bin build
reader-test: ## Build desktop reader-test tool (process books without flashing)
@mkdir -p tools/reader-test/build
@cd tools/reader-test/build && cmake .. && cmake --build . --parallel
@echo "Built: tools/reader-test/build/reader-test"
ifdef FILE
@tools/reader-test/build/reader-test $(FILE) $(OUTPUT)
endif
## Help:
help: ## Show this help
@echo "Papyrix Reader - Build System"
@echo ""
@echo "Usage: make [target]"
@echo ""
@awk 'BEGIN {FS = ":.*##"; section=""} \
/^##/ { section=substr($$0, 4); next } \
/^[a-zA-Z_-]+:.*##/ { \
if (section != "") { printf "\n\033[1m%s\033[0m\n", section; section="" } \
printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 \
}' $(MAKEFILE_LIST)
@echo ""