Skip to content

Commit 13e2db3

Browse files
committed
build.sh add help [skip ci]
1 parent 1d15946 commit 13e2db3

File tree

1 file changed

+58
-37
lines changed

1 file changed

+58
-37
lines changed

build.sh

+58-37
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,60 @@
11
#!/bin/bash
22

3-
CC=gcc
4-
CXX=g++
5-
6-
n=0
7-
args=()
8-
for i in "$@"
9-
do
10-
case $i in
11-
-j=*|--jobs=*)
12-
jobs="-j${i#*=}"
13-
shift
14-
;;
15-
-c=*|--compiler=*)
16-
C="${i#*=}"
17-
shift
18-
;;
19-
*)
20-
args[$n]="$i"
21-
((++n))
22-
;;
23-
esac
24-
done
25-
26-
case "$C" in
27-
("intel"|"icc") CC=icc CXX=icpc ;;
28-
("gcc") CC=gcc CXX=g++ ;;
29-
("clang") CC=clang CXX=clang++ ;;
30-
*)
31-
;;
32-
esac
33-
34-
rm -rf build
35-
mkdir build
36-
pushd build &> /dev/null
37-
CC=$CC CXX=$CXX cmake ${args[@]} ..
38-
make ${jobs}
39-
popd > /dev/null
3+
main()
4+
{
5+
CC=gcc
6+
CXX=g++
7+
8+
if [[ "$*" =~ "--help" ]]; then
9+
help
10+
exit 0;
11+
fi
12+
13+
n=0
14+
args=()
15+
for i in "$@"
16+
do
17+
case $i in
18+
-j=*|--jobs=*)
19+
jobs="-j${i#*=}"
20+
shift
21+
;;
22+
-c=*|--compiler=*)
23+
C="${i#*=}"
24+
shift
25+
;;
26+
*)
27+
args[$n]="$i"
28+
((++n))
29+
;;
30+
esac
31+
done
32+
33+
case "$C" in
34+
("intel"|"icc") CC=icc CXX=icpc ;;
35+
("gcc"|"g++") CC=gcc CXX=g++ ;;
36+
("clang|llvm") CC=clang CXX=clang++ ;;
37+
*)
38+
;;
39+
esac
40+
41+
rm -rf build
42+
mkdir build
43+
pushd build &> /dev/null
44+
CC=$CC CXX=$CXX cmake ${args[@]} ..
45+
make ${jobs}
46+
popd > /dev/null
47+
}
48+
49+
help()
50+
{
51+
printf "Usage: ./build.sh <options>\n\n"
52+
printf " -c= | --compiler=<icc|gcc|clang> - Select preferred C/C++ compiler to build\n"
53+
printf " -j= | --jobs=<N> - Specifies the number of jobs (commands) to run simultaneously (For faster building)\n\n"
54+
}
55+
56+
# Initialize
57+
main $*
58+
59+
# Exit normally
60+
exit 0

0 commit comments

Comments
 (0)