forked from microsoft/ELL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·107 lines (89 loc) · 3.07 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
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
102
103
104
105
106
107
#!/bin/bash
# get path of current script: https://stackoverflow.com/a/39340259/207661
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# usage: build.sh build_dir nproc dailyclean cmakeargs
# This script checks to make sure you have required tools instealled then builds ELL.
# Options:
# build_dir - the output folder (default 'build')
# nproc - number of procs to use (default let make decide)
# dailyclean - true/false if you want the folder cleaned each day
# cmakeargs - args to pass cmake (default '-DCMAKE_BUILD_TYPE=Release ..')
set -e
# make sure we have the required tools
if printf '%s\n%s\n' "$(cmake --version | head -n1 | cut -d" " -f3 | awk '{print $NF}')" 3.7.9 | sort -CV; then
echo "Your cmake version is less than the required 3.8.0"
echo "See INSTALL-Ubuntu.md for information on how to install cmake"
exit 1
fi
if printf '%s\n%s\n' "$(gcc --version | head -n1 | cut -d" " -f4 | awk '{print $NF}')" 8.0.0 | sort -CV; then
echo "Your GCC compiler version is less than the required 8.0.0"
echo "See INSTALL-Ubuntu.md for information on how to install GCC"
exit 1
fi
if [[ ! -f "/usr/bin/llvm-config-6.0" ]]; then
echo "LLVM version 6.0 needs to be installed"
echo "See INSTALL-Ubuntu.md for information on how to install llvm"
exit 1
fi
if printf '%s\n%s\n' "$(swig -version | grep -e 'SWIG Version' | cut -d" " -f3 | awk '{print $NF}')" 3.0.11 | sort -CV; then
echo "Your swig version is less than the required 3.0.12"
echo "See INSTALL-Ubuntu.md for information on how to install swig"
exit 1
fi
if printf '%s\n%s\n' "$(python --version 2>&1 | head -n1 | cut -d" " -f2 | awk '{print $NF}')" 3.5.9 | sort -CV; then
echo "Your python version is less than the required 3.6"
echo "See INSTALL-Ubuntu.md for information on how to install python using anaconda"
exit 1
fi
if [[ ! -f "/usr/lib/libopenblas.a" ]]; then
sudo apt-get install -y libopenblas-dev
fi
pushd "$SCRIPT_DIR" > /dev/null
# variable for build output
build_dir=$1
if [[ -z "$build_dir" ]]; then
build_dir=build
else
shift
fi
nproc=$1
if [[ ! -z "$nproc" ]]; then
shift
fi
dailyclean=$1
if [[ ! -z "$dailyclean" ]]; then
shift
fi
incremental="true"
if [[ -d $build_dir ]]; then
if [ "${dailyclean}" = "true" ]; then
d="$(date +%d/%m/%Y)"
e=""
if [[ -f .lastbuild ]]; then
e="$(cat .lastbuild)"
fi
if [ ! "${d}" = "${e}" ]; then
echo forcing clean build by deleting ${build_dir}
rm -rf $build_dir
incremental="false"
fi
echo ${d} > .lastbuild
fi
if [ "${incremental}" = "true" ]; then
echo performing incremental build in ${build_dir}
fi
fi
if [[ ! -d $build_dir ]]; then
echo "putting build in $build_dir folder, to clean, just delete the directory..."
mkdir -p $build_dir
fi
set -x
cmakeargs="$@"
if [[ -z "${cmakeargs}" ]]; then
cmakeargs="-DCMAKE_BUILD_TYPE=Release .."
fi
pushd $build_dir > /dev/null
cmake ${cmakeargs}
make -j $nproc
make -j $nproc _ELL_python
popd > /dev/null