-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathMakefile
171 lines (135 loc) · 5.05 KB
/
Makefile
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
# 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/aarch64-unknown-linux-gnu/release/piglet - Headless 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
# target/armv7-unknown-linux-gnueabihf/release/piglet - Headless version for armv7 based architecture with GPIO, can be run natively
# MacOS pre-requisites for cross-compiling to armv7
# brew install arm-linux-gnueabihf-binutils
# rustup target add armv7-unknown-linux-musleabihf
#
# See: https://github.com/messense/homebrew-macos-cross-toolchains
#
# brew tap messense/macos-cross-toolchains
# brew install aarch64-unknown-linux-gnu
# brew install arm-unknown-linux-gnueabihf
# brew install arm-unknown-linux-musleabihf
# Detect if on a Raspberry Pi
$(eval PI = $(shell cat /proc/cpuinfo 2>&1 | grep "Raspberry Pi"))
.PHONY: all
all: clippy build build-arm build-porky test
.PHONY: clean
clean:
@cargo clean
.PHONY: clippy
clippy:
cargo clippy --tests --no-deps
# Enable the "iced" feature so we only build the "piggui" binary on the current host (macos, linux or raspberry pi)
# To build both binaries on a Pi directly, we will need to modify this
.PHONY: build
build:
cargo build
.PHONY: run
run:
cargo run
.PHONY: run-release
run-release:
cargo run --release
.PHONY: run-piglet
run-piglet:
cargo run --bin piglet
.PHONY: run-release-piglet
run-release-piglet:
cargo run --bin piglet --release
# This will build all binaries on the current host, be it macos, linux or raspberry pi - with release profile
.PHONY: build-release
build-release:
cargo build --release
.PHONY: build-porky
build-porky:
cd porky && $(MAKE)
# This will only test GUI tests in piggui on the local host, whatever that is
# We'd need to think how to run tests on RºPi, on piggui with GUI and GPIO functionality,
# and piglet with GPIO functionality
.PHONY: test
test:
cargo test
.PHONY: features
features:
cargo build-all-features
#### arm builds
.PHONY: build-arm
# Don't build build-armv7-musl locally on macOS
build-arm: build-armv7 build-aarch64
#### 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: release-build-armv7
release-build-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/piglet $(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/piglet $(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: release-build-aarch64
release-build-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/piglet $(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/piglet $(PI_USER)@$(PI_TARGET):~/
.PHONY: ssh
ssh:
ssh $(PI_USER)@$(PI_TARGET)
.PHONY: web-build
web-build:
rustup target add wasm32-unknown-unknown
cargo build --target wasm32-unknown-unknown --no-default-features
.PHONY: web-run
web-run: web-build
trunk serve
.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/