-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
181 lines (161 loc) · 6.17 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
<project name="compiler-design" default="antlr-parser-source" basedir=".">
<!-- A very simple ant file that primarily exists to run cup and lex;
it also includes targets to build the compiler and run tests for those
who would rather not use Eclipse -->
<!-- Set project properties. -->
<property name="src.dir" value="src"/>
<property name="test.dir" value="test"/>
<property name="parser.dir" value="${src.dir}/cd/parser"/>
<property name="build.dir" value="bin"/>
<property name="javacup.jar" value="lib/java-cup-11a-eth.jar"/>
<property name="jlex.jar" value="lib/jlex-1.2.6-eth.jar"/>
<property name="junit.jar" value="lib/junit-4.4.jar"/>
<property name="antlr.jar" value="lib/antlr-3.4.jar"/>
<property name="antlr3task.jar" value="lib/antlr3task.jar"/>
<property name="obfuscated.jar" value="lib/parser_.jar"/>
<property name="antlr.profile" value="false"/>
<property name="antlr.report" value="false"/>
<macrodef name="invokeAntlr3">
<attribute name="grammar.name"/>
<attribute name="target.dir" default="${parser.dir}"/>
<sequential>
<echo message="ANTLR ${parser.dir}/@{grammar.name}" level="info"/>
<antlr3 xmlns:antlr="antlib:org/apache/tools/ant/antlr"
target="${parser.dir}/@{grammar.name}"
outputdirectory="@{target.dir}"
libdirectory="@{target.dir}"
multithreaded="false"
report="${antlr.report}"
profile="${antlr.profile}"
depend="true">
<classpath>
<pathelement location="${antlr.jar}"/>
</classpath>
</antlr3>
</sequential>
</macrodef>
<macrodef name="invokeAntlr3Debug">
<attribute name="grammar.name" />
<attribute name="target.dir" default="${parser.dir}" />
<sequential>
<echo message="ANTLR ${parser.dir}/@{grammar.name}" level="info" />
<antlr3 xmlns:antlr="antlib:org/apache/tools/ant/antlr"
target="${parser.dir}/@{grammar.name}"
outputdirectory="@{target.dir}"
libdirectory="@{target.dir}"
multithreaded="false"
report="${antlr.report}"
profile="${antlr.profile}"
depend="true"
debug="true">
<classpath>
<pathelement location="${antlr.jar}"/>
</classpath>
</antlr3>
</sequential>
</macrodef>
<target name="antlr-parser-source">
<taskdef name="antlr3" classname="org.apache.tools.ant.antlr.ANTLR3" classpath="${antlr3task.jar}"/>
<invokeAntlr3 grammar.name="Javali.g"/>
<invokeAntlr3 grammar.name="JavaliWalker.g"/>
</target>
<target name="antlr-debug-parser-source">
<taskdef name="antlr3" classname="org.apache.tools.ant.antlr.ANTLR3" classpath="${antlr3task.jar}"/>
<invokeAntlr3 grammar.name="Javali.g"/>
<invokeAntlr3Debug grammar.name="JavaliWalker.g"/>
</target>
<!-- Deletes the generated ANTLR parser files. Don't use in A1! -->
<target name="clean-antlr-parser">
<delete file="${parser.dir}/Javali.tokens"/>
<delete file="${parser.dir}/JavaliLexer.java"/>
<delete file="${parser.dir}/JavaliParser.java"/>
<delete file="${parser.dir}/JavaliWalker.tokens"/>
<delete file="${parser.dir}/JavaliWalker.java"/>
</target>
<!-- Deletes the generated parser files. Don't use in A1! -->
<target name="clean-cup-parser">
<delete file="${parser.dir}/sym.java"/>
<delete file="${parser.dir}/parser.java"/>
<delete file="${parser.dir}/Yylex.java"/>
</target>
<!-- Generates the source to the parser from .cup/.lex files.
Not needed in A1. -->
<target name="cup-parser-source">
<!-- Generate parser.java and sym.java -->
<java jar="${javacup.jar}" fork="true">
<arg line="-package cd.ir.parser"/>
<arg line="-destdir ${parser.dir}"/>
<arg line="-dump"/>
<arg file="${parser.dir}/javali.cup"/>
<classpath>
<pathelement location="${javacup.jar}"/>
</classpath>
</java>
<!-- Generate ${lang}.lex.java -->
<java classname="JLex.Main">
<arg file="${parser.dir}/javali.lex"/>
<classpath>
<pathelement location="${jlex.jar}"/>
</classpath>
</java>
<!-- for some reason lex can't figure out how to give its output
a reasonable name, so we have to clean up after it -->
<move file="${parser.dir}/javali.lex.java"
tofile="${parser.dir}/Yylex.java"/>
</target>
<!-- Cleans generated code, but NOT the parser source! -->
<target name="clean">
<delete dir="${build.dir}"/>
</target>
<!-- Builds the compiler framework. -->
<target name="compile">
<mkdir dir="${build.dir}"/>
<javac srcdir="${src.dir}" destdir="${build.dir}" debug="true">
<classpath>
<pathelement location="${javacup.jar}"/>
<pathelement location="${jlex.jar}"/>
<pathelement location="${antlr.jar}"/>
<pathelement location="${obfuscated.jar}"/>
</classpath>
</javac>
<javac srcdir="${test.dir}" destdir="${build.dir}" debug="true">
<classpath>
<pathelement location="${javacup.jar}"/>
<pathelement location="${jlex.jar}"/>
<pathelement location="${junit.jar}"/>
<pathelement location="${antlr.jar}"/>
<pathelement location="${obfuscated.jar}"/>
</classpath>
</javac>
</target>
<!-- Deletes all byproducts of running the tests except for ref files -->
<target name="clean-test">
<delete>
<fileset dir="javali_tests" includes="**/*.err"/>
<fileset dir="javali_tests" includes="**/*.s"/>
<fileset dir="javali_tests" includes="**/*.bin"/>
<fileset dir="javali_tests" includes="**/*.dot"/>
</delete>
</target>
<!-- Like clean-test but deletes ref files too -->
<target name="clean-test-all" depends="clean-test">
<delete>
<fileset dir="javali_tests" includes="**/*.ref"/>
</delete>
</target>
<!-- Runs the tests. Use the compile target first! -->
<target name="test">
<java classname="org.junit.runner.JUnitCore" fork="yes">
<jvmarg value="-ea"/>
<classpath>
<pathelement location="${build.dir}"/>
<pathelement location="${javacup.jar}"/>
<pathelement location="${jlex.jar}"/>
<pathelement location="${junit.jar}"/>
<pathelement location="${antlr.jar}"/>
<pathelement location="${obfuscated.jar}"/>
</classpath>
<arg value="cd.test.TestSamplePrograms"/>
</java>
</target>
</project>