Skip to content

Commit

Permalink
build.sh add help [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
s1lentq committed Apr 12, 2021
1 parent f57f3d7 commit 69b0003
Showing 1 changed file with 58 additions and 37 deletions.
95 changes: 58 additions & 37 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,39 +1,60 @@
#!/bin/bash

CC=gcc
CXX=g++

n=0
args=()
for i in "$@"
do
case $i in
-j=*|--jobs=*)
jobs="-j${i#*=}"
shift
;;
-c=*|--compiler=*)
C="${i#*=}"
shift
;;
*)
args[$n]="$i"
((++n))
;;
esac
done

case "$C" in
("intel"|"icc") CC=icc CXX=icpc ;;
("gcc"|"g++") CC=gcc CXX=g++ ;;
("clang|llvm") CC=clang CXX=clang++ ;;
*)
;;
esac

rm -rf build
mkdir build
pushd build &> /dev/null
CC=$CC CXX=$CXX cmake ${args[@]} ..
make ${jobs}
popd > /dev/null
main()
{
CC=gcc
CXX=g++

if [[ "$*" =~ "--help" ]]; then
help
exit 0;
fi

n=0
args=()
for i in "$@"
do
case $i in
-j=*|--jobs=*)
jobs="-j${i#*=}"
shift
;;
-c=*|--compiler=*)
C="${i#*=}"
shift
;;
*)
args[$n]="$i"
((++n))
;;
esac
done

case "$C" in
("intel"|"icc") CC=icc CXX=icpc ;;
("gcc"|"g++") CC=gcc CXX=g++ ;;
("clang|llvm") CC=clang CXX=clang++ ;;
*)
;;
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

0 comments on commit 69b0003

Please sign in to comment.