-
Notifications
You must be signed in to change notification settings - Fork 17
/
build.xml
215 lines (215 loc) · 7.74 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
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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
<project name="MJC">
<property name="junit.jar" value="/usr/share/java/junit4.jar" />
<property name="bridj.name" value="bridj-0.6.2.jar" />
<property name="bridj.url" value="https://oss.sonatype.org/content/groups/public/com/nativelibs4java/bridj/0.6.2/${bridj.name}" />
<property name="bridj.jar" value="build/libs/${bridj.name}" />
<property name="llvm-j.jar" value="build/libs/llvm-j.jar" />
<property name="commons.jar.system" value="/usr/share/java/commons-cli.jar" />
<property name="commons.jar" value="build/libs/commons-cli.jar" />
<property name="dir.build" value="build/" />
<property name="dir.libs" value="build/libs" />
<property name="dir.bin" value="build/bin" />
<property name="dir.classes" value="build/classes" />
<property name="dir.runtime" value="build/runtime" />
<property name="jacc.download.name" value="jacc.tar.gz" />
<property name="jacc.url" value="http://web.cecs.pdx.edu/~mpj/jacc/${jacc.download.name}" />
<property name="jacc.download" value="${dir.libs}/${jacc.download.name}" />
<property name="jacc.jar" value="${dir.libs}/jacc/jacc.jar" />
<taskdef resource="net/sf/antcontrib/antcontrib.properties"/>
<path id="llvm-j.build.classpath">
<pathelement location="${junit.jar}" />
<pathelement location="${bridj.jar}"/>
</path>
<path id="llvm-j.run.classpath">
<pathelement location="${junit.jar}" />
<pathelement location="${bridj.jar}"/>
<pathelement location="${llvm-j.jar}"/>
</path>
<path id="project.classpath">
<pathelement location="${bridj.jar}"/>
<pathelement location="${llvm-j.jar}"/>
<pathelement location="${commons.jar}"/>
</path>
<target name="git_setup">
<exec executable="git">
<arg value="config" />
<arg value="filter.java_code.clean" />
<arg value="astyle --options=${basedir}/.javastyle < %f" />
</exec>
<exec executable="git">
<arg value="config" />
<arg value="filter.c_code.clean" />
<arg value="astyle --options=${basedir}/.cstyle < %f" />
</exec>
<exec executable="git">
<arg value="submodule" />
<arg value="update" />
<arg value="--init" />
<arg value="--recursive" />
</exec>
</target>
<target name="deps">
<exec executable="sudo">
<arg value="apt-get" />
<arg value="update" />
</exec>
<exec executable="sudo">
<arg value="apt-get" />
<arg value="-y" />
<arg value="install" />
<arg value="build-essential" />
<arg value="default-jdk" />
<arg value="default-jre" />
<arg value="ant-contrib" />
<arg value="libcommons-cli-java" />
<arg value="junit4" />
<arg value="libjna-java" />
<arg value="astyle" />
<arg value="clang-3.4" />
<arg value="llvm-3.4-dev" />
<arg value="llvm" />
<arg value="libc6-dev-i386" />
<arg value="python" />
<arg value="python3" />
<arg value="wget" />
<arg value="git" />
</exec>
</target>
<target name="clean">
<delete dir="build"/>
</target>
<target name="runtime">
<mkdir dir="${dir.runtime}"/>
<outofdate>
<sourcefiles>
<pathelement path="src/runtime_llvm.c"/>
</sourcefiles>
<targetfiles>
<pathelement path="${dir.runtime}/runtime_llvm.bc"/>
</targetfiles>
<sequential>
<exec executable="clang" failonerror="true">
<arg value="src/runtime_llvm.c" />
<arg value="-c" />
<arg value="-g" />
<arg value="-o" />
<arg value="${dir.runtime}/runtime_llvm.o"/>
</exec>
</sequential>
</outofdate>
</target>
<target name="build_libs" depends="git_setup">
<mkdir dir="${dir.bin}" />
<mkdir dir="${dir.libs}" />
<if>
<available file="${bridj.jar}"/>
<else>
<exec executable="wget" dir="${dir.libs}" failonerror="true">
<arg value="${bridj.url}" />
</exec>
</else>
</if>
<if>
<available file="${jacc.jar}" />
<else>
<if>
<available file="${jacc.download}" />
<else>
<exec executable="wget" dir="${dir.libs}" failonerror="true">
<arg value="${jacc.url}" />
</exec>
</else>
</if>
<exec executable="tar" dir="${dir.libs}" failonerror="true">
<arg value="xvf" />
<arg value="${jacc.download.name}" />
</exec>
</else>
</if>
<if>
<available file="${commons.jar}" />
<else>
<copy file="${commons.jar.system}" todir="${dir.libs}" />
</else>
</if>
<if>
<available file="${llvm-j.jar}"/>
<else>
<exec executable="llvm-config" outputproperty="llvm.version" >
<arg value="--version" />
</exec>
<exec executable="llvm-config" outputproperty="llvm.include">
<arg value="--includedir" />
</exec>
<exec executable="make" dir="llvm-j" failonerror="true">
<arg value="LLVM_C=${llvm.include}/llvm-c" />
<arg value="LLVM_VERSION=${llvm.version}" />
<arg value="llvm" />
</exec>
<mkdir dir="build/llvm-j/"/>
<javac includeantruntime="false" srcdir="llvm-j/src/"
destdir="build/llvm-j/" classpathref="llvm-j.build.classpath" />
<jar destfile="${llvm-j.jar}" basedir="build/llvm-j/" />
</else>
</if>
</target>
<target name="llvm_j_test" depends="build_libs">
<java classname="org.junit.runner.JUnitCore" fork="true" classpathref="llvm-j.run.classpath">
<arg value="org.llvm.test.TestJIT" />
<arg value="org.llvm.test.TestLLVM" />
<arg value="org.llvm.test.TestFactorial" />
</java>
</target>
<target name="compile" depends="build_libs">
<mkdir dir="${dir.classes}"/>
<outofdate>
<sourcefiles>
<pathelement path="src/syntax/Mjc.jacc"/>
</sourcefiles>
<targetfiles>
<pathelement path="src/syntax/MjcParser.java"/>
<pathelement path="src/syntax/MjcTokens.java"/>
</targetfiles>
<sequential>
<java jar="${jacc.jar}" fork="true">
<arg value="src/syntax/Mjc.jacc" />
</java>
</sequential>
</outofdate>
<javac debug="on" includeantruntime="false" srcdir="src" destdir="${dir.classes}" classpathref="project.classpath" />
</target>
<target name="jar" depends="compile,runtime">
<mkdir dir="build/jar"/>
<manifestclasspath property="jar.classpath" jarfile="build/jar/mjc.jar">
<classpath refid="project.classpath"/>
</manifestclasspath>
<jar destfile="build/jar/mjc.jar" basedir="${dir.classes}">
<manifest>
<attribute name="Main-Class" value="Compiler"/>
<attribute name="Class-Path" value="${jar.classpath}"/>
</manifest>
</jar>
</target>
<target name="run" depends="jar">
<java jar="build/jar/mjc.jar" fork="true"/>
</target>
<target name="test" depends="jar">
<exec executable="./runTests.py" failonerror="true">
<arg value="--show_diff" />
</exec>
</target>
<target name="license">
<exec executable="copyright-header">
<arg value="--add-path" /><arg value="src:runTests.py" />
<arg value="--license-file" /><arg value="GPL2.erb" />
<arg value="--copyright-holder" /><arg value="Mitch Souders" />
<arg value="--copyright-holder" /><arg value="Mark A. Smith" />
<arg value="--copyright-holder" /><arg value="Mark P. Jones" />
<arg value="--copyright-software" /><arg value="MiniJava Compiler" />
<arg value="--copyright-software-description" /><arg value="X86, LLVM Compiler/Interpreter for MiniJava." />
<arg value="--copyright-year" /> <arg value="2014" />
<arg value="--copyright-year" /> <arg value="2008" />
<arg value="--output-dir" /> <arg value="." />
</exec>
</target>
</project>