-
Notifications
You must be signed in to change notification settings - Fork 13
/
build.xml
86 lines (67 loc) · 3.63 KB
/
build.xml
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
<!--
Copyright 1999-2021 Alibaba Group Holding Ltd.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<project name="llvm4jni">
<target name="make">
<echo message="Make native code" level="info"/>
<mkdir dir="${project.build.directory}/native"/>
<property environment="env"/>
<fail unless="env.LLVM11_HOME" message="LLVM11_HOME not set."/>
<condition property="platform" value="linux64">
<os family="unix" arch="amd64" />
</condition>
<condition property="platform" value="mac">
<os family="mac" arch="x86_64" />
</condition>
<condition property="cores.count" value="4">
<os family="mac" arch="x86_64" />
</condition>
<exec executable="nproc" failonerror="false" failifexecutionfails="false" osfamily="unix" outputproperty="cores.count">
<arg value="--all"/>
</exec>
<fail unless="platform" message="Not a supported platform."/>
<condition property="lld" value="${env.LLVM11_HOME}/bin/ld.lld">
<os family="unix" arch="amd64" />
</condition>
<fail message="lld ${lld} not set or missing">
<condition>
<and>
<not>
<available file="${lld}" />
</not>
<os family="unix" arch="amd64" />
</and>
</condition>
</fail>
<exec executable="cmake" dir="${project.build.directory}/native" failonerror="true" os="Linux">
<arg line="-DCMAKE_C_COMPILER="${env.LLVM11_HOME}/bin/clang" -DCMAKE_CXX_COMPILER="${env.LLVM11_HOME}/bin/clang++" -DCMAKE_CXX_FLAGS="-flto -fforce-emit-vtables" -DCMAKE_JNI_LINKER_FLAGS="-fuse-ld=${lld} -Xlinker -mllvm=-lto-embed-bitcode" ${cmake.flags} ${basedir}"/>
</exec>
<echo message="CMake Flags: ${cmake.flags}" level="info"/>
<echo message="Native Library Name: ${native.library.name}" level="info"/>
<exec executable="cmake" dir="${project.build.directory}/native" failonerror="true" os="Mac OS X">
<arg line="-DCMAKE_C_COMPILER="${env.LLVM11_HOME}/bin/clang" -DCMAKE_CXX_COMPILER="${env.LLVM11_HOME}/bin/clang++" -DCMAKE_CXX_FLAGS="-fforce-emit-vtables -flto -frtti" ${cmake.flags} ${basedir}"/>
</exec>
<echo message="Make Flags: -j${cores.count}" level="info"/>
<exec executable="make" dir="${project.build.directory}/native" failonerror="true">
<arg line="VERBOSE=1 -j${cores.count}"/>
</exec>
</target>
<target name="link-llvm-bitcode" depends="make">
<echo message="Link bitcode" level="info"/>
<exec executable="sh" dir="${project.build.directory}/native" failonerror="true" os="Mac OS X">
<arg line="-c '${env.LLVM11_HOME}/bin/llvm-link ./bitcode/* -o ${native.library.name}.bc'" />
</exec>
<exec executable="cp" dir="${project.build.directory}/native" failonerror="true" os="Mac OS X">
<arg line="${native.library.name}.bc ${project.build.directory}/classes"/>
</exec>
</target>
</project>