-
Notifications
You must be signed in to change notification settings - Fork 46
/
build.xml
95 lines (77 loc) · 3.92 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
87
88
89
90
91
92
93
94
95
<!--
~ Copyright 2021 Alibaba Group Holding Limited.
~
~ 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.
-->
<!--
~ Derived from alibaba/fastFFI v0.1.2
~ https://github.com/alibaba/fastFFI/blob/1eca42b/build.xml
-->
<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>
<fail unless="platform" message="Not a supported platform."/>
<echo message="Native Library Name: ${native.library.name}" level="info"/>
<exec executable="cmake" dir="${project.build.directory}/native" failonerror="true">
<arg line="-DBUILD_GAR_CPP=${build_gar_cpp}; -DCMAKE_AR="${env.LLVM11_HOME}/bin/llvm-ar" -DCMAKE_RANLIB="${env.LLVM11_HOME}/bin/llvm-ranlib" -DCMAKE_C_COMPILER="${env.LLVM11_HOME}/bin/clang" -DCMAKE_CXX_COMPILER="${env.LLVM11_HOME}/bin/clang++" -DCMAKE_CXX_FLAGS="-flto -fforce-emit-vtables" ${basedir}"/>
</exec>
<exec executable="make" dir="${project.build.directory}/native" failonerror="true">
<arg line="VERBOSE=1"/>
</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">
<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">
<arg line="${native.library.name}.bc ${project.build.directory}/classes"/>
</exec>
</target>
<target name="run-llvm4jni" depends="link-llvm-bitcode">
<echo message="Run LLVM4JNI" level="info"/>
<mkdir dir="${project.build.directory}/llvm4jni-output"/>
<condition property="native.library.file" value="lib${native.library.name}.so"><os family="unix" arch="amd64" />
</condition>
<condition property="native.library.file" value="lib${native.library.name}.dylib"><os family="mac" arch="x86_64" />
</condition>
<java classname="com.alibaba.fastffi.llvm4jni.Main"
fork="true" failonerror="true">
<arg value="-cp" />
<arg value="${project.build.directory}/classes" />
<arg value="-bc" />
<arg value="${project.build.directory}/native/${native.library.name}.bc" />
<!--
<arg value="-lib" />
<arg value="${project.build.directory}/native/${native.library.file}" />
-->
<arg value="-output" />
<arg value="${project.build.directory}/llvm4jni-output" />
<arg value="-v" />
<arg value="INFO" />
<jvmarg value="-Dllvm4jni.supportIndirectCall=simple" />
<jvmarg value="-Dllvm4jni.supportLocalConstant=true" />
<jvmarg value="-Dllvm4jni.maximumBytecodeSize=128" />
<classpath>
<pathelement path="${compile_classpath}"/>
</classpath>
</java>
</target>
</project>