-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·101 lines (83 loc) · 1.87 KB
/
build.sh
File metadata and controls
executable file
·101 lines (83 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/bin/bash
set -e
show_help() {
echo "usage: $0 [run|test] [Options...]"
echo "Build GENEX if no argument is provided. Otherwise:"
echo " run build then run"
echo " test build then test"
echo "Options:"
echo " -d compile in debug mode"
echo " -r rebuild everything"
echo " -h show this help"
echo " --cmake flags... flags to be passed to cmake"
}
OPTS=$(getopt -o rdh --long cmake: -n "$0" -- "$@")
if [ $? != 0 ] ; then show_help; exit 1; fi
REBUILD=false
DEBUG=false
SHOW_HELP=false
while true; do
case "$1" in
-r )
REBUILD=true; shift; ;;
-d )
DEBUG=true; shift; ;;
-h )
SHOW_HELP=true; shift; ;;
--cmake )
CMAKE_FLAGS="$2"; shift; shift; ;;
-- )
shift; break; ;;
* )
break ;;
esac
done
if [ $SHOW_HELP = true ]; then
show_help
exit 0
fi
if [ $# -gt 1 ]; then
echo "$0: too many arguments"
show_help
exit 1
fi
if [ $# -eq 1 ] && [ "$1" != "run" ] && [ "$1" != "test" ]; then
echo "$0: unknown argument - $1"
show_help
exit 1
fi
echo "Create and enter the 'build' directory"
mkdir -p build
cd build
if [ $DEBUG = true ]; then
echo "Build in Debug mode"
CMAKE_FLAGS="${CMAKE_FLAGS} -DCMAKE_BUILD_TYPE=Debug"
fi
echo "CMake flags: ${CMAKE_FLAGS}"
cmake .. $CMAKE_FLAGS
unameOut="$(uname -s)"
case "${unameOut}" in
Linux*) machine=Linux;;
Darwin*) machine=Mac;;
CYGWIN*) machine=Cygwin;;
MINGW*) machine=MinGw;;
*) machine="UNKNOWN:${unameOut}"
esac
if [ $unameOut = Linux ]; then
CPU=$(lscpu | grep ^CPU\(s\): | tr -s " " | cut -f2 -d " ")
BUILD_CPU=$(expr $CPU / 2)
MULTI_THREAD_BUILD="-j $BUILD_CPU"
echo "Number of CPU(s): $CPU"
echo "Building with $BUILD_CPU CPU(s)"
fi
if [ $REBUILD = true ]; then
make clean
fi
make $MULTI_THREAD_BUILD
cp -v pygenex/pygenex.so ../scripts/
if [ "$1" = "run" ]; then
./genexcli
elif [ "$1" = "test" ]; then
ctest -V
fi
exit 0