forked from skishore/6035-compiler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.xml
149 lines (127 loc) · 4.77 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
<project name="Compiler" default="presubmit" basedir=".">
<property name="base_package_dir" value="edu/mit/compilers/le02" />
<property name="base_package_name" value="edu.mit.compilers.le02" />
<!-- Manually generated java files -->
<property name="src" location="src" />
<!-- Auto-generated java files -->
<property name="autogen" location="autogen" />
<!-- Target Dir for compile -->
<property name="classes" location="classes" />
<!-- Jar directory -->
<property name="dist" location="dist" />
<!-- Directory containing tests -->
<property name="tests" location="tests" />
<!-- Directory containing unit tests -->
<property name="unittests" location="${tests}/src" />
<!-- Runtime libraries -->
<property name="lib" location="lib" />
<!-- Dependencies: ANTLR 2.7.7 -->
<!-- Binaries for tools, etc. -->
<property name="bin" location="bin" />
<!-- Build up a path structure for a classpath
that includes the binaries (jars) in bin/ and
the existing classpath. Not used now,
because the jflex and cup task define their own cp,
but could come in handly later. -->
<path id="binaries">
<pathelement location="${bin}" />
<fileset dir="${bin}">
<include name="**/*.jar" />
<include name="**/*.zip" />
</fileset>
<pathelement path="${java.class.path}" />
<pathelement path="${classes}" />
</path>
<!-- Build up a path structure for a classpath
that includes the libraries and the existing classpath -->
<path id="libraries">
<pathelement location="${lib}" />
<fileset dir="${lib}">
<include name="**/*.jar" />
<include name="**/*.zip" />
</fileset>
<pathelement path="${java.class.path}" />
</path>
<target name="init">
<mkdir dir="${classes}" />
<mkdir dir="${dist}" />
<mkdir dir="${autogen}/${base_package_dir}/grammar" />
</target>
<target name="scanner" depends="init">
<antlr
target="${src}/${base_package_dir}/grammar/scanner.g"
outputdirectory="${autogen}/${base_package_dir}/grammar"
trace="yes">
<classpath>
<pathelement location="${lib}/antlr.jar" />
</classpath>
</antlr>
</target>
<target name="parser" depends="scanner">
<antlr
target="${src}/${base_package_dir}/grammar/parser.g"
outputdirectory="${autogen}/${base_package_dir}/grammar"
trace="yes">
<classpath>
<pathelement location="${lib}/antlr.jar" />
</classpath>
</antlr>
</target>
<target name="compile" depends="parser">
<javac srcdir="${autogen}:${src}:${unittests}" destdir="${classes}"
debug="on" includeantruntime="false">
<classpath refid="libraries" />
</javac>
</target>
<target name="unittests" depends="compile">
<junit failureproperty="junit.failed">
<classpath>
<path refid="libraries" />
<pathelement path="${classes}" />
</classpath>
<formatter type="plain" usefile="false" />
<batchtest fork="yes">
<fileset dir="${unittests}">
<include name="**/*Test.java" />
</fileset>
</batchtest>
</junit>
<fail if="junit.failed" message="Unit tests failed!" />
</target>
<target name="jar" depends="unittests">
<jar jarfile="${dist}/Compiler.jar" basedir="${classes}">
<manifest>
<attribute name="Main-Class" value="${base_package_name}.Main" />
<!-- ANTLR runtime is needed for parsing! -->
<attribute name="Class-Path" value="antlr.jar" />
</manifest>
</jar>
<!-- Third party libraries can only be found by java -jar if they
reside in the same dir but we don't a billion copies floating around,
so use symlinks instead. -->
<symlink link="${dist}/antlr.jar" resource="${lib}/antlr.jar"
overwrite="true" />
</target>
<target name="integrationtests" depends="jar">
<!-- Iterate over the non-unittest test directories -->
<exec executable="${tests}/scanner/test.sh" failonerror="true" />
<exec executable="${tests}/parser/test.sh" failonerror="true" />
<exec executable="${tests}/semantics/test.sh" failonerror="true" />
<exec executable="${tests}/codegen/test.sh" failonerror="true" />
<exec executable="${tests}/dataflow/test.sh" failonerror="true" />
<exec executable="${tests}/optimizer/test.sh" failonerror="true" />
<exec executable="${tests}/derby/test.sh" failonerror="false" />
</target>
<target name="lint">
<exec executable="${bin}/lint.sh" failonerror="false" />
</target>
<target name="presubmit" depends="integrationtests,lint">
</target>
<!-- to clean, delete everything in the autogen, classes, and dist
directories -->
<target name="clean">
<delete dir="${autogen}" />
<delete dir="${classes}" />
<delete dir="${dist}" />
</target>
</project>