-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathbuild.xml
214 lines (168 loc) · 7.51 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
<project name="jlang" default="compile-all" basedir=".">
<description>
JLang build file
</description>
<!-- ****************************************
set global properties for this build
**************************************** -->
<!-- extension package name -->
<property name="package.dir" value="jlang"/>
<!-- extension language name -->
<property name="name" value="jlang"/>
<!-- extension compiler script name -->
<property name="compiler.name" value="${name}c"/>
<!-- extension interpreter script name -->
<property name="interp.sh.name" value="${name}"/>
<!-- jar file names -->
<property name="compiler.jar.name" value="${name}.jar"/>
<!-- source directory -->
<property name="compiler.src" location="${basedir}/compiler/src" />
<!-- directory for class file targets -->
<property name="compiler.classes" location="${basedir}/compiler/classes" />
<!-- binaries directory -->
<property name="bin.dir" location="${basedir}/bin" />
<!-- directory for shared libraries -->
<property name="lib.dir" location="${basedir}/lib" />
<!-- distribution directory -->
<property name="dist" location="${basedir}/dist" />
<property name="compiler.sh" location="${bin.dir}/${compiler.name}"/>
<property name="compiler.bat" location="${bin.dir}/${compiler.name}.bat"/>
<property name="interp.sh" location="${bin.dir}/${interp.sh.name}"/>
<property name="compiler.jar" location="${lib.dir}/${compiler.jar.name}"/>
<!-- set the prefix for accessing environment variables -->
<property environment="env" />
<!-- the Polyglot project -->
<property name="polyglot.home" value="${lib.dir}/polyglot" />
<!-- the standard classpath -->
<path id="standard.classpath">
<!-- our generated classes -->
<pathelement location="${compiler.classes}" />
<!-- the java classpath -->
<pathelement path="${java.class.path}" />
<!-- the Polyglot classpath -->
<pathelement path="${polyglot.home}/lib/polyglot.jar"/>
<pathelement path="${polyglot.home}/lib/jflex.jar"/>
<pathelement path="${polyglot.home}/lib/java_cup.jar"/>
<!-- jar files in the lib directory, excluding generated jars -->
<fileset dir="${lib.dir}">
<include name="*.jar" />
<exclude name="${name}.jar" />
<exclude name="${name}-rt.jar" />
</fileset>
</path>
<!-- ****************************************
Clean up targets and other admin tasks
**************************************** -->
<target name="clean" description="clean up">
<!-- Delete the ${compiler.classes} and ${dist} directory trees -->
<delete dir="${compiler.classes}" />
<delete dir="${dist}" />
<delete includeemptydirs="true">
<fileset dir="${basedir}/tests">
<include name="**/*.class" />
<include name="**/*~" />
<include name="pthOutput*/**/*" />
<include name="pthOutput*" />
</fileset>
</delete>
</target>
<target name="clobber" depends="clean" description="removes all generated files">
<delete includeemptydirs="true">
<fileset dir="${compiler.src}">
<include name="**/Grm.java" />
<include name="**/sym.java" />
<include name="**/Lexer_c.java" />
<include name="**/*_ppg.cup" />
</fileset>
<fileset dir="${lib.dir}">
<include name="${compiler.jar.name}" />
</fileset>
</delete>
</target>
<!-- initialize the build -->
<target name="init">
<!-- Create the time stamp -->
<tstamp />
<!-- Create the build directory structures used by compile -->
<mkdir dir="${compiler.classes}" />
</target>
<!-- ****************************************
Configuration
**************************************** -->
<target name="check-classpath" description="Check the classpath contains the appropriate directories/jars">
<available classname="polyglot.main.Main"
classpathref="standard.classpath"
property="cp_existence.polyglot"/>
<fail unless="cp_existence.polyglot"
message="The polyglot classes must be on the classpath. Try adding polyglot.jar to the classpath."/>
</target>
<!-- ****************************************
targets
**************************************** -->
<target name="compile-all" depends="compiler" description="Build the compiler and libraries"/>
<target name="compiler" depends="init,check-classpath">
<antcall target="compile-ext">
<param name="ext" value="${name}" />
<param name="ext.pkg" value="${package.dir}" />
</antcall>
</target>
<!-- ****************************************
Javadoc and distribution targets
**************************************** -->
<target name="jar" depends="compile-all">
<jar jarfile="${compiler.jar}" basedir="${compiler.classes}" includes="${package.dir}/**" />
</target>
<target name="javadoc" depends="compiler">
<javadoc sourcepath="${compiler.src}" destdir="${basedir}/doc/${name}-api" defaultexcludes="yes" classpathref="standard.classpath">
<packageset dir="${compiler.src}" defaultexcludes="yes">
<include name="**" />
</packageset>
</javadoc>
</target>
<!-- generate the distribution -->
<target name="dist" description="generate the distribution">
<!-- Create the distribution directory -->
<mkdir dir="${dist}" />
<!-- Clobber everything so we're in a clean state -->
<antcall target="clobber" />
<!-- Copy src files over. -->
<copy todir="${dist}" includeEmptyDirs="no">
<fileset dir="${basedir}" defaultexcludes="yes">
<include name="compiler/src/**" />
<include name="tests/*" />
<include name="README" />
<include name="LICENSE" />
<include name="CHANGES" />
<include name="build.xml" />
</fileset>
</copy>
<!-- Create the Javadoc, and copy the documentation -->
<antcall target="javadoc" />
<copy todir="${dist}" includeEmptyDirs="no">
<fileset dir="${basedir}" defaultexcludes="yes">
<include name="doc/*api/**" />
<include name="doc/*.html" />
<include name="doc/*.css" />
</fileset>
</copy>
<!-- Create the jar files and copy all the jars over -->
<antcall target="jar" />
<copy todir="${dist}" includeEmptyDirs="no">
<fileset dir="${basedir}" defaultexcludes="yes">
<include name="lib/*.jar" />
</fileset>
</copy>
</target>
<!-- ****************************************
"Reusable" targets
**************************************** -->
<!-- compile a single extension.
@param ${ext} the name of the extension
@param ${ext.pkg} the package directory of the extension
-->
<target name="compile-ext">
<javac source="1.8" target="1.8" srcdir="${compiler.src}" destdir="${compiler.classes}" debug="on" includes="${ext.pkg}/**" includeantruntime="false">
<classpath refid="standard.classpath" />
</javac>
</target>
</project>