build.xml 14.2 KB
Newer Older
1
<project name="disl" default="prepare-all" basedir=".">
Lukáš Marek's avatar
Lukáš Marek committed
2

3
4
	<property file="build.properties" />
	<property file="disl.version" />
Lukáš Marek's avatar
Lukáš Marek committed
5
6

	<path id="buildpath">
František Haas's avatar
František Haas committed
7
		<pathelement location="${bin}" />
8
		<pathelement location="${asm.path}" />
František Haas's avatar
František Haas committed
9
10
11
12
13
		<pathelement location="${junit.core.path}" />
		<pathelement location="${junit.hamcrest.path}" />
	</path>

	<path id="classpath">
14
		<pathelement location="${bin}" />
František Haas's avatar
František Haas committed
15
16
17
		<pathelement location="${asm.path}" />
		<pathelement location="${junit.core.path}" />
		<pathelement location="${junit.hamcrest.path}" />
Lukáš Marek's avatar
Lukáš Marek committed
18
19
	</path>

20
21
	<!-- it automatically compiles all other necessary stuff :) -->
	<target name="compile-tlvinserter">
22
		<mkdir dir="${bin}" />
23
		<javac srcdir="${src.disl}" includes="ch/usi/dag/disl/utilinstr/tlvinserter/" destdir="${bin}" debug="true" includeAntRuntime="false">
24
			<classpath refid="buildpath" />
Lukáš Marek's avatar
Lukáš Marek committed
25
		</javac>
Lukáš Marek's avatar
Lukáš Marek committed
26
27
	</target>

28
	<target name="prepare-extendedthread" depends="compile-tlvinserter">
29
		<mkdir dir="bin-thread/java/lang" />
30
		<java fork="true" classname="ch.usi.dag.disl.utilinstr.tlvinserter.ExtendThread">
31
			<classpath refid="buildpath" />
32
		</java>
33
34
35
		<mkdir dir="${build}" />
		<jar basedir="bin-thread" destfile="${extendedthread.path}" />
		<delete dir="bin-thread" />
Lukáš Marek's avatar
Lukáš Marek committed
36
37
	</target>

38
	<target name="compile-dynamicbypass" depends="prepare-extendedthread">
39
		<mkdir dir="${bin}" />
40
		<javac srcdir="${src.dynbypass}" destdir="${bin}" debug="true" includeAntRuntime="false">
41
			<classpath refid="buildpath" />
42
			<compilerarg value="-Xbootclasspath/p:${extendedthread.path}" />
Lukáš Marek's avatar
Lukáš Marek committed
43
		</javac>
44
		<delete file="${extendedthread.path}" />
Lukáš Marek's avatar
Lukáš Marek committed
45
46
	</target>

47
48
	<target name="compile-disl" depends="compile-dynamicbypass">
		<javac srcdir="${src.disl}" destdir="${bin}" debug="true" includeAntRuntime="false">
49
			<classpath refid="buildpath" />
Lukáš Marek's avatar
Lukáš Marek committed
50
51
		</javac>
	</target>
Lukáš Marek's avatar
Lukáš Marek committed
52

Lukáš Marek's avatar
Lukáš Marek committed
53
54
55
56
57
58
59
	<target name="compile-agent-java" depends="compile-dynamicbypass">
		<javac srcdir="${src.agent.java}" destdir="${bin}" debug="true" includeAntRuntime="false">
			<classpath refid="buildpath" />
		</javac>
	</target>

	<target name="compile-agent-c">
60
		<exec executable="make" dir="${src.agent.c}/javahome" />
Lukáš Marek's avatar
Lukáš Marek committed
61
		<exec executable="make" dir="${src.agent.c}" />
62
63
64
65
	</target>

	<target name="compile-reserver">
		<javac srcdir="${src.reserver}" destdir="${bin}" debug="true" includeAntRuntime="false">
66
67
68
69
			<classpath refid="buildpath" />
		</javac>
	</target>

