-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.xml
123 lines (108 loc) · 4.02 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
<project name="Compiler" default="jar" basedir=".">
<property environment="env" />
<property name="phase" value="parser" />
<property name="base_package_dir" value="edu/mit/compilers" />
<property name="base_package_name" value="edu.mit.compilers" />
<!-- 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" />
<!-- Runtime libraries -->
<property name="lib" location="lib" />
<!-- Binaries for tools, etc. -->
<property name="bin" location="bin" />
<!-- Directory containing tests -->
<property name="tests" location="tests" />
<!-- We rely on ANTLR 2.7.7 -->
<!-- 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/parser2.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}" destdir="${classes}"
debug="on" includeantruntime="false"
excludes="${src}/${base_package_dir}/semchecker/SemanticCheckTests.java"
>
<classpath refid="libraries" />
</javac>
</target>
<target name="jar" depends="compile">
<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="test_scanner" depends="jar">
<!-- Set failonerror="true" when you're confident you're correct
and want to prevent accidentally regressing. -->
<exec executable="${tests}/scanner/test.sh" />
</target>
<target name="test_parser" depends="jar">
<!-- Set failonerror="true" when you're confident you're correct
and want to prevent accidentally regressing. -->
<exec executable="${tests}/parser/test.sh" />
</target>
<!-- to clean, delete everything in the autogen, classes, and dist
directory -->
<target name="clean">
<delete dir="${classes}" />
<delete dir="${dist}" />
</target>
</project>