-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathclone.sh
executable file
·83 lines (71 loc) · 1.79 KB
/
clone.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
#!/bin/bash
#
# [email protected], 2014-02-07
#
# arguments:
# [cores] number of cores to use, optional
# default: all detected cores
# which is not ideal, see http://stackoverflow.com/a/677212/1392758
python=`which python`
if type python3 > /dev/null 2>&1; then
python=`which python3`
fi
allcores=`$python <(cat <<EOF
import multiprocessing
print (multiprocessing.cpu_count())
EOF
)`
cores=${1:-${allcores}}
echo Using $cores cores.
function update {
cd llvm-project || exit 1
echo '++ Updating llvm...'
git pull || exit 1
echo '++ Updating cling...'
cd ../cling || exit 1
git pull || exit 1
echo '++ Update done.'
cd ..
}
function clone {
# clone what branch where
echo '>> Cloning '$1'...'
git clone --depth=1 --branch $2 https://github.com/root-project/${1}.git > /dev/null || exit 1
}
function initial {
if [ -d inst ]; then
echo '!! Directory inst/ exists; refusing to build / install!'
exit 1
fi
clone llvm-project cling-llvm16
clone cling master
}
function configure {
mkdir -p build || exit 1
INSTDIR=`pwd`/inst
cd build || exit 1
echo '>> Configuring...'
cmake -DCMAKE_INSTALL_PREFIX=$INSTDIR -DLLVM_EXTERNAL_PROJECTS=cling -DLLVM_EXTERNAL_CLING_SOURCE_DIR=../cling -DLLVM_ENABLE_PROJECTS="clang" -DLLVM_TARGETS_TO_BUILD="host;NVPTX" -DCMAKE_BUILD_TYPE=Release -DLLVM_BUILD_TOOLS=Off ../llvm-project/llvm/ > /dev/null || exit 1
cd ..
}
function build {
cd build
echo ':: Building...'
make -j$cores || exit 1
rm -rf ../inst
echo ':: Installing...'
make -j$cores install || exit 1
echo ':: SUCCESS.'
cd ..
}
if [ -d cling ]; then
# update mode
update
else
initial
fi
if ! [ -e build/Makefile ]; then
configure
fi
build
echo 'Run ./inst/bin/cling'