This repository was archived by the owner on Dec 28, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.xml
More file actions
118 lines (106 loc) · 3.59 KB
/
build.xml
File metadata and controls
118 lines (106 loc) · 3.59 KB
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
<project name="Compiler" default="jar" basedir=".">
<!-- Manually generated java files -->
<property name="src" location="src" />
<!-- Auto-generated java files -->
<property name="java" location="java" />
<!-- 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" />
<!-- We rely on ANTLR 4.5.3 -->
<!-- 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">
<delete dir="${java}/decaf"/>
<mkdir dir="${classes}"/>
<mkdir dir="${java}"/>
<mkdir dir="${dist}"/>
<mkdir dir="${java}/decaf"/>
</target>
<!-- copy manual edited sources to automatically generated ones -->
<target name="copy_src" depends="init">
<copy todir="${java}">
<fileset dir="${src}" includes="**/**.java" />
</copy>
</target>
<macrodef name="antlr4">
<attribute name="srcpath"/>
<element name="args" optional="true"/>
<sequential>
<local name="package"/>
<local name="paths.antlr4.local"/>
<java classname="org.antlr.v4.Tool" fork="true" failonerror="true" dir="${src}">
<arg value="-o"/>
<arg value="${java}/decaf"/>
<args/>
<arg line="@{srcpath}"/>
<classpath>
<pathelement location="${lib}/antlr.jar"/>
</classpath>
</java>
</sequential>
</macrodef>
<target name="scanner" depends="init">
<antlr4
srcpath="${src}/decaf/DecafLexer.g4">
</antlr4>
</target>
<target name="parser" depends="scanner">
<!-- set trace="yes" if you want to trace the praser actions -->
<antlr4
srcpath="${src}/decaf/DecafParser.g4">
</antlr4>
</target>
<target name="compile" depends="parser">
<javac srcdir="${java}:${src}" destdir="${classes}" debug="on">
<classpath refid="libraries"/>
</javac>
</target>
<target name="jar" depends="compile">
<jar jarfile="${dist}/Compiler.jar" basedir="${classes}">
<zipgroupfileset dir="lib" includes="symtab-1.0.8.jar" />
<manifest>
<attribute name="Main-Class" value="decaf.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 -->
<copy todir="${dist}">
<fileset dir="${lib}" includes="**/**.jar"/>
</copy>
</target>
<!-- to clean, delete everything in the java, classes, and dist
directory -->
<target name="clean">
<delete dir="${java}" />
<delete dir="${classes}" />
<delete dir="${dist}" />
</target>
</project>