-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
213 lines (197 loc) · 7.67 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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
<!--
Targets for working from terminal window:
build (default) - generates java files and compiles them
clean - removes all generated files and class files
Targets for working from Eclipse:
gen - generates java files
genClean - removes all generated files and their class files
-->
<project name="JavaDB" default="build">
<!-- location of JastAddJ -->
<property name="JastAddJ" value="../JastAddJ"/>
<!-- location of Java1.4Frontend -->
<property name="Java1.4Frontend" value="${JastAddJ}/Java1.4Frontend"/>
<!-- location of Java1.4Backend -->
<property name="Java1.4Backend" value="${JastAddJ}/Java1.4Backend"/>
<!-- location of Java1.5Frontend -->
<property name="Java1.5Frontend" value="${JastAddJ}/Java1.5Frontend"/>
<!-- location of Java1.5Backend -->
<property name="Java1.5Backend" value="${JastAddJ}/Java1.5Backend"/>
<!-- "package" is the directory where generated files will be stored -->
<property name="package" value="AST"/>
<!-- "tools" is the directory where generators and libraries are located. -->
<property name="tools" value="${Java1.4Frontend}/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"/>
<!-- "jastadd" is an ant task class in jastadd2.jar -->
<taskdef name="jastadd" classname="jastadd.JastAddTask" classpath="${tools}/jastadd2.jar"/>
<!-- compile sources -->
<target name="build" depends="gen">
<javac debug="true" nowarn="true" srcdir="." includes="**/*.java" excludes="test/**,examples/**"
classpath=".:${tools}/beaver-rt.jar:${tools}/junit.jar"
includeantruntime="false"/>
</target>
<!-- generate compiler source files -->
<!-- Call Ant again, to run JastAdd with a suffient amount of memory-->
<target name="gen" depends="scanner,parser">
<exec executable="ant" failonerror="true">
<env key="ANT_OPTS" value="-Xmx256M"/>
<arg value="genWithMoreMemory"/>
</exec>
</target>
<!-- generate compiler source files -->
<!-- Needs to be called in an environment with more memory than default -->
<target name="genWithMoreMemory">
<!-- create AST node types and weave aspect modules -->
<jastadd package="${package}" rewrite="true" beaver="true" novisitcheck="true" noCacheCycle="true" outdir="${basedir}">
<fileset dir="${Java1.4Frontend}">
<include name="**/*.ast"/>
<include name="**/*.jrag"/>
<include name="**/*.jadd"/>
<exclude name="BytecodeAttributes.jrag"/>
<exclude name="BytecodeDescriptor.jrag"/>
<exclude name="BytecodeReader.jrag"/>
</fileset>
<fileset dir="${Java1.4Backend}">
<include name="**/*.ast"/>
<include name="**/*.jrag"/>
<include name="**/*.jadd"/>
</fileset>
<fileset dir="${Java1.5Frontend}">
<include name="**/*.ast"/>
<include name="**/*.jrag"/>
<include name="**/*.jadd"/>
</fileset>
<fileset dir="${Java1.5Backend}">
<include name="**/*.ast"/>
<include name="**/*.jrag"/>
<include name="**/*.jadd"/>
</fileset>
<fileset dir=".">
<include name="**/*.ast"/>
<include name="**/*.jrag"/>
<include name="**/*.jadd"/>
</fileset>
</jastadd>
<!-- copy library files-->
<copy todir="beaver" preservelastmodified="true">
<fileset dir="${Java1.4Frontend}/beaver">
<include name="**/*.java"/>
</fileset>
</copy>
</target>
<target name="scanner">
<mkdir dir="scanner"/>
<!-- compose the scanner -->
<concat destfile="scanner/JavaScanner.flex" binary="true" force="false">
<filelist dir="${Java1.4Frontend}/scanner">
<file name="preamble.flex"/>
<file name="macros.flex"/>
</filelist>
<filelist dir="${Java1.5Frontend}">
<file name="java15macros.flex"/>
</filelist>
<filelist dir="${Java1.4Frontend}/scanner">
<file name="rules_preamble.flex"/>
<file name="WhiteSpace.flex"/>
<file name="Comments.flex"/>
<file name="Keywords.flex"/>
</filelist>
<filelist dir=".">
<file name="JavaDB.flex"/>
</filelist>
<filelist dir="${Java1.5Frontend}">
<file name="java15keywords.flex"/>
</filelist>
<filelist dir="${Java1.4Frontend}/scanner">
<file name="Literals.flex"/>
</filelist>
<filelist dir="${Java1.5Frontend}">
<file name="java15literals.flex"/>
</filelist>
<filelist dir="${Java1.4Frontend}/scanner">
<file name="Separators.flex"/>
<file name="Operators.flex"/>
</filelist>
<filelist dir="${Java1.5Frontend}">
<file name="java15operators.flex"/>
<file name="java15identifiers.flex"/>
</filelist>
<filelist dir="${Java1.4Frontend}/scanner">
<file name="postamble.flex"/>
</filelist>
</concat>
<!-- generate the scanner -->
<jflex file="scanner/JavaScanner.flex" outdir="scanner" nobak="yes"/>
<copy todir="scanner" file="${Java1.4Frontend}/scanner/Unicode.java" preservelastmodified="true"/>
</target>
<target name="parser">
<mkdir dir="parser"/>
<!-- generate the parser phase 1, create a full .lalr specification from fragments-->
<concat destfile="parser/JavaParser.all" binary="true" force="false">
<filelist dir="${Java1.4Frontend}">
<file name="parser/preamble.parser"/>
<file name="parser/java14.parser"/>
<file name="parser/errorrecovery.parser"/>
</filelist>
<fileset dir="${Java1.5Frontend}">
<include name="*.parser"/>
</fileset>
<fileset dir=".">
<include name="*.parser"/>
</fileset>
</concat>
<!-- generate the parser phase 2, translating .lalr to .beaver -->
<java classpath="${tools}/JastAddParser.jar:${tools}/beaver-rt.jar" classname="Main" fork="true">
<arg line="parser/JavaParser.all parser/JavaParser.beaver"/>
</java>
<!-- generate the parser phase 3, translating .beaver to .java -->
<beaver file="parser/JavaParser.beaver" terminalNames="yes" compress="yes" useSwitch="no"/>
</target>
<!-- remove generated source files and .class files -->
<target name="clean" depends="cleanGen">
<!-- delete all .class files recursively -->
<delete>
<fileset dir="." includes="**/*.class"/>
</delete>
<delete file="JavaCompiler.jar"/>
<delete file="JavaDB-src.jar"/>
</target>
<!-- remove generated source files and .class files -->
<target name="cleanGen">
<delete dir="${package}"/>
<delete dir="beaver"/>
<delete dir="parser"/>
<delete dir="scanner"/>
</target>
<!-- build binaries -->
<target name="jar" depends="build">
<jar destfile="JavaCompiler.jar" basedir="." includes="**/*.class" excludes="test/**">
<manifest>
<attribute name="Main-Class" value="JavaCompiler"/>
</manifest>
</jar>
</target>
<!-- build a source distribution -->
<target name="source">
<jar destfile="JavaDB-src.jar">
<fileset dir="..">
<!-- include backend source file -->
<include name="JavaDB/JavaCompiler.java"/>
<include name="JavaDB/**/*.ast"/>
<include name="JavaDB/**/*.jrag"/>
<include name="JavaDB/**/*.jadd"/>
<include name="JavaDB/**/*.flex"/>
<!-- include buildfile used to build the backend -->
<include name="JavaDB/build.xml"/>
<!-- include readme and licence -->
<include name="JavaDB/README"/>
<include name="JavaDB/licences/BSD"/>
</fileset>
<manifest>
</manifest>
</jar>
</target>
</project>