70
71
	<target name="compile-redispatch">
		<javac srcdir="${src.redispatch}" destdir="${bin}" debug="true" includeAntRuntime="false">
72
73
74
75
			<classpath refid="buildpath" />
		</javac>
	</target>

76
	<target name="compile-reagent">
77
		<exec executable="make" dir="${src.reagent}/javahome" />
78
79
80
81
		<exec executable="make" dir="${src.reagent}" />
	</target>

	<target name="compile-test" depends="compile-disl,compile-reserver,compile-redispatch">
82
		<javac srcdir="${src.test}" destdir="bin" debug="true" includeAntRuntime="false">
83
			<classpath refid="buildpath" />
84
85
86
		</javac>
	</target>

Lukáš Marek's avatar
Lukáš Marek committed
87
	<target name="compile" depends="compile-disl,compile-agent-java,compile-agent-c,compile-test,compile-reserver,compile-redispatch" />
Lukáš Marek's avatar
Lukáš Marek committed
88

89
	<target name="package-dislserver" depends="compile-disl">
František Haas's avatar
František Haas committed
90
		<jar basedir="${bin}" destfile="${build}/disl-server.jar" includes="ch/usi/dag/disl/**,ch/usi/dag/dislserver/**" excludes="ch/usi/dag/disl/test/**,ch/usi/dag/disl/testtools/**">
91
			<manifest>
92
				<attribute name="Class-Path" value="${asm.lib}" />
93
				<attribute name="Main-Class" value="ch.usi.dag.dislserver.DiSLServer" />
94
				<attribute name="DiSL-Version" value="${disl.version}" />
95
96
97
98
			</manifest>
		</jar>
	</target>

Lukáš Marek's avatar
Lukáš Marek committed
99
100
101
102
103
104
105
106
107
	<target name="compile-dynamicbypass-afterbootstrap">
		<mkdir dir="${build.afterbootstrap}" />
		<javac srcdir="${src.dynbypass.act}" destdir="${build.afterbootstrap}" debug="true" includeAntRuntime="false">
			<classpath refid="buildpath" />
		</javac>
	</target>

	<target name="package-dislagent-java" depends="compile-agent-java,compile-dynamicbypass,compile-dynamicbypass-afterbootstrap">
		<!-- rename after bootstrap class -->
František Haas's avatar
František Haas committed
108
		<move file="${build.afterbootstrap}/ch/usi/dag/disl/dynamicbypass/DynamicBypassCheck.class" tofile="${build.afterbootstrap}/DynamicBypassCheck-AfterBootstrap.class" />
Lukáš Marek's avatar
Lukáš Marek committed
109

František Haas's avatar
František Haas committed
110
		<jar basedir="${bin}" destfile="${build}/disl-agent.jar" includes="ch/usi/dag/dislagent/**,ch/usi/dag/disl/dynamicbypass/**">
Lukáš Marek's avatar
Lukáš Marek committed
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125

			<manifest>
				<attribute name="Premain-Class" value="ch.usi.dag.dislagent.DiSLAgent" />
				<attribute name="Can-Redefine-Classes" value="true" />
				<attribute name="DiSL-Version" value="${disl.version}" />
			</manifest>

			<!-- include after bootstrap class -->
			<fileset file="${build.afterbootstrap}/DynamicBypassCheck-AfterBootstrap.class" />
		</jar>

		<!-- delete dir with after bootstrap class -->
		<delete dir="${build.afterbootstrap}" />
	</target>

126
	<target name="package-reserver" depends="compile-reserver">
František Haas's avatar
František Haas committed
127
		<jar basedir="${bin}" destfile="${build}/dislre-server.jar" includes="ch/usi/dag/dislreserver/**">
128
			<manifest>
129
				<attribute name="Class-Path" value="${asm.lib}" />
130
				<attribute name="Main-Class" value="ch.usi.dag.dislreserver.DiSLREServer" />
131
				<attribute name="DiSL-Version" value="${disl.version}" />
