-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Makefile
156 lines (118 loc) · 5.53 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
.PHONY: dist
# Compile the binaries for all targets.
build: \
build-x86_64-unknown-linux-musl \
build-aarch64-unknown-linux-musl \
build-armv5te-unknown-linux-musleabi \
build-armv7-unknown-linux-musleabihf \
build-mips-unknown-linux-musl \
build-mipsel-unknown-linux-musl
build-x86_64-unknown-linux-musl:
cross build --target x86_64-unknown-linux-musl --release
build-aarch64-unknown-linux-musl:
cross build --target aarch64-unknown-linux-musl --release
build-armv5te-unknown-linux-musleabi:
cross build --target armv5te-unknown-linux-musleabi --release
build-armv7-unknown-linux-musleabihf:
cross build --target armv7-unknown-linux-musleabihf --release
build-mips-unknown-linux-musl:
# mips is a tier-3 target.
rustup toolchain add nightly-2024-05-17-x86_64-unknown-linux-gnu
cross +nightly-2024-05-17 build -Z build-std=panic_abort,std --target mips-unknown-linux-musl --release --no-default-features --features semtech_udp
build-mipsel-unknown-linux-musl:
# mipsel is a tier-3 target.
rustup toolchain add nightly-2024-05-17-x86_64-unknown-linux-gnu
cross +nightly-2024-05-17 build -Z build-std=panic_abort,std --target mipsel-unknown-linux-musl --release --no-default-features --features semtech_udp
# Build distributable binaries for all targets.
dist: \
dist-x86_64-unknown-linux-musl \
dist-aarch64-unknown-linux-musl \
dist-armv5te-unknown-linux-musleabi \
dist-armv7-unknown-linux-musleabihf \
dist-mips-unknown-linux-musl \
dist-mipsel-unknown-linux-musl
dist-x86_64-unknown-linux-musl: build-x86_64-unknown-linux-musl package-x86_64-unknown-linux-musl
dist-aarch64-unknown-linux-musl: build-aarch64-unknown-linux-musl package-aarch64-unknown-linux-musl
dist-armv5te-unknown-linux-musleabi: build-armv5te-unknown-linux-musleabi package-armv5te-unknown-linux-musleabi
dist-armv7-unknown-linux-musleabihf: build-armv7-unknown-linux-musleabihf package-armv7-unknown-linux-musleabihf
dist-mips-unknown-linux-musl: build-mips-unknown-linux-musl package-mips-unknown-linux-musl
dist-mipsel-unknown-linux-musl: build-mipsel-unknown-linux-musl package-mipsel-unknown-linux-musl
# Package the compiled binaries
package-x86_64-unknown-linux-musl:
$(eval PKG_VERSION := $(shell cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version'))
mkdir -p dist
# .tar.gz
tar -czvf dist/chirpstack-mqtt-forwarder_$(PKG_VERSION)_amd64.tar.gz -C target/x86_64-unknown-linux-musl/release chirpstack-mqtt-forwarder
# .deb
cargo deb --target x86_64-unknown-linux-musl --no-build --no-strip
cp target/x86_64-unknown-linux-musl/debian/*.deb ./dist
package-aarch64-unknown-linux-musl:
$(eval PKG_VERSION := $(shell cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version'))
mkdir -p dist
# .tar.gz
tar -czvf dist/chirpstack-mqtt-forwarder_$(PKG_VERSION)_arm64.tar.gz -C target/aarch64-unknown-linux-musl/release chirpstack-mqtt-forwarder
# .deb
cargo deb --target aarch64-unknown-linux-musl --no-build --no-strip
cp target/aarch64-unknown-linux-musl/debian/*.deb ./dist
package-armv7-unknown-linux-musleabihf: package-tektelic-kona package-kerlink-klkgw package-multitech-conduit-ap3
$(eval PKG_VERSION := $(shell cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version'))
mkdir -p dist
# .tar.gz
tar -czvf dist/chirpstack-mqtt-forwarder_$(PKG_VERSION)_armv7hf.tar.gz -C target/armv7-unknown-linux-musleabihf/release chirpstack-mqtt-forwarder
# .deb
cargo deb --target armv7-unknown-linux-musleabihf --no-build --no-strip
cp target/armv7-unknown-linux-musleabihf/debian/*.deb ./dist
package-armv5te-unknown-linux-musleabi: package-multitech-conduit package-multitech-conduit-ap
package-mips-unknown-linux-musl: package-dragino
package-mipsel-unknown-linux-musl: package-rak-mipsel_24kc
# Gateway specific packaging.
package-dragino:
cd packaging/vendor/dragino/mips_24kc && ./package.sh
mkdir -p dist/vendor/dragino/mips_24kc
cp packaging/vendor/dragino/mips_24kc/*.ipk dist/vendor/dragino/mips_24kc
package-multitech-conduit:
cd packaging/vendor/multitech/conduit && ./package.sh
mkdir -p dist/vendor/multitech/conduit
cp packaging/vendor/multitech/conduit/*.ipk dist/vendor/multitech/conduit
package-multitech-conduit-ap:
cd packaging/vendor/multitech/conduit_ap && ./package.sh
mkdir -p dist/vendor/multitech/conduit_ap
cp packaging/vendor/multitech/conduit_ap/*.ipk dist/vendor/multitech/conduit_ap
package-multitech-conduit-ap3:
cd packaging/vendor/multitech/conduit_ap3 && ./package.sh
mkdir -p dist/vendor/multitech/conduit_ap3
cp packaging/vendor/multitech/conduit_ap3/*.ipk dist/vendor/multitech/conduit_ap3
package-rak-mipsel_24kc:
cd packaging/vendor/rak/mipsel_24kc && ./package.sh
mkdir -p dist/vendor/rak/mipsel_24kc
cp packaging/vendor/rak/mipsel_24kc/*.ipk dist/vendor/rak/mipsel_24kc
package-tektelic-kona:
cd packaging/vendor/tektelic/kona && ./package.sh
mkdir -p dist/vendor/tektelic/kona
cp packaging/vendor/tektelic/kona/*.ipk dist/vendor/tektelic/kona
package-kerlink-klkgw:
cd packaging/vendor/kerlink/klkgw && ./package.sh
mkdir -p dist/vendor/kerlink/klkgw
cp packaging/vendor/kerlink/klkgw/*.ipk dist/vendor/kerlink/klkgw
# Update the version.
version:
test -n "$(VERSION)"
sed -i 's/^ version.*/ version = "$(VERSION)"/g' ./Cargo.toml
make test
git add .
git commit -v -m "Bump version to $(VERSION)"
git tag -a v$(VERSION) -m "v$(VERSION)"
# Cleanup dist.
clean:
cargo clean
rm -rf dist
# Run tests
test:
cargo clippy --no-deps
cargo test
# Enter the devshell.
devshell:
nix-shell
# Enter the Docker based devshell.
docker-devshell:
docker compose run --rm chirpstack-mqtt-forwarder