forked from GssMahadevan/Okra-Interface-to-HSAIL-Simulator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-okra-sim.xml
166 lines (141 loc) · 8.43 KB
/
build-okra-sim.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
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
<?xml version="1.0"?>
<project name="okra" default="build" basedir=".">
<import file="./common-targets.xml"/>
<!--
For each okra implementation, the following properites should get updated
1) the name of the repo to pull hsa from
2) the name of the cpp file with the okra implementation
-->
<property name="hsa.version" value="hsatools-old" />
<property name="okra.cpp.filename" value="okraContextSimulator.cpp" />
<property name="junit.jar.version" value="4.10"/>
<property name="junit.jar.name" value="junit-${junit.jar.version}.jar"/>
<property name="junit.home" value="${basedir}/.libs"/>
<property name="junit.base.url" value="http://repo1.maven.org/maven2/junit/junit"/>
<!-- Change the following to specify debug or release build -->
<property name="sim.build.type" value="DEBUG"/>
<property name="simbuild" value="sim/hsail2brig/build_linux"/>
<echo>OS Name: ${os.name}</echo>
<echo>OS Version: ${os.version}</echo>
<echo>OS Arch: ${os.arch}</echo>
<!--<property name="build.compiler" value="javac1.6"/>-->
<!-- <property name="ant.build.javac.source" value="1.6"/>-->
<!-- <property name="ant.build.javac.target" value="1.6"/> -->
<property environment="env" />
<!-- we need env.PATH for msvc only -->
<!-- uncomment this if you want to use mingw! -->
<!--<property name="mingw.dir" value="c:\\MinGW"/>-->
<available file="${simbuild}" type="dir" property="sim.exists" />
<available property="cmake.installed" file="cmake" filepath="${env.PATH}"/>
<available property="flex.installed" file="flex" filepath="${env.PATH}"/>
<available property="svn.installed" file="svn" filepath="${env.PATH}"/>
<available property="git.installed" file="git" filepath="${env.PATH}"/>
<available property="libelf-dev.installed" file="libelf.h" filepath="/usr/include"/>
<available property="libdwarf-dev.installed" file="libdwarf.h" filepath="/usr/include"/>
<target name="getsim" depends="init" unless="sim.exists" >
<property name="youneed.msg" value="To build the simulator and associated assembler, you need to install cmake, flex, subversion (for llvm pull), git (for libhsail pull), libelf-dev and libdwarf-dev"/>
<fail message="${youneed.msg}" unless="cmake.installed" />
<fail message="${youneed.msg}" unless="flex.installed" />
<fail message="${youneed.msg}" unless="svn.installed" />
<fail message="${youneed.msg}" unless="git.installed" />
<fail message="${youneed.msg}" unless="libelf-dev.installed" />
<fail message="${youneed.msg}" unless="libdwarf-dev.installed" />
<echo message="... downloading simulator hsa runtime sources, this may take a while but should only happen once..."/>
<mkdir dir="sim" />
<exec dir="sim" executable="git">
<arg line="clone https://github.com/HSAFoundation/HSAIL-Instruction-Set-Simulator-.git hsail2brig" />
</exec>
<!-- explicitly get the libhsail to avoid git problems -->
<echo message="... using git to pull libhsail..."/>
<exec dir="sim/hsail2brig/src/brig2llvm" executable="git">
<arg line="clone https://github.com/HSAFoundation/HSAIL-Tools.git" />
</exec>
<mkdir dir="${simbuild}" />
</target>
<target name="updatesim" depends="getsim" >
<echo message="... pulling simulator hsa runtime sources..."/>
<exec dir="sim/hsail2brig" executable="git">
<arg line="pull" />
</exec>
<echo message="... pulling libhsail sources..."/>
<exec dir="sim/hsail2brig/src/brig2llvm/HSAIL-Tools" executable="git">
<arg line="pull" />
</exec>
</target>
<available file="${simbuild}/src/hsa_runtime/libhsa.a" type="file" property="sim.built" />
<target name="buildsim" depends="getsim" >
<exec dir="${simbuild}" executable="cmake" failonerror="true">
<arg line="-DCMAKE_BUILD_TYPE=${sim.build.type} ../" />
</exec>
<exec dir="${simbuild}" executable="make" failonerror="true">
<arg line="--jobs=4" />
</exec>
</target>
<target name="gcc" if="use.gcc">
<mkdir dir="${basedir}/dist"/>
<mkdir dir="${basedir}/dist/lib"/>
<mkdir dir="${basedir}/dist/include"/>
<mkdir dir="${basedir}/dist/bin"/>
<mkdir dir="${basedir}/dist/tools"/>
<echo message="linuxcc ${os.arch}" />
<exec executable="g++" failonerror="true">
<!--
<arg value="-O3" />
-->
<arg value="-g" />
<arg value="-fPIC" />
<arg value="-I${java.home}/../include" />
<arg value="-I${java.home}/../include/linux" />
<arg value="-Isim/hsail2brig/include" />
<arg value="-Iinclude" />
<arg value="-shared" />
<arg value="-o" />
<arg value="${basedir}/dist/bin/libokra_${x86_or_x86_64}.so" />
<arg value="src/cpp/${okra.cpp.filename}" />
<arg value="src/cpp/OkraJNI.cpp" />
<arg value="src/cpp/okra_c_interface.cpp" />
<arg line=" -rdynamic ${simbuild}/src/hsa_runtime/libhsa.a ${simbuild}/src/brig2llvm/libbrig2llvm.a ${simbuild}/src/brig2llvm/compiler/lib/libLLVMJIT.a ${simbuild}/src/brig2llvm/compiler/lib/libLLVMMCJIT.a ${simbuild}/src/brig2llvm/compiler/lib/libLLVMX86CodeGen.a ${simbuild}/src/brig2llvm/compiler/lib/libLLVMExecutionEngine.a ${simbuild}/src/brig2llvm/compiler/lib/libLLVMRuntimeDyld.a ${simbuild}/src/brig2llvm/compiler/lib/libLLVMAsmPrinter.a ${simbuild}/src/brig2llvm/compiler/lib/libLLVMSelectionDAG.a ${simbuild}/src/brig2llvm/compiler/lib/libLLVMX86Desc.a ${simbuild}/src/brig2llvm/compiler/lib/libLLVMMCParser.a ${simbuild}/src/brig2llvm/compiler/lib/libLLVMCodeGen.a ${simbuild}/src/brig2llvm/compiler/lib/libLLVMX86AsmPrinter.a ${simbuild}/src/brig2llvm/compiler/lib/libLLVMX86Info.a ${simbuild}/src/brig2llvm/compiler/lib/libLLVMScalarOpts.a ${simbuild}/src/brig2llvm/compiler/lib/libLLVMX86Utils.a ${simbuild}/src/brig2llvm/compiler/lib/libLLVMInstCombine.a ${simbuild}/src/brig2llvm/compiler/lib/libLLVMTransformUtils.a ${simbuild}/src/brig2llvm/compiler/lib/libLLVMipa.a ${simbuild}/src/brig2llvm/compiler/lib/libLLVMAnalysis.a ${simbuild}/src/brig2llvm/compiler/lib/libLLVMTarget.a ${simbuild}/src/brig2llvm/compiler/lib/libLLVMCore.a ${simbuild}/src/brig2llvm/compiler/lib/libLLVMMC.a ${simbuild}/src/brig2llvm/compiler/lib/libLLVMObject.a ${simbuild}/src/brig2llvm/compiler/lib/libLLVMDebugInfo.a ${simbuild}/src/brig2llvm/compiler/lib/libLLVMSupport.a -ldl -lpthread -lz" />
</exec>
<copy todir="dist/include">
<fileset dir="src/cpp">
<include name="**/okra.h"/>
</fileset>
</copy>
<!-- copy executables preserving x bit (too bad there is no ant task that preserves x bits) -->
<!-- hsailasm is built by the sim build rule. We need to use it when assembling for the simulator -->
<exec executable="cp" failonerror="true">
<arg line="${simbuild}/HSAIL-Tools/hsailasm dist/bin" />
</exec>
<!--- tools
<copy todir="dist/tools">
<fileset dir="simtools">
<include name="*"/>
</fileset>
</copy>
-->
</target>
<property name="okra.versioned.jar" value="${basedir}/dist/okra-${okra.version}.jar"/>
<property name="okra.src.jar" value="${basedir}/dist/okra-${okra.version}-src.jar"/>
<property name="okra.with.sim.jar" value="${basedir}/dist/okra-${okra.version}-with-sim.jar"/>
<property name="okra.with.sim.src.jar" value="${basedir}/dist/okra-${okra.version}-with-sim-src.jar"/>
<property name="okra.resource.base.dir" value="${basedir}/jarResourceBase"/>
<property name="okra.resource.dir" value="${okra.resource.base.dir}/resources/okra/Linux"/>
<target name="otherjars" depends="javah">
<!-- versioned okra.jar -->
<copy file="${okra.jar}" tofile="${okra.versioned.jar}"/>
<!-- normal sources -->
<jar jarfile="${okra.src.jar}" basedir="${basedir}/okra-java/src" excludes="${okra.resource.extractor.java}"/>
<!-- resourceextractor sources -->
<jar jarfile="${okra.with.sim.src.jar}" basedir="${basedir}/okra-java/src" includes="${okra.resource.extractor.java}"/>
<!-- jar with resources -->
<mkdir dir="${okra.resource.dir}"/>
<copy todir="${okra.resource.dir}">
<fileset dir="dist/bin">
<include name="*"/>
</fileset>
</copy>
<jar jarfile="${okra.with.sim.jar}" basedir="./classes" includes="${okra.resource.extractor.class}"/>
<jar jarfile="${okra.with.sim.jar}" update="true" basedir="${okra.resource.base.dir}"/>
</target>
<target name="build" depends="clean, getsim, buildsim, javah, gcc, otherjars" />
</project>