132
133
134
135
			</manifest>
		</jar>
	</target>

136
	<target name="package-redispatch" depends="compile-redispatch">
František Haas's avatar
František Haas committed
137
		<jar basedir="${bin}" destfile="${build}/dislre-dispatch.jar" includes="ch/usi/dag/dislre/**">
138
139
140
		</jar>
	</target>

Lukáš Marek's avatar
Lukáš Marek committed
141
	<target name="package" depends="package-dislserver,package-dislagent-java,package-reserver,package-redispatch,compile-agent-c,compile-reagent" />
142
143
144

	<target name="eclipse-agent" description="creates simple agent jar file for eclipse">
		<mkdir dir="build" />
145
146
		<jar jarfile="build/eclipse-agent.jar">
			<manifest>
147
				<attribute name="Premain-Class" value="ch.usi.dag.disl.testtools.agent.Agent" />
148
149
150
			</manifest>
		</jar>
	</target>
151

František Haas's avatar
František Haas committed
152
153
	<target name="eclipse-dynamicbypass" depends="compile-dynamicbypass" description="creates support library for DiSL development under eclipse">
		<jar basedir="${bin}" destfile="${build}/eclipse-dynamicbypass.jar" includes="ch/usi/dag/disl/dynamicbypass/" />
154
	</target>
155
156

	<target name="eclipse" depends="eclipse-dynamicbypass,eclipse-agent" />
Lukáš Marek's avatar
Lukáš Marek committed
157

158
159
160
161
162
163
	<target name="copy-asm">
		<copy file="${asm.path}" tofile="${build}/${asm.lib}" />
	</target>

	<target name="prepare-all" depends="package,eclipse,compile-test,copy-asm" />

Lukáš Marek's avatar
Lukáš Marek committed
164
	<target name="clean">
165
166
		<delete dir="${bin}" />
		<delete dir="${build}" />
František Haas's avatar
František Haas committed
167
		<delete dir="${build.test}" />
168
		<delete dir="${build.thread}" />
Lukáš Marek's avatar
Lukáš Marek committed
169
		<delete dir="${build.afterbootstrap}" />
170
171
172
173
		<delete dir="${dist}" />
		<exec executable="make" dir="${src.agent.c}/javahome">
			<arg value="clean" />
		</exec>
Lukáš Marek's avatar
Lukáš Marek committed
174
		<exec executable="make" dir="${src.agent.c}">
175
176
			<arg value="clean" />
		</exec>
177
178
179
		<exec executable="make" dir="${src.reagent}/javahome">
			<arg value="clean" />
		</exec>
180
181
182
		<exec executable="make" dir="${src.reagent}">
			<arg value="clean" />
		</exec>
František Haas's avatar
František Haas committed
183
		<ant antfile="example/build.xml" target="clean" useNativeBasedir="true" />
Lukáš Marek's avatar
Lukáš Marek committed
184
185
	</target>

186
	<target name="javadoc" depends="package,eclipse">
František Haas's avatar
František Haas committed
187
		<javadoc access="public" author="true" overview="doc/overview.html" classpath="build/eclipse-dynamicbypass.jar:${asm.path}" destdir="doc" nodeprecated="false" nodeprecatedlist="false" noindex="false" nonavbar="false" notree="false" packagenames="ch.usi.dag.disl.guardcontext,ch.usi.dag.disl.staticcontext,ch.usi.dag.disl.dynamiccontext,ch.usi.dag.disl.classcontext,ch.usi.dag.disl.marker,ch.usi.dag.disl.transformer,ch.usi.dag.disl.processorcontext,ch.usi.dag.disl.annotation" source="1.7" sourcefiles="src/ch/usi/dag/disl/scope/Scope.java,src/ch/usi/dag/disl/scope/ScopeImpl.java,src/ch/usi/dag/disl/DiSL.java,src/ch/usi/dag/disl/snippet/Shadow.java" sourcepath="src-test:src-agent-java:src" splitindex="true" use="true" version="true" />
