-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.xml
95 lines (83 loc) · 3.61 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
<?xml version="1.0" encoding="UTF-8"?>
<project name="MiniJava Compiler" default="jar" basedir=".">
<description>
This ant buildfile contains a default target that builds the compiler,
runs the parser generator and lexer generator (from the lib directory),
and then generates one compiler (or several compilers) as a jar file.
</description>
<!-- set global properties for this build -->
<property name="bin" location="bin"/>
<property name="dist" location="dist"/>
<property name="lib" location="lib"/>
<property name="src" location="src"/>
<property name="src.lex" location="${src}/lex"/>
<property name="src.parser" location="${src}/parser"/>
<target name="init">
<tstamp/>
<mkdir dir="${bin}"/>
</target>
<target name="lexerUpToDateCheck">
<uptodate property="lexerUpToDate" srcfile="${src.lex}/minijava.lex"
targetfile="${src.lex}/Lexer.java"/>
</target>
<target name="lexer" depends="lexerUpToDateCheck" unless="lexerUpToDate" description="Generates the lexer source.">
<java jar="${lib}/JFlex.jar" fork="true">
<arg file="${src.lex}/minijava.lex"/>
</java>
</target>
<target name="parserUpToDateCheck">
<condition property="parserUpToDate">
<and>
<uptodate srcfile="${src.parser}/parser.cup" targetfile="${src.parser}/parser.java"/>
<uptodate srcfile="${src.parser}/parser.cup" targetfile="${src.parser}/sym.java"/>
</and>
</condition>
</target>
<target name="parser" depends="parserUpToDateCheck" unless="parserUpToDate" description="Generates the parser source.">
<java jar="${lib}/java-cup-11a.jar" fork="true" dir="${src.parser}" input="${src.parser}/parser.cup"/>
</target>
<target name="compile" depends="init,lexer,parser" description="Compile the source in ${src} into ${bin}">
<javac srcdir="${src}" destdir="${bin}" classpath="${lib}/*.jar" includeantruntime="no">
<classpath>
<fileset dir="${lib}">
<include name="*.jar"/>
</fileset>
</classpath>
</javac>
</target>
<target name="jar" depends="compile,jasminJarJar" description="Create JAR file">
<jar destfile="mjc.jar">
<fileset dir="${bin}"/>
</jar>
</target>
<target name="jasminJarJarUpToDateCheck">
<uptodate property="jasminJarJarUpToDate" srcfile="res/jasmin.jar"
targetfile="lib/jasmin-jarjar.jar"/>
</target>
<target name="jasminJarJar" depends="jasminJarJarUpToDateCheck" unless="jasminJarJarUpToDate">
<taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask"
classpath="res/jarjar-1.1.jar"/>
<jarjar jarfile="lib/jasmin-jarjar.jar">
<zipfileset src="res/jasmin.jar"/>
<rule pattern="java_cup.**" result="jarjar.java_cup.@1"/>
</jarjar>
</target>
<target name="run" depends="compile">
<java classname="mjc.JVMMain">
<arg value="${run.args.filename}"/>
<classpath>
<pathelement path="${bin}"/>
<fileset dir="${lib}">
<include name="*.jar"/>
</fileset>
</classpath>
</java>
</target>
<target name="clean" description="Remove all generated files.">
<delete dir="${bin}"/>
<delete file="${src.lex}/Lexer.java"/>
<delete file="${src.lex}/Lexer.java~"/>
<delete file="${src.parser}/parser.java"/>
<delete file="mjc.jar"/>
</target>
</project>