forked from OpenPPL/ppl.cv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·74 lines (63 loc) · 1.7 KB
/
build.sh
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
#!/bin/bash
workdir=`pwd`
x64_build_dir="${workdir}/x64-build"
cuda_build_dir="${workdir}/cuda-build"
cpu_num=`cat /proc/cpuinfo | grep processor | grep -v grep | wc -l`
options='-DCMAKE_BUILD_TYPE=Release'
# --------------------------------------------------------------------------- #
function BuildCuda() {
mkdir ${cuda_build_dir}
cd ${cuda_build_dir}
cmd="cmake $options -DWITH_CUDA=ON -DCMAKE_INSTALL_PREFIX=${cuda_build_dir}/install .. && make -j${cpu_num} && make install"
echo "cmd -> $cmd"
eval "$cmd"
}
function BuildX64() {
mkdir ${x64_build_dir}
cd ${x64_build_dir}
cmd="cmake $options -DCMAKE_INSTALL_PREFIX=${x64_build_dir}/install .. && make -j${cpu_num} && make install"
echo "cmd -> $cmd"
eval "$cmd"
}
declare -A engine2func=(
["cuda"]=BuildCuda
["x64"]=BuildX64
)
# --------------------------------------------------------------------------- #
function Usage() {
echo -n "[INFO] usage: $0 [ all"
for engine in ${!engine2func[@]}; do
echo -n " | $engine"
done
echo "] [cmake options]"
}
if [ $# -lt 1 ]; then
Usage
exit 1
fi
engine="$1"
shift
options="$options $*"
if [ "$engine" == "all" ]; then
for engine in "${!engine2func[@]}"; do
func=${engine2func[$engine]}
eval $func
if [ $? -ne 0 ]; then
echo "[ERROR] build [$engine] failed." >&2
exit 1
fi
done
else
func=${engine2func["$engine"]}
if ! [ -z "$func" ]; then
eval $func
if [ $? -ne 0 ]; then
echo "[ERROR] build [$engine] failed." >&2
exit 1
fi
else
echo "[ERROR] unknown engine name [$engine]" >&2
Usage
exit 1
fi
fi