forked from helium/gateway-rs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile.toml
202 lines (165 loc) · 5.37 KB
/
Makefile.toml
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
[config]
additional_profiles = ["klkgw", "ramips_24kec", "smartharvest", "dragino", "mtcdt", "raspi01", "raspi234", "resiot", "cotx", "raspi_64", "caldigit", "tektelic", "risinghf", "clodpi", "cloudgate"]
default_to_workspace = false
[env]
TAR = { source = "${CARGO_MAKE_RUST_TARGET_OS}", default_value = "linux", mapping = {"macos" = "gtar", "linux" = "tar" } }
AR = "ar"
PKG_BUILD_DIR ="target/pkg/${CARGO_MAKE_PROFILE}"
PKG_SRC_DIR = "package/${CARGO_MAKE_PROFILE}"
[env.raspi01]
CROSS_TARGET = "arm-unknown-linux-gnueabihf"
PKG = "deb"
[env.raspi234]
CROSS_TARGET = "armv7-unknown-linux-gnueabihf"
PKG = "deb"
[env.raspi_64]
CROSS_TARGET = "aarch64-unknown-linux-gnu"
PKG = "deb"
[env.x86_64]
CROSS_TARGET = "x86_64-unknown-linux-gnu"
PKG = "deb"
[env.klkgw]
CROSS_TARGET = "armv7-unknown-linux-musleabihf"
PKG = "ipk"
IPK_USE_AR = false
[env.ramips_24kec]
CROSS_TARGET = "mipsel-unknown-linux-musl"
PKG = "ipk"
IPK_USE_AR = false
[env.smartharvest]
CROSS_TARGET = "mipsel-unknown-linux-musl"
PKG = "ipk"
IPK_USE_AR = false
[env.dragino]
CROSS_TARGET = "mips-unknown-linux-musl"
PKG = "ipk"
IPK_USE_AR = false
[env.mtcdt]
CROSS_TARGET = "armv5te-unknown-linux-musleabi"
PKG = "ipk"
IPK_USE_AR = true
[env.resiot]
CROSS_TARGET = "armv7-unknown-linux-gnueabihf"
PKG = "ipk"
IPK_USE_AR = true
[env.cotx]
CROSS_TARGET = "aarch64-unknown-linux-gnu"
PKG = "deb"
[env.tektelic]
CROSS_TARGET = "armv7-unknown-linux-gnueabihf"
PKG = "ipk"
IPK_USE_AR = true
[env.caldigit]
CROSS_TARGET = "mipsel-unknown-linux-musl"
PKG = "ipk"
IPK_USE_AR = false
[env.risinghf]
CROSS_TARGET = "armv7-unknown-linux-gnueabihf"
PKG = "deb"
[env.clodpi]
CROSS_TARGET = "mipsel-unknown-linux-musl"
PKG = "ipk"
IPK_USE_AR = false
[env.cloudgate]
CROSS_TARGET = "armv5te-unknown-linux-musleabi"
PKG = "ipk"
IPK_USE_AR = true
[tasks.cross]
description = "Runs the cross rust compiler."
category = "Build"
install_crate = false
condition = { env_set = ["CROSS_TARGET"] }
command = "cross"
args = [
"build",
"--target",
"${CROSS_TARGET}",
"--release"
]
[tasks.pkg]
description = "Builds a package for a given packaging profile"
category = "Package"
condition = { env_set = ["PKG"]}
env = { "PKG_NAME" = "helium-gateway-v${CARGO_MAKE_CRATE_VERSION}-${CARGO_MAKE_PROFILE}.${PKG}"}
run_task = [
{ name = "ipk", condition = { env = { "PKG" = "ipk" } } },
{ name = "deb", condition = { env = { "PKG" = "deb" } } }
]
[tasks.ipk]
description = "Builds an ipk for openwrt/opk based targets"
category = "Package"
dependencies = ["cross"]
condition = { env_set = ["CROSS_TARGET", "TAR", "AR", "PKG_NAME", "IPK_USE_AR"] }
env = { "PKG_BUILD_DIR" = "target/pkg/${CARGO_MAKE_PROFILE}", "PKG_SRC_DIR" = "package/${CARGO_MAKE_PROFILE}" }
script = '''
# make base folder
mkdir -p ${PKG_BUILD_DIR}
echo 2.0 > ${PKG_BUILD_DIR}/debian-binary
# install data files
cp -R ${PKG_SRC_DIR}/data ${PKG_BUILD_DIR}
# inject default.toml
cp -R config/default.toml ${PKG_BUILD_DIR}/data/etc/helium_gateway
# install binary
mkdir -p ${PKG_BUILD_DIR}/data/usr/bin
cp target/${CROSS_TARGET}/release/helium_gateway ${PKG_BUILD_DIR}/data/usr/bin
# install control files
mkdir -p ${PKG_BUILD_DIR}/control
export CARGO_MAKE_PROFILE CARGO_MAKE_CRATE_VERSION
envsubst < config/conffiles > ${PKG_BUILD_DIR}/control/conffiles
chmod +x ${PKG_BUILD_DIR}/control/conffiles
for control_file in control preinst postinst prerm; do
envsubst "$(printf '${%s} ' $(env | sed 's/=.*//'))" < ${PKG_SRC_DIR}/control/${control_file} > ${PKG_BUILD_DIR}/control/${control_file}
chmod +x ${PKG_BUILD_DIR}/control/${control_file}
done
# package together
cd ${PKG_BUILD_DIR}/control
${TAR} --numeric-owner --group=0 --owner=0 -czf ../control.tar.gz ./*
cd ${CARGO_MAKE_WORKING_DIRECTORY}
cd ${PKG_BUILD_DIR}/data
${TAR} --numeric-owner --group=0 --owner=0 -czf ../data.tar.gz ./*
cd ${CARGO_MAKE_WORKING_DIRECTORY}
cd ${PKG_BUILD_DIR}
if ${IPK_USE_AR} ; then
rm -f ../${PKG_NAME}
${AR} r ../${PKG_NAME} ./debian-binary ./data.tar.gz ./control.tar.gz
else
${TAR} --numeric-owner --group=0 --owner=0 -czf ../${PKG_NAME} ./debian-binary ./data.tar.gz ./control.tar.gz
fi
cd ${CARGO_MAKE_WORKING_DIRECTORY}
'''
[tasks.deb]
description = "Builds a deb package for debian based targets"
category = "Package"
dependencies = ["cross"]
condition = { env_set = ["CROSS_TARGET", "PKG_NAME"] }
script = '''
# make base folder
mkdir -p ${PKG_BUILD_DIR}
# install data files
cp -R ${PKG_SRC_DIR}/data ${PKG_BUILD_DIR}
# inject default.toml
cp -R config/default.toml ${PKG_BUILD_DIR}/data/etc/helium_gateway
# install binary
mkdir -p ${PKG_BUILD_DIR}/data/usr/bin
cp target/${CROSS_TARGET}/release/helium_gateway ${PKG_BUILD_DIR}/data/usr/bin
# install control files
mkdir -p ${PKG_BUILD_DIR}/control
export CARGO_MAKE_PROFILE CARGO_MAKE_CRATE_VERSION
for control_file in service preinst postinst prerm; do
envsubst < ${PKG_SRC_DIR}/control/${control_file} > ${PKG_BUILD_DIR}/control/${control_file}
chmod +x ${PKG_BUILD_DIR}/control/${control_file}
done
# create manifest
envsubst < config/metadata.deb.toml > ${PKG_BUILD_DIR}/Cargo.toml
# package together
cd ${PKG_BUILD_DIR}
cargo deb -v --no-build --target ${CROSS_TARGET} -o ../${PKG_NAME}
'''
[tasks.ci]
dependencies = ["check-format", "check-clippy"]
[tasks.check-format]
command = "cargo"
args = ["fmt", "--", "--check"]
[tasks.check-clippy]
command = "cargo"
args = ["clippy", "--", "--deny=clippy::all"]