188
	</target>
189

František Haas's avatar
František Haas committed
190
191
	<property name="dist.executables" value="
		**/find.sh,
192
193
		**/find.bat,
		**/disl.py" />
František Haas's avatar
František Haas committed
194

195
	<property name="dist.excludes" value="
František Haas's avatar
František Haas committed
196
197
198
199
200
		${bin}/**,
		${build}/**,
		${build.test}/**,
		${dist}/**,
		.settings/**,
201
202
		.classpath,
		.project,
František Haas's avatar
František Haas committed
203
204
		eclipse.**,
		test.py,
205
206
207
208
		run**" />

	<target name="dist-tar">
		<mkdir dir="${dist}" />
František Haas's avatar
František Haas committed
209
210
211
212
		<tar destfile="${dist}/disl-src-${disl.version}.tar">
			<tarfileset dir="." excludes="${dist.excludes}, ${dist.executables}" />
			<tarfileset dir="." includes="${dist.executables}" filemode="755" />
		</tar>
213
	</target>
František Haas's avatar
František Haas committed
214

215
216
	<target name="dist-zip">
		<mkdir dir="${dist}" />
František Haas's avatar
František Haas committed
217
218
219
220
		<zip destfile="${dist}/disl-src-${disl.version}.zip">
			<zipfileset dir="." excludes="${dist.excludes}, ${dist.executables}" />
			<zipfileset dir="." includes="${dist.executables}" filemode="755" />
		</zip>
221
222
	</target>

223
224
	<!-- *** test instrumentaion package *** -->

František Haas's avatar
František Haas committed
225
	<!-- package suite test application -->
František Haas's avatar
František Haas committed
226
227
	<target name="package-test-app">
		<jar jarfile="${build.test}/disl-app-${tmp.test.name}.jar" basedir="${bin}" includes="${tmp.test.path}/app/**">
František Haas's avatar
František Haas committed
228
			<manifest>
František Haas's avatar
František Haas committed
229
				<attribute name="Main-Class" value="${tmp.test.pkg}.app.TargetClass" />
František Haas's avatar
František Haas committed
230
231
232
233
234
			</manifest>
		</jar>
	</target>

	<!-- package suite test instrumentaton with default DiSLClass -->
František Haas's avatar
František Haas committed
235
236
	<target name="package-test-instr-nomanifest">
		<jar jarfile="${build.test}/disl-instr-${tmp.test.name}.jar" basedir="${bin}" includes="${tmp.test.path}/instr/**" excludes="${tmp.test.path}/instr/MANIFEST.MF">
František Haas's avatar
František Haas committed
237
			<manifest>
František Haas's avatar
František Haas committed
238
				<attribute name="DiSL-Classes" value="${tmp.test.path}.instr.DiSLClass" />
František Haas's avatar
František Haas committed
239
240
241
242
243
			</manifest>
		</jar>
	</target>

	<!-- package suite test instrumentaton with manifest file -->
František Haas's avatar
František Haas committed
244
245
	<target name="package-test-instr-manifest">
		<jar jarfile="${build.test}/disl-instr-${tmp.test.name}.jar" basedir="${bin}" includes="${tmp.test.path}/instr/**" excludes="${tmp.test.path}/instr/MANIFEST.MF" manifest="${tmp.test.manifest}">
František Haas's avatar
František Haas committed
246
247
248
		</jar>
	</target>

František Haas's avatar
František Haas committed
249
250
	<!-- iterates over files and runs targets on them, dir is passed as property -->
	<!-- property passed in the targets must be used directly -->
František Haas's avatar
František Haas committed
251
252
253
254
	<!--
		currently used ant-contrib instead
		javascript requires js.jar and bsf.jar in lower versions of jdk and ant
				
František Haas's avatar
František Haas committed
255
	<scriptdef name="package-test-script" language="javascript">
František Haas's avatar
František Haas committed
256
257
258
259
260
261
		<element name="dirset" type="dirset" />
		<![CDATA[
			dirsets = elements.get("dirset");
			for (i = 0; i < dirsets.size(); ++i) {
				var it = dirsets.get(i).iterator();
				while (it.hasNext()) {
262
					var name = it.next().getName();
František Haas's avatar
František Haas committed
263
264
					var path = "ch/usi/dag/disl/test/suite/" + name;
					var pkg = "ch.usi.dag.disl.test.suite." + name;
265
266
					var manifest = self.project.getProperty("src.test") + "/" + path + "/instr/MANIFEST.MF";
				
František Haas's avatar
František Haas committed
267
268
269
270
					self.project.setProperty( "tmp.test.name", name); 
					self.project.setProperty( "tmp.test.path", path); 
					self.project.setProperty( "tmp.test.pkg", pkg); 
					self.project.setProperty( "tmp.test.manifest", manifest); 
271

František Haas's avatar
František Haas committed
272
					self.project.executeTarget( "package-test-app");
273
274
					
					if (new java.io.File( manifest).exists()) {
František Haas's avatar
František Haas committed
275
						self.project.executeTarget( "package-test-instr-manifest");
276
					} else {
František Haas's avatar
František Haas committed
277
						self.project.executeTarget( "package-test-instr-nomanifest");
278
					}
František Haas's avatar
František Haas committed
279
280
281
				}
			}
		]]>
František Haas's avatar
František Haas committed
282
	</scriptdef> 
František Haas's avatar
František Haas committed
283
	
František Haas's avatar
František Haas committed
284
	<target name="package-test">
František Haas's avatar
František Haas committed
285
		<mkdir dir="${build.test}"/>
František Haas's avatar
František Haas committed
286
287
		<package-test-script>
			<dirset dir="src-test/ch/usi/dag/disl/test/suite/">
František Haas's avatar
František Haas committed
288
289
				<include name="*" />
			</dirset>
František Haas's avatar
František Haas committed
290
		</package-test-script>
František Haas's avatar
František Haas committed
291
	</target>
František Haas's avatar
František Haas committed
292
293
294
	-->

	<!-- build single suite test -->
František Haas's avatar
František Haas committed
295
296
	<target name="package-test-single">
		<antcall target="package-test-app" />
František Haas's avatar
František Haas committed
297
		<if>
František Haas's avatar
František Haas committed
298
			<available file="${tmp.test.manifest}" />
František Haas's avatar
František Haas committed
299
			<then>
František Haas's avatar
František Haas committed
300
				<antcall target="package-test-instr-manifest" />
František Haas's avatar
František Haas committed
301
302
			</then>
			<else>
František Haas's avatar
František Haas committed
303
				<antcall target="package-test-instr-nomanifest" />
František Haas's avatar
František Haas committed
304
305
306
			</else>
		</if>
	</target>
František Haas's avatar
František Haas committed
307

František Haas's avatar
František Haas committed
308
	<!-- build jars for every directory in suite tests -->
František Haas's avatar
František Haas committed
309
	<target name="package-test">
František Haas's avatar
František Haas committed
310
311
312
313
314
315
316
317
318
319
		<taskdef resource="${ant-contrib.resource}">
			<classpath>
				<pathelement location="${ant-contrib.path}" />
			</classpath>
		</taskdef>

		<mkdir dir="${build.test}" />

		<for param="file">
			<path>
František Haas's avatar
František Haas committed
320
				<dirset dir="src-test/ch/usi/dag/disl/test/suite/">
František Haas's avatar
František Haas committed
321
322
323
324
325
					<include name="*" />
				</dirset>
			</path>
			<sequential>
				<propertyregex override="yes" property="basename" input="@{file}" regexp="(.*)/(.*)" replace="\2" />
František Haas's avatar
František Haas committed
326
327
328
329
330
				<antcall target="package-test-single">
					<param name="tmp.test.name" value="${basename}" />
					<param name="tmp.test.path" value="ch/usi/dag/disl/test/suite/${basename}" />
					<param name="tmp.test.pkg" value="ch.usi.dag.disl.test.suite.${basename}" />
					<param name="tmp.test.manifest" value="${src.test}/ch/usi/dag/disl/test/suite/${basename}/instr/MANIFEST.MF" />
František Haas's avatar
František Haas committed
331
332
333
334
335
336
				</antcall>
			</sequential>
		</for>
	</target>

	<!-- copy resource files needed to run the tests from source to bin directory -->
František Haas's avatar
František Haas committed
337
	<target name="copy-test-resource">
František Haas's avatar
František Haas committed
338
339
340
341
342
343
344
		<copy todir="${bin}">
			<fileset dir="${src.test}">
				<include name="**/*.resource" />
			</fileset>
		</copy>
	</target>

František Haas's avatar
František Haas committed
345
	<target name="prepare-test" depends="prepare-all, copy-test-resource, package-test" />
František Haas's avatar
František Haas committed
346

František Haas's avatar
František Haas committed
347
	<!-- run all junit and junit wrapped suite tests -->
František Haas's avatar
František Haas committed
348
	<target name="test" depends="prepare-test">
František Haas's avatar
František Haas committed
349
		<junit haltonfailure="no" haltonerror="no" failureproperty="junit.failure">
František Haas's avatar
František Haas committed
350
351
			<classpath refid="classpath" />
			<formatter type="brief" usefile="false" />
František Haas's avatar
František Haas committed
352
			<!-- allow properties starting with "-Ddisl." to be passed to tests -->
František Haas's avatar
František Haas committed
353
354
355
356
357
			<syspropertyset>
				<propertyref prefix="disl" />
			</syspropertyset>
			<batchtest fork="yes">
				<fileset dir="${src.test}">
František Haas's avatar
František Haas committed
358
359
					<include name="ch/usi/dag/disl/test/junit/*Test.java" />
					<include name="ch/usi/dag/disl/test/suite/*/junit/*Test.java" />
František Haas's avatar
František Haas committed
360
361
362
363
				</fileset>
			</batchtest>
		</junit>
	</target>
František Haas's avatar
František Haas committed
364

František Haas's avatar
František Haas committed
365
366
	<target name="report-test-name" depends="check-test-name" unless="test.name.set">
		<fail message="Property test.name is not set. Set it using -Dtest.name=value" />
František Haas's avatar
František Haas committed
367
	</target>
František Haas's avatar
František Haas committed
368

František Haas's avatar
František Haas committed
369
370
371
	<target name="check-test-name">
		<condition property="test.name.set">
			<isset property="test.name" />
František Haas's avatar
František Haas committed
372
373
		</condition>
	</target>
František Haas's avatar
František Haas committed
374
375

	<!-- run single suite test -->
František Haas's avatar
František Haas committed
376
	<target name="suite-test" depends="prepare-test, report-test-name">
František Haas's avatar
František Haas committed
377
		<junit haltonfailure="no" haltonerror="no" failureproperty="junit.failure">
František Haas's avatar
František Haas committed
378
379
			<classpath refid="classpath" />
			<formatter type="brief" usefile="false" />
380
			<!-- allow "disl.", "dislserver.", and "dislreserver." properties to be passed to tests -->
František Haas's avatar
František Haas committed
381
			<syspropertyset>
382
383
384
				<propertyref prefix="disl." />
				<propertyref prefix="dislserver." />
				<propertyref prefix="dislreserver." />
František Haas's avatar
František Haas committed
385
386
387
			</syspropertyset>
			<batchtest fork="yes">
				<fileset dir="${src.test}">
František Haas's avatar
František Haas committed
388
					<include name="*ch/usi/dag/disl/test/suite/${test.name}/junit/*Test.java" />
František Haas's avatar
František Haas committed
389
390
391
392
				</fileset>
			</batchtest>
		</junit>
	</target>
Lukáš Marek's avatar
Lukáš Marek committed
393
</project>