-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.xml
263 lines (232 loc) · 9.53 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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
<?xml version="1.0"?>
<project name="mjc" default="jar">
<description>Compiler for the MiniJava language</description>
<!-- Settings -->
<property file="build.properties"/>
<path id="project-classpath">
<fileset dir="${lib-dir}">
<include name="**/*.jar"/>
</fileset>
<pathelement location="${main-classes-dir}"/>
<pathelement location="${parser-classes-dir}"/>
<pathelement location="${test-classes-dir}"/>
</path>
<!-- Internal Targets -->
<target name="init">
<mkdir dir="${parser-src-dir}"/>
<uptodate property="parser-out-of-date" targetfile="${parser-grammar}">
<srcfiles dir="${parser-src-dir}" includes="**/*.java"/>
</uptodate>
<uptodate property="report-up-to-date" targetfile="report.pdf">
<srcfiles dir="${report-src-dir}" includes="**/*"/>
</uptodate>
</target>
<target name="generate-parser" if="parser-out-of-date" depends="init">
<java classname="org.sablecc.sablecc.SableCC"
fork="true"
outputproperty="sablecc-output"
errorproperty="sablecc-error"
resultproperty="sablecc-result">
<arg value="-d"/>
<arg value="${parser-src-dir}"/>
<arg value="--no-inline"/>
<arg value="${parser-grammar}"/>
<classpath>
<!-- So that our custom parser.txt template is picked up -->
<pathelement location="${src-dir}/main/txt"/>
<pathelement location="${lib-dir}/sablecc.jar"/>
</classpath>
</java>
<fail message="${sablecc-error}">
<condition>
<not>
<equals arg1="${sablecc-result}" arg2="0"/>
</not>
</condition>
</fail>
<echo>Generated parser in ${parser-src-dir} from ${parser-grammar}</echo>
</target>
<!-- Public Targets -->
<target name="compile" description="Compile all sources" depends="generate-parser">
<mkdir dir="${parser-classes-dir}"/>
<javac srcdir="${parser-src-dir}"
destdir="${parser-classes-dir}"
encoding="utf8"
classpathref="project-classpath"
includeAntRuntime="false"
debug="on"/>
<copy todir="${parser-classes-dir}">
<fileset dir="${parser-src-dir}" includes="**/*.dat"/>
</copy>
<mkdir dir="${main-classes-dir}"/>
<javac srcdir="${main-src-dir}"
destdir="${main-classes-dir}"
encoding="utf8"
classpathref="project-classpath"
includeAntRuntime="false"
debug="on"/>
<mkdir dir="${test-classes-dir}"/>
<javac srcdir="${test-src-dir}"
destdir="${test-classes-dir}"
encoding="utf8"
classpathref="project-classpath"
includeAntRuntime="false"
debug="on"/>
</target>
<target name="test" description="Run the unit tests" depends="compile">
<mkdir dir="${test-reports-dir}"/>
<junit printsummary="withOutAndErr" haltonfailure="yes">
<classpath refid="project-classpath"/>
<formatter type="plain"/>
<batchtest fork="yes" todir="${test-reports-dir}">
<fileset dir="${test-src-dir}" includes="**/*Test.java"/>
</batchtest>
</junit>
</target>
<target name="jar" description="Build compiler JAR file" depends="test">
<jar destfile="${output-jar}">
<fileset dir="${main-classes-dir}"/>
<fileset dir="${parser-classes-dir}"/>
</jar>
</target>
<target name="doc" description="Generate JavaDoc documentation in doc/" depends="generate-parser">
<delete dir="${doc-dir}"/>
<javadoc package="mjc"
destdir="${doc-dir}"
doclet="mjc.doclets.TextDoclet"
docletpath="${lib-dir}/mjc-doclets.jar"
overview="${main-src-dir}/overview.html"
includenosourcepackages="true"
Private="true">
<classpath refid="project-classpath"/>
<fileset dir="${main-src-dir}"/>
<fileset dir="${parser-src-dir}">
<!-- These are not very interesting -->
<exclude name="mjc/lexer/**"/>
<exclude name="mjc/parser/**"/>
<exclude name="mjc/node/**"/>
</fileset>
</javadoc>
</target>
<target name="report" description="Build report PDF file" unless="report-up-to-date" depends="init">
<!-- Prepare build directory -->
<delete dir="${report-build-dir}"/>
<copy todir="${report-build-dir}">
<fileset dir="${report-src-dir}"/>
</copy>
<!-- Run LaTeX - Pass #1 -->
<echo>Running LaTeX - Pass #1</echo>
<exec executable="${latex-command}"
dir="${report-build-dir}"
outputProperty="latex1-output"
resultProperty="latex1-result">
<arg value="report.tex"/>
</exec>
<fail message="${latex1-output}">
<condition>
<not>
<equals arg1="${latex1-result}" arg2="0"/>
</not>
</condition>
</fail>
<!-- Run BibTeX -->
<echo>Running BibTeX</echo>
<exec executable="${bibtex-command}"
dir="${report-build-dir}"
outputProperty="bibtex-output"
resultProperty="bibtex-result">
<arg value="report"/>
</exec>
<fail message="${bibtex-output}">
<condition>
<not>
<equals arg1="${bibtex-result}" arg2="0"/>
</not>
</condition>
</fail>
<!-- Run LaTeX - Pass #2 -->
<echo>Running LaTeX - Pass #2</echo>
<exec executable="${latex-command}"
dir="${report-build-dir}"
outputProperty="latex2-output"
resultProperty="latex2-result">
<arg value="report.tex"/>
</exec>
<fail message="${latex2-output}">
<condition>
<not>
<equals arg1="${latex2-result}" arg2="0"/>
</not>
</condition>
</fail>
<!-- Run LaTeX - Pass #3 -->
<echo>Running LaTeX - Pass #3</echo>
<exec executable="${latex-command}"
dir="${report-build-dir}"
outputProperty="latex3-output"
resultProperty="latex3-result">
<arg value="report.tex"/>
</exec>
<fail message="${latex3-output}">
<condition>
<not>
<equals arg1="${latex3-result}" arg2="0"/>
</not>
</condition>
</fail>
<!-- Copy results -->
<copy file="${report-build-dir}/report.pdf" tofile="report.pdf"/>
<echo>Successfully generated report.pdf from LaTeX in ${report-src-dir}/report.tex</echo>
</target>
<target name="tar" description="Build compressed source-only TAR archive" depends="test,report">
<!-- If tigris.id/email is unset, use environment variables. -->
<property environment="env"/>
<condition property="tigris.id" value="${env.TIGRIS_ID}">
<isset property="env.TIGRIS_ID"/>
</condition>
<condition property="tigris.email" value="${env.TIGRIS_EMAIL}">
<isset property="env.TIGRIS_EMAIL"/>
</condition>
<!-- Fail unless we have both tigris.id/email. -->
<fail message="Use -Dtigris.id=YOUR_ID or set TIGRIS_ID environment variable!" unless="tigris.id"/>
<fail message="Use -Dtigris.email=YOUR_EMAIL or set TIGRIS_EMAIL environment variable!" unless="tigris.email"/>
<!-- Prepare TAR file contents in a temporary directory -->
<tempfile property="temp-dir"
destDir="${java.io.tmpdir}"
prefix="${ant.project.name}"/>
<mkdir dir="${temp-dir}/${ant.project.name}"/>
<copy todir="${temp-dir}/${ant.project.name}">
<fileset dir="${basedir}" id="tar-fileset">
<exclude name="**/${build-dir}/**"/>
<exclude name="${output-jar}"/>
<exclude name="${output-tar}"/>
<exclude name="**/*.classpath"/>
<exclude name="**/*.project"/>
<exclude name="**/*.settings"/>
<exclude name="**/*.swp"/>
<exclude name="**/*.class"/>
</fileset>
</copy>
<replace file="${temp-dir}/${ant.project.name}/DESC"
token="@ID@"
value="${tigris.id}"/>
<replace file="${temp-dir}/${ant.project.name}/DESC"
token="@EMAIL@"
value="${tigris.email}"/>
<tar destfile="${output-tar}" basedir="${temp-dir}" compression="gzip"/>
<delete dir="${temp-dir}"/>
<echo>Successfully generated ${output-tar}</echo>
</target>
<target name="submit" description="Submit TAR archive to TIGRIS" depends="tar">
<property name="tigris.to" value="[email protected]"/>
<exec executable="tools/submit">
<arg value="${tigris.to}"/>
</exec>
</target>
<target name="clean" description="Delete all generated files">
<delete dir="${build-dir}"/>
<delete dir="${doc-dir}"/>
<delete file="${output-jar}"/>
<delete file="${output-tar}"/>
</target>
</project>