forked from vrdabomb5717/Tandem
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.xml
312 lines (272 loc) · 10.4 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
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
<!-- build.xml -->
<!-- Written by Varun Ravishankar -->
<project xmlns:ivy="antlib:org.apache.ivy.ant" name="Tandem" default="compile" basedir=".">
<description>
build file for Tandem programming language.
</description>
<property name="project.name" value="Tandem" />
<!-- program version -->
<property name="version" value="0.1" />
<!-- set global properties for this build -->
<property name="src" location="src"/>
<property name="build" location="bin"/>
<property name="dist" location="dist"/>
<property name="test" location="test"/>
<property name="tutorial" location="tutorial"/>
<property name="lib" location="lib"/>
<property name="grammar" value="TanG.g"/>
<property name ="treeGrammar" value="TanG_TG.g"/>
<property name="grammar1" value="WateredDownTanG.g"/>
<property name="gunit_test" value="TanG.gunit" />
<property name="test.class.name" value="TandemTest" />
<property name="jruby_jar" value="jruby-complete.jar" />
<!-- Properties required to download Ivy. -->
<property name="ivy.install.version" value="2.3.0-rc1" />
<condition property="ivy.home" value="${env.IVY_HOME}">
<isset property="env.IVY_HOME" />
</condition>
<property name="ivy.jar.dir" value="${lib}/ivy" />
<property name="ivy.jar.file" value="${ivy.jar.dir}/ivy.jar" />
<property name="ivy.lib.dir" value="${lib}" />
<path id="lib.path.id">
<fileset dir="${ivy.lib.dir}" includes="*.jar"/>
</path>
<!-- Path required to run the tests. Uses built-in JUnit,
if one is installed, or the provided JUnit otherwise. -->
<path id="test.classpath">
<fileset dir="${lib}">
<include name="*.jar"/>
</fileset>
<fileset dir="${lib}/test">
<include name="**/*.jar"/>
</fileset>
<pathelement location="${java.class.path}" />
</path>
<!-- Path required to build the grammar. Uses downloaded ANTLR,
or the installed ANTLR otherwise. -->
<path id="build.classpath">
<fileset dir="${lib}">
<include name="*.jar"/>
</fileset>
<fileset dir="${lib}/build">
<include name="**/*.jar"/>
</fileset>
<pathelement location="${java.class.path}" />
</path>
<!-- Path required to build the grammar. Uses downloaded ANTLR,
or the installed ANTLR otherwise. -->
<path id="runtime.classpath">
<fileset dir="${lib}">
<include name="*.jar"/>
</fileset>
<fileset dir="${lib}/runtime">
<include name="**/*.jar"/>
</fileset>
<pathelement location="${java.class.path}" />
</path>
<!-- An ant macro which invokes ANTLR3
This is just a parameterizable wrapper to simplify the invocation of ANTLR3.
The default values can be overriden by assigning a value to an attribute
when using the macro.
Example with ANTLR3 outputdirectory modified:
<antlr3 grammar.name="TanG.g" outputdirectory="${src}/${package}"/>
-->
<taskdef resource="org/apache/tools/ant/antlr/antlib.xml"
classpath="${lib}/antlr3-task/ant-antlr3.jar" />
<macrodef name="antlr3">
<attribute name="grammar.name"/>
<attribute name="outputdirectory" default="${lib}/grammar"/>
<attribute name="libdirectory" default="${lib}"/>
<attribute name="multithreaded" default="true"/>
<attribute name="verbose" default="true"/>
<attribute name="report" default="false"/>
<attribute name="debug" default="false"/>
<sequential>
<ant-antlr3 xmlns:antlr="org/apache/tools/ant/antlr"
target="@{grammar.name}"
outputdirectory="@{outputdirectory}"
libdirectory="@{libdirectory}"
multithreaded="@{multithreaded}"
verbose="@{verbose}"
report="@{report}"
debug="@{debug}">
<classpath>
<pathelement location="${lib}/antlr3-task/ant-antlr3.jar"/>
<path refid="build.classpath"/>
</classpath>
<jvmarg value="-Xmx512M"/>
</ant-antlr3>
</sequential>
</macrodef>
<target name="download-ivy" unless="offline">
<available file="${ivy.jar.file}" property="ivy.available"/>
<antcall target="-download-ivy" />
</target>
<target name="-download-ivy" unless="ivy.available">
<mkdir dir="${ivy.jar.dir}"/>
<!-- download Ivy from web site so that it can be used even without any special installation -->
<get src="http://repo2.maven.org/maven2/org/apache/ivy/ivy/${ivy.install.version}/ivy-${ivy.install.version}.jar"
dest="${ivy.jar.file}" usetimestamp="true"/>
</target>
<target name="install-ivy" depends="download-ivy">
<!-- try to load ivy here from ivy home, in case the user has not already dropped
it into ant's lib dir (note that the latter copy will always take precedence).
We will not fail as long as local lib dir exists (it may be empty) and
ivy is in at least one of ant's lib dir or the local lib dir. -->
<path id="ivy.lib.path">
<fileset dir="${ivy.jar.dir}" includes="*.jar"/>
</path>
<taskdef resource="org/apache/ivy/ant/antlib.xml"
uri="antlib:org.apache.ivy.ant" classpathref="ivy.lib.path"/>
</target>
<target name="resolve" depends="install-ivy" description="Resolve the dependencies">
<ivy:retrieve pattern="lib/[conf]/[artifact](-[classifier]).[ext]"/>
</target>
<target name="init" depends="resolve">
<!-- Create the time stamp -->
<tstamp/>
<!-- Create the build directory structure used by compile -->
<mkdir dir="${build}"/>
<mkdir dir="${dist}"/>
<mkdir dir="${lib}"/>
<mkdir dir="${lib}/grammar"/>
</target>
<target name="antlr_classpath">
<whichresource property="antlr.in.classpath" class="org.antlr.Tool"/>
<fail message="ANTLR3 not found via CLASSPATH ${java.class.path}">
<condition>
<not>
<isset property="antlr.in.classpath"/>
</not>
</condition>
</fail>
</target>
<target name="grammar" depends="init" description="compile the grammar" >
<!-- Compile the grammar from ${src} into ${build} -->
<antlr3 grammar.name="${src}/${grammar}" outputdirectory="${lib}/grammar"/>
<!-- <antlr3 grammar.name="${src}/${treeGrammar}" outputdirectory="${lib}/grammar"/> -->
</target>
<target name="compile" depends="grammar" description="compile the source " >
<!-- Compile the java code from ${src} into ${build} -->
<!-- includeantruntime="false" -->
<javac destdir="${build}" includeantruntime="false" verbose="false">
<classpath>
<path refid="build.classpath"/>
</classpath>
<src path="${lib}/grammar" />
</javac>
<javac destdir="${build}" includeantruntime="false" verbose="false">
<!-- <classpath path="${build}" /> -->
<classpath>
<path refid="test.classpath"/>
</classpath>
<src path="${src}" />
<exclude name="**/Test.java"/>
<!-- <exclude name="**/TreeWalker.java"/> -->
</javac>
</target>
<target name="dist" depends="compile"
description="generate the distribution" >
<!-- Create the distribution directory -->
<mkdir dir="${dist}/lib"/>
<!-- Put everything in ${build} into the Tandem-${DSTAMP}.jar file -->
<jar jarfile="${dist}/lib/Tandem-${DSTAMP}.jar" basedir="${build}"/>
</target>
<target name="parse_test" depends="compile">
<junit showoutput="no" fork="yes" haltonfailure="no">
<test name="${test.class.name}" />
<formatter type="plain" usefile="false" />
<classpath>
<pathelement path="${build}"/>
<path refid="test.classpath"/>
</classpath>
</junit>
</target>
<target name="gunit_test" depends="compile">
<copy file="${src}/${gunit_test}" tofile="${build}/${gunit_test}"/>
<java classname="org.antlr.gunit.Interp">
<arg value="${build}/${gunit_test}"/>
<classpath>
<pathelement path="${build}"/>
<path refid="runtime.classpath"/>
<path refid="test.classpath"/>
</classpath>
</java>
</target>
<target name="test" depends="gunit_test, parse_test">
</target>
<target name="walk" depends="compile">
<java classname="TandemTree">
<arg value="${file}"/>
<classpath>
<pathelement path="${build}"/>
<path refid="runtime.classpath"/>
</classpath>
</java>
</target>
<target name="rubyexec" depends="init">
<java jar="${lib}/runtime/${jruby_jar}" fork="true">
<arg value="--1.9"/>
<arg value="${file}"/>
<classpath>
<pathelement path="${build}"/>
<path refid="runtime.classpath"/>
</classpath>
</java>
</target>
<target name="rubytest" depends="compile">
<java jar="${lib}/runtime/${jruby_jar}" fork="true">
<arg value="--1.9"/>
<arg value="test/tutorial/geometry_question1_test.rb"/>
<classpath>
<pathelement path="${build}"/>
<path refid="runtime.classpath"/>
</classpath>
</java>
<java jar="${lib}/runtime/${jruby_jar}" fork="true">
<arg value="test/tutorial/geometry_question2_test.rb"/>
<classpath>
<pathelement path="${build}"/>
<path refid="runtime.classpath"/>
</classpath>
</java>
<java jar="${lib}/runtime/${jruby_jar}" fork="true">
<arg value="test/tutorial/geometry_question2_test.rb"/>
<classpath>
<pathelement path="${build}"/>
<path refid="runtime.classpath"/>
</classpath>
</java>
<java jar="${lib}/runtime/${jruby_jar}" fork="true">
<arg value="test/tutorial/geometry_question2_test.rb"/>
<classpath>
<pathelement path="${build}"/>
<path refid="runtime.classpath"/>
</classpath>
</java>
</target>
<target name="clean" description="clean up" >
<!-- Delete the ${build} and ${dist} directory trees -->
<delete dir="${build}"/>
<delete dir="${dist}"/>
<delete dir="${lib}/grammar"/>
</target>
<!-- =================================
target: clean-ivy
================================= -->
<target name="clean-ivy" depends="clean-downloads" description="--> clean the ivy installation">
<delete dir="${ivy.jar.dir}"/>
</target>
<target name="clean-downloads" description="--> clean the downloaded jars">
<delete dir="${ivy.lib.dir}/build"/>
<delete dir="${ivy.lib.dir}/runtime"/>
<delete dir="${ivy.lib.dir}/test"/>
</target>
<!-- =================================
target: clean-cache
================================= -->
<target name="clean-cache" depends="install-ivy"
description="--> clean the ivy cache">
<ivy:cleancache />
</target>
</project>