-
-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathMakefile
More file actions
263 lines (210 loc) · 7.23 KB
/
Copy pathMakefile
File metadata and controls
263 lines (210 loc) · 7.23 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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
# Variables used to talk to your pi. Set these up in your env, or set them on the command
# line when invoking make
# Which Pi to copy files to and ssh into
#PI_TARGET := pizero2w0.local
# The User name of your user on the pi, to be able to copy files and ssh into it
#PI_USER := andrew
# default target: "make" ran on macos or linux host should build these binaries:
# target/debug/piggui - GUI version without GPIO, to enable UI development on a host
# target/aarch64-unknown-linux-gnu/release/piggui - GUI version for Pi with GPIO, can be run natively from RPi command line
# target/armv7-unknown-linux-gnueabihf/release/piggui - GUI version for armv7 based architecture with GPIO, can be run natively
# Detect if on a Raspberry Pi
$(eval PI = $(shell cat /proc/cpuinfo 2>&1 | grep "Raspberry Pi"))
OSFLAG :=
ifeq ($(OS),Windows_NT)
OSFLAG:=windows
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
OSFLAG:=linux
endif
ifeq ($(UNAME_S),Darwin)
OSFLAG:=macos
endif
endif
.PHONY: all
all: clippy format-check build build-arm build-armv7 build-aarch64 build-porky build-web test
.PHONY: clean
clean:
@cargo clean
@rm -rf _site
.PHONY: macos-setup
macos-setup:
@echo "Running macos specific setup"
@cmake -C piggui macos-setup
@make -C pigglet macos-setup
.PHONY: linux-setup
linux-setup:
@echo "Running linux specific setup"
sudo apt install gcc-arm-linux-gnueabihf
sudo apt install gcc-aarch64-linux-gnu
.PHONY: setup
setup:
ifeq ($(OSFLAG),macos)
$(MAKE) macos-setup
else
$(MAKE) linux-setup
endif
@cargo install mlc
@cargo install cargo-all-features
@make -C piggui setup
@make -C pigglet setup
@make -C porky setup
.PHONY: clippy
clippy:
cargo clippy --tests --no-deps --all-features --all-targets
cargo clippy --manifest-path=hw_test/Cargo.toml --tests --no-deps --all-features --all-targets
.PHONY: format-check
format-check:
cargo fmt --all -- --check
.PHONY: build
build:
cargo build
cargo build --manifest-path=hw_test/Cargo.toml
.PHONY: run
run:
cargo run --bin piggui
.PHONY: run-release
run-release:
cargo run --bin piggui --release
.PHONY: run-pigglet
run-pigglet:
cargo run --bin pigglet
.PHONY: run-release-pigglet
run-release-pigglet:
cargo run --bin pigglet --release
.PHONY: build-release
build-release:
cargo build --release
.PHONY: build-porky
build-porky:
make -C porky
.PHONY: test
test:
cargo test -- --show-output
.PHONY: hw_tests
hw_tests: build
make -C hw_test
.PHONY: features
features:
cargo build-all-features
#### armv7 targets
# Don't build build-armv7-musl locally on macOS
.PHONY: armv7
armv7: clippy-armv7 build-armv7
.PHONY: clippy-armv7
clippy-armv7:
cargo clippy --tests --no-deps --target=armv7-unknown-linux-gnueabihf
.PHONY: build-armv7
build-armv7:
cargo build --target=armv7-unknown-linux-gnueabihf
.PHONY: build-armv7-musl
build-armv7-musl:
cargo build --target=armv7-unknown-linux-musleabihf
.PHONY: build-release-armv7
build-release-armv7:
cargo build --release --target=armv7-unknown-linux-gnueabihf
# NOTE: The tests will be built for armv7 architecture, so tests can only be run on that architecture
.PHONY: test-armv7
test-armv7:
cargo test --target=armv7-unknown-linux-gnueabihf
.PHONY: copy-armv7
copy-armv7:
scp target/armv7-unknown-linux-gnueabihf/debug/piggui $(PI_USER)@$(PI_TARGET):~/
scp target/armv7-unknown-linux-gnueabihf/debug/pigglet $(PI_USER)@$(PI_TARGET):~/
.PHONY: copy-release-armv7
copy-release-armv7:
scp target/armv7-unknown-linux-gnueabihf/release/piggui $(PI_USER)@$(PI_TARGET):~/
scp target/armv7-unknown-linux-gnueabihf/release/pigglet $(PI_USER)@$(PI_TARGET):~/
#### aarch64 targets
.PHONY: aarch64
aarch64: clippy-aarch64 build-aarch64
.PHONY: clippy-aarch64
clippy-aarch64:
cargo clippy --tests --no-deps --target=aarch64-unknown-linux-gnu
.PHONY: build-aarch64
build-aarch64:
cargo build --target=aarch64-unknown-linux-gnu
.PHONY: build-release-aarch64
build-release-aarch64:
cargo build --release --target=aarch64-unknown-linux-gnu
# NOTE: The tests will be built for aarch64 architecture, so tests can only be run on that architecture
.PHONY: test-aarch64
test-aarch64:
cargo test --target=aarch64-unknown-linux-gnu
.PHONY: copy-aarch64
copy-aarch64:
scp target/aarch64-unknown-linux-gnu/debug/piggui $(PI_USER)@$(PI_TARGET):~/
scp target/aarch64-unknown-linux-gnu/debug/pigglet $(PI_USER)@$(PI_TARGET):~/
.PHONY: copy-release-aarch64
copy-release-aarch64:
scp target/aarch64-unknown-linux-gnu/release/piggui $(PI_USER)@$(PI_TARGET):~/
scp target/aarch64-unknown-linux-gnu/release/pigglet $(PI_USER)@$(PI_TARGET):~/
#### arm targets - useful for Raspberry Pi Zero (not Zero 2)
# Don't build build-arm-musl by default
.PHONY: arm
arm: clippy-arm build-arm
.PHONY: clippy-arm
clippy-arm:
cargo clippy --tests --no-deps --target=arm-unknown-linux-gnueabihf
.PHONY: build-arm
build-arm:
cargo build --target=arm-unknown-linux-gnueabihf
.PHONY: build-arm-musl
build-arm-musl:
cargo build --target=arm-unknown-linux-musleabihf
.PHONY: build-release-arm
build-release-arm:
cargo build --release --target=arm-unknown-linux-gnueabihf
# NOTE: The tests will be built for arm architecture, so tests can only be run on that architecture
.PHONY: test-arm
test-arm:
cargo test --target=arm-unknown-linux-gnueabihf
.PHONY: copy-arm
copy-arm:
scp target/arm-unknown-linux-gnueabihf/debug/pigglet $(PI_USER)@$(PI_TARGET):~/
scp target/arm-unknown-linux-gnueabihf/debug/piggui $(PI_USER)@$(PI_TARGET):~/
.PHONY: copy-release-arm
copy-release-arm:
scp target/arm-unknown-linux-gnueabihf/release/pigglet $(PI_USER)@$(PI_TARGET):~/
scp target/arm-unknown-linux-gnueabihf/release/piggui $(PI_USER)@$(PI_TARGET):~/
.PHONY: ssh
ssh:
ssh $(PI_USER)@$(PI_TARGET)
.PHONY: usb
usb:
@echo "Echo your root password at the prompt to copy udev rules for piggui to the system folder for them"
sudo cp 70.pigg.rules /etc/udev/rules.d/
.PHONY: clean-start
clean-start:
@find . -name "*.profraw" | xargs rm -rf {}
.PHONY: coverage
coverage: clean-start
@echo "coverage<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
@RUSTFLAGS="-C instrument-coverage" LLVM_PROFILE_FILE="pigg-%p-%m.profraw" cargo build
cargo test
@echo "Gathering coverage information"
@grcov . --binary-path target/debug/ -s . -t lcov --branch --ignore-not-existing --ignore "/*" -o coverage.info
@lcov --remove coverage.info 'target/debug/build/**' 'target/release/build/**' '**/errors.rs' '**/build.rs' '*tests/*' --ignore-errors unused,unused --ignore-errors unsupported --ignore-errors inconsistent --ignore-errors empty,empty -o coverage.info --erase-functions "(?=^.*fmt).+"
@find . -name "*.profraw" | xargs rm -f
@echo "Generating coverage report"
@genhtml -o target/coverage --quiet coverage.info
@echo "View coverage report using 'open target/coverage/index.html'"
.PHONY: jonesy
jonesy: build
jonesy --config jonesy.toml
.PHONY: e2e
e2e: build-web
cd tests/e2e && npm ci && npx playwright test --reporter=list
.PHONY: build-web
build-web:
RUSTFLAGS='--cfg getrandom_backend="wasm_js"' trunk build --release --config piggui/Trunk.toml
.PHONY: web-run
web-run: build-web
RUSTFLAGS='--cfg getrandom_backend="wasm_js"' trunk serve --release --config piggui/Trunk.toml
docs:
bundle exec jekyll build --source site --destination _site
mlc _site
surge _site
serve-docs:
bundle exec jekyll serve --source site --destination _site