-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-linux.sh
executable file
·56 lines (45 loc) · 1.55 KB
/
build-linux.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
#!/bin/bash
# This is the main linux script for building the JNI native part for
# the clang bindings. This is intended to run on the results of the
# prepare script.
# The number of cores used for compilation
CORES=16
# Customization to allow reuse of script for mac and linux
EXTENSION=linux.so
SOURCE=libclang.so
if [[ "$OSTYPE" == "darwin"* ]]
then
EXTENSION=mac.dylib
SOURCE=libclang.dylib
fi
echo "Patching cmake files to work on this machine"
(
cd ../llvm-project/clang/tools/libclang
if [[ "$OSTYPE" == "darwin"* ]]
then
# Taken from JDK 11.0.2
gsed -i -e '/set.LIBS/i include_directories(/Library/Java/JavaVirtualMachines/jdk-11.0.2.jdk/Contents/Home/include/)' CMakeLists.txt
gsed -i -e '/set.LIBS/i include_directories(/Library/Java/JavaVirtualMachines/jdk-11.0.2.jdk/Contents/Home/include/darwin)' CMakeLists.txt
else
# these are the include dirs for OpenJDK 8
sed -i -e '/set.LIBS/i include_directories(/usr/lib/jvm/java-8-openjdk-amd64/include)' CMakeLists.txt
sed -i -e '/set.LIBS/i include_directories(/usr/lib/jvm/java-8-openjdk-amd64/include/linux)' CMakeLists.txt
fi
)
echo "Running cmake"
(
cd ../llvm-project
mkdir -p build
cd build
cmake -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra" -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD=X86 -G "Unix Makefiles" ../llvm
)
echo "running make"
(
cd ../llvm-project/build
make -j$CORES
)
echo "Copying resulting library"
(
cp ../llvm-project/build/lib/$SOURCE libs/libclang-$EXTENSION
)
echo "done"