#!/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