2
0
mirror of https://github.com/rehlds/rehlds.git synced 2025-01-12 14:48:00 +03:00

build.sh add help [skip ci]

This commit is contained in:
s1lentq 2021-04-13 05:39:29 +07:00
parent 1d15946cff
commit 13e2db3423

View File

@ -1,39 +1,60 @@
#!/bin/bash #!/bin/bash
CC=gcc main()
CXX=g++ {
CC=gcc
CXX=g++
n=0 if [[ "$*" =~ "--help" ]]; then
args=() help
for i in "$@" exit 0;
do fi
case $i in
-j=*|--jobs=*)
jobs="-j${i#*=}"
shift
;;
-c=*|--compiler=*)
C="${i#*=}"
shift
;;
*)
args[$n]="$i"
((++n))
;;
esac
done
case "$C" in n=0
("intel"|"icc") CC=icc CXX=icpc ;; args=()
("gcc") CC=gcc CXX=g++ ;; for i in "$@"
("clang") CC=clang CXX=clang++ ;; do
*) case $i in
;; -j=*|--jobs=*)
esac jobs="-j${i#*=}"
shift
;;
-c=*|--compiler=*)
C="${i#*=}"
shift
;;
*)
args[$n]="$i"
((++n))
;;
esac
done
rm -rf build case "$C" in
mkdir build ("intel"|"icc") CC=icc CXX=icpc ;;
pushd build &> /dev/null ("gcc"|"g++") CC=gcc CXX=g++ ;;
CC=$CC CXX=$CXX cmake ${args[@]} .. ("clang|llvm") CC=clang CXX=clang++ ;;
make ${jobs} *)
popd > /dev/null ;;
esac
rm -rf build
mkdir build
pushd build &> /dev/null
CC=$CC CXX=$CXX cmake ${args[@]} ..
make ${jobs}
popd > /dev/null
}
help()
{
printf "Usage: ./build.sh <options>\n\n"
printf " -c= | --compiler=<icc|gcc|clang> - Select preferred C/C++ compiler to build\n"
printf " -j= | --jobs=<N> - Specifies the number of jobs (commands) to run simultaneously (For faster building)\n\n"
}
# Initialize
main $*
# Exit normally
exit 0