-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.xml
More file actions
143 lines (127 loc) · 5.86 KB
/
build.xml
File metadata and controls
143 lines (127 loc) · 5.86 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
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
<!--
Targets for working from terminal window:
build (default) - generates java files and compiles them
clean - removes all generated files and class files
test - run junit tests
Targets for working from Eclipse:
gen - generates java files
genClean - removes all generated files and their class files
-->
<project name="PL0" default="build" basedir=".">
<property name="projectName" value="PL0" />
<property name="fileExtension" value="pl0" />
<!-- Create the build directory to separate generated file -->
<property name="build" value="Build" />
<!-- Define the tree structure folders hat each module will follow -->
<property name="modules" value="Modules" />
<property name="aspects" value="Aspects" />
<property name="ast" value="AST" />
<property name="parser" value="Parser" />
<property name="scanner" value="Scanner" />
<property name="tests" value="Tests" />
<property name="testCases" value="Data" />
<property name="utility" value="Utility" />
<!-- The directory where tools like javacc, junit, and jastadd are stored. -->
<property name="tools" value="Tools" />
<!-- "jflex" is an ant task class for the scanner generator in JFlex.jar -->
<taskdef name="jflex" classname="JFlex.anttask.JFlexTask" classpath="${tools}/JFlex.jar" />
<!-- "beaver" is an ant task class for the parser generator in beaver.jar -->
<taskdef name="beaver" classname="beaver.comp.run.AntTask" classpath="${tools}/beaver.jar" />
<!-- The JastAdd ANT task -->
<taskdef classname="org.jastadd.JastAddTask" name="jastadd" classpath="${tools}/jastadd2.jar" />
<property name="moduleList" value="ControlFlowGraph,Unparse,SanitizedVariables,TaintedVariables,AvailableExpressions"/>
<!-- compile sources -->
<!-- build: (automatically runs "gen" if needed)
- compiles all java files
- intended to be used from the command line
(in Eclipse you don't need this target since Eclipse compiles
java files automatically) -->
<target name="build" depends="gen">
<javac
debug="false"
includeantruntime="true"
nowarn="true"
destdir="${build}"
classpath=".:${tools}/beaver.jar:tools/junit.jar">
<src path="${build}"/>
<src path="${utility}"/>
<src>
<multirootfileset basedirs="${moduleList}" type="dir">
</multirootfileset>
</src>
</javac>
</target>
<!-- generate compiler source files and compile sources -->
<target name="scanner">
<copy file="${basedir}/${scanner}/${projectName}.flex" todir="${basedir}/${build}/${scanner}"/>
</target>
<!-- compose the parser -->
<target name="parser">
<concat destfile="${build}/${parser}/${projectName}Parser.parser" binary="true" force="false">
<fileset dir="${parser}">
<include name="*.parser"/>
</fileset>
</concat>
</target>
<target name="gen" depends="genTreeStructure,scanner,parser">
<!-- JastAddTask does not support multirootfileset so copy ast and jrags into build folder first -->
<copy todir="${basedir}/${build}/${ast}">
<fileset dir="${ast}">
<include name="${projectName}.ast"/>
</fileset>
</copy>
<copy todir="${basedir}/${build}">
<multirootfileset basedirs="${moduleList}">
<include name="${aspects}/*.jrag"/>
</multirootfileset>
</copy>
<!-- run jastadd to generate AST files -->
<jastadd package="${ast}" beaver="true" rewrite="true" outdir="${basedir}/${build}">
<fileset dir="${basedir}/${build}">
<include name="${ast}/*.ast"/>
<include name="${aspects}/*.jrag"/>
</fileset>
</jastadd>
<!-- generate the scanner -->
<echo message = "Running jflex"/>
<jflex file="${basedir}/${scanner}/${projectName}.flex" outdir="${build}" nobak="yes"/>
<!-- generate the parser phase 1, translating .parser to .beaver -->
<echo message = "generating beaver input"/>
<java fork="true" dir="${basedir}/${build}" classpath="${basedir}:${tools}/proj.jar:${tools}/beaver-rt.jar" classname="Main">
<arg line="${parser}/${projectName}Parser.parser ${projectName}Parser.beaver"/>
</java>
<!-- generate the parser phase 2, translating .beaver to .java -->
<beaver file="${build}/${projectName}Parser.beaver" terminalNames="yes" compress="no" useSwitch="yes"/>
</target>
<target name="genTreeStructure">
<!-- create a directory for the generated files -->
<mkdir dir="${basedir}/${build}"/>
<mkdir dir="${basedir}/${build}/${ast}"/>
<mkdir dir="${basedir}/${build}/${parser}"/>
<mkdir dir="${basedir}/${build}/${scanner}"/>
</target>
<!-- clean:
- deletes the directory holding generated files
- deletes all .class files (recursively) -->
<target name="clean">
<delete dir="${build}" />
</target>
<!-- test: (automatically runs "build" if needed
- runs a set of tests by starting the Java program TestAll
- intended to be used from the command line -->
<target name="test" depends="build">
<!-- Copy the test cases -->
<mkdir dir="${basedir}/${build}/${tests}/${testCases}"/>
<copy todir="${basedir}/${build}">
<multirootfileset basedirs="${moduleList}">
<include name="${tests}/${testCases}/*.pl0"/>
</multirootfileset>
</copy>
<!-- Run tests -->
<java classname="${tests}.TestAll"
classpath="${build}:${tools}/beaver.jar:tools/junit.jar"
fork="true" dir="${build}">
<arg value=""/>
</java>
</target>
</project>