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
#!/bin/bash
function confirm() {
echo -n "$@ [y/N]: "
read -e answer
for response in y Y
do
if [ "_$answer" == "_$response" ]
then
return 0
fi
done
# default to no
return 1
}
function buildmusl() {
# build a docker image with the required libs
docker build -f Dockerfile.alpine -t laurelinclient-musl-builder .
# create the target dir
mkdir ../target
mkdir ../.cargo-cache
# use the docker image to build an executable
docker run --rm --user "$(id -u)":"$(id -g)" \
-v "$PWD":/usr/src/client \
-v "$PWD/../target":/usr/src/target \
-v "$PWD/../Cargo.toml":/usr/src/Cargo.toml \
-v "$PWD/../Cargo.lock":/usr/src/Cargo.lock \
-v "$PWD/../.cargo":/usr/src/.cargo \
-v "$PWD/../.cargo-cache":/usr/src/.cargo-cache \
-e CARGO_HOME=/usr/src/.cargo-cache \
-w /usr/src/ \
laurelinclient-musl-builder \
cargo build --release
}
function buildglibc() {
cargo build
}
if confirm musl?
then
buildmusl
else
buildglibc
fi