1
0
Fork 0
mirror of https://github.com/eosswedenorg/antelope-keygen synced 2026-06-18 04:00:03 +02:00

build.sh: switch to "getopt" command and handle "--disable-threads" and "--force-ansi" long options.

This commit is contained in:
Henrik Hautakoski 2020-01-28 12:54:07 +01:00
parent 693c7aa069
commit 826ad10ce9

View file

@ -4,24 +4,41 @@ mkdir build 2> /dev/null
pushd build > /dev/null
function usage() {
echo "Usage: ${0##*/} [ -h ] [ -t Debug|Release|RelWithDebInfo|MinSizeRel ]"
echo "Usage: ${0##*/} [ -h ] [ -t Debug|Release|RelWithDebInfo|MinSizeRel ] [ --disable-threads ] [ --force-ansi ]"
exit 1
}
ARGS=""
while getopts ":h?t:" opt; do
options=$(getopt -n "${0##*/}" -o ht: --long disable-threads --long force-ansi -- "$@")
case "${opt}" in
t) ARGS="${ARGS} -DCMAKE_BUILD_TYPE=${OPTARG}" ;;
h) usage ;;
:) echo "Error: -${OPTARG} requires a value"
exit 1
[ $? -eq 0 ] || usage
eval set -- "$options"
ARGS=""
while true; do
case "${1}" in
-t)
shift
[[ ! "$1" =~ ^(Debug|Release|RelWithDebInfo|MinSizeRel)$ ]] && {
echo "Incorrect type '$1' provided"
usage
}
ARGS="${ARGS} -DCMAKE_BUILD_TYPE=${1}"
;;
--disable-threads)
ARGS="${ARGS} -DUSE_THREADS=OFF" ;;
--force-ansi)
ARGS="${ARGS} -DFORCE_ANSI=ON" ;;
-h) usage ;;
--) shift
break
;;
esac
shift
done
shift $((OPTIND-1))
cmake $ARGS $@ ..
echo cmake $ARGS ..
make -B
popd > /dev/null