forked from SVF-tools/SVF
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·123 lines (112 loc) · 2.88 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# !bash
# type './build.sh' for release build
# type './build.sh debug' for debug build
#########
# VARs and Links
########
SVFHOME=$(pwd)
sysOS=`uname -s`
MacLLVM="https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.0/clang+llvm-10.0.0-x86_64-apple-darwin.tar.xz"
UbuntuLLVM="https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.0/clang+llvm-10.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz"
MacZ3="https://github.com/Z3Prover/z3/releases/download/z3-4.8.8/z3-4.8.8-x64-osx-10.14.6.zip"
UbuntuZ3="https://github.com/Z3Prover/z3/releases/download/z3-4.8.8/z3-4.8.8-x64-ubuntu-16.04.zip"
LLVMHome="llvm-10.0.0.obj"
Z3Home="z3.obj"
SVFTests="Test-Suite"
########
# Download LLVM binary and Z3 binary
########
if [[ $sysOS == "Darwin" ]]
then
if [ ! -d "$LLVMHome" ]
then
echo 'Downloading LLVM binary for MacOS '
curl -L $MacLLVM > llvm-mac.tar.xz
mkdir ./$LLVMHome && tar -xf "llvm-mac.tar.xz" -C ./$LLVMHome --strip-components 1
rm llvm-mac.tar.xz
fi
if [ ! -d "$Z3Home" ]
then
echo 'Downloading Z3 binary for MacOS '
curl -L $MacZ3 -o z3_mac.zip
unzip -q "z3_mac.zip" && mv ./z3-* ./$Z3Home
rm z3_mac.zip
fi
elif [[ $sysOS == "Linux" ]]
then
if [ ! -d "$LLVMHome" ]
then
echo 'Downloading LLVM binary for Ubuntu'
wget -c $UbuntuLLVM -O llvm-ubuntu.tar.xz
mkdir ./$LLVMHome && tar -xf "llvm-ubuntu.tar.xz" -C ./$LLVMHome --strip-components 1
rm llvm-ubuntu.tar.xz
fi
if [ ! -d "$Z3Home" ]
then
echo 'Downloading LLVM binary for Ubuntu'
wget -c $UbuntuZ3 -O z3_ubuntu.zip
unzip -q "z3_ubuntu.zip" && mv ./z3-* ./$Z3Home
rm z3_ubuntu.zip
fi
else
echo 'not support builds in OS other than Ubuntu and Mac'
fi
export LLVM_DIR=$SVFHOME/$LLVMHome
export Z3_DIR=$SVFHOME/$Z3Home
export PATH=$LLVM_DIR/bin:$PATH
echo "LLVM_DIR =" $LLVM_DIR
########
# Download SVF Test Suite
#######
if [ ! -d "$SVFTests" ]
then
git clone "https://github.com/SVF-tools/Test-Suite.git"
if [[ $sysOS == "Linux" ]] ; then
cd ./$SVFTests
./generate_bc.sh
cd ..
fi
fi
########
# Build SVF
########
if [[ $1 == 'debug' ]]
then
rm -rf ./'Debug-build'
mkdir ./'Debug-build'
cd ./'Debug-build'
cmake -D CMAKE_BUILD_TYPE:STRING=Debug ../
else
rm -rf ./'Release-build'
mkdir ./'Release-build'
cd ./'Release-build'
cmake ../
fi
make -j4
########
# Set up environment variables of SVF
########
cd ../
if [[ $1 == 'debug' ]]
then
. ./setup.sh debug
else
. ./setup.sh
fi
#########
# Run ctest
########
if [[ $sysOS == "Linux" ]]
then
if [[ $1 == 'debug' ]]
then
cd ./'Debug-build'
else
cd ./'Release-build'
fi
ctest --v
fi
#########
# Optionally, you can also specify a CXX_COMPILER and your $LLVM_HOME for your build
# cmake -DCMAKE_CXX_COMPILER=$LLVM_DIR/bin/clang++ -DLLVM_DIR=$LLVM_DIR
#########