build.xml 12.6 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">
90
		<jar basedir="${bin}" destfile="${build}/disl-server.jar"
91 92
			includes="ch/usi/dag/disl/**,ch/usi/dag/dislserver/**"
			excludes="ch/usi/dag/disl/test/**,ch/usi/dag/disl/testtools/**">
93

94
			<manifest>
95
				<attribute name="Class-Path" value="${asm.lib}" />
96
				<attribute name="Main-Class" value="ch.usi.dag.dislserver.DiSLServer" />
97
				<attribute name="DiSL-Version" value="${disl.version}" />
98 99 100 101
			</manifest>
		</jar>
	</target>

Lukáš Marek's avatar
Lukáš Marek committed
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
	<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 -->
		<move file="${build.afterbootstrap}/ch/usi/dag/disl/dynamicbypass/DynamicBypassCheck.class"
			tofile="${build.afterbootstrap}/DynamicBypassCheck-AfterBootstrap.class" />

		<jar basedir="${bin}" destfile="${build}/disl-agent.jar"
			includes="ch/usi/dag/dislagent/**,ch/usi/dag/disl/dynamicbypass/**">

			<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>

132 133
	<target name="package-reserver" depends="compile-reserver">
		<jar basedir="${bin}" destfile="${build}/dislre-server.jar"
134 135
			includes="ch/usi/dag/dislreserver/**">
			<manifest>
136
				<attribute name="Class-Path" value="${asm.lib}" />
137
				<attribute name="Main-Class" value="ch.usi.dag.dislreserver.DiSLREServer" />
138
				<attribute name="DiSL-Version" value="${disl.version}" />
139 140 141 142
			</manifest>
		</jar>
	</target>

143 144
	<target name="package-redispatch" depends="compile-redispatch">
		<jar basedir="${bin}" destfile="${build}/dislre-dispatch.jar"
145 146 147 148
			includes="ch/usi/dag/dislre/**">
		</jar>
	</target>

Lukáš Marek's avatar
Lukáš Marek committed
149
	<target name="package" depends="package-dislserver,package-dislagent-java,package-reserver,package-redispatch,compile-agent-c,compile-reagent" />
150 151 152

	<target name="eclipse-agent" description="creates simple agent jar file for eclipse">
		<mkdir dir="build" />
153 154
		<jar jarfile="build/eclipse-agent.jar">
			<manifest>
155
				<attribute name="Premain-Class" value="ch.usi.dag.disl.testtools.agent.Agent" />
156 157 158
			</manifest>
		</jar>
	</target>
159 160 161

	<target name="eclipse-dynamicbypass" depends="compile-dynamicbypass"
		description="creates support library for DiSL development under eclipse">
162

163 164
		<jar basedir="${bin}" destfile="${build}/eclipse-dynamicbypass.jar"
			includes="ch/usi/dag/disl/dynamicbypass/" />
165
	</target>
166 167

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

169 170 171 172 173 174
	<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
175
	<target name="clean">
176 177
		<delete dir="${bin}" />
		<delete dir="${build}" />
František Haas's avatar
František Haas committed
178
		<delete dir="${build.test}" />
179
		<delete dir="${build.thread}" />
Lukáš Marek's avatar
Lukáš Marek committed
180
		<delete dir="${build.afterbootstrap}" />
181 182 183 184
		<delete dir="${dist}" />
		<exec executable="make" dir="${src.agent.c}/javahome">
			<arg value="clean" />
		</exec>
Lukáš Marek's avatar
Lukáš Marek committed
185
		<exec executable="make" dir="${src.agent.c}">
186 187
			<arg value="clean" />
		</exec>
188 189 190
		<exec executable="make" dir="${src.reagent}/javahome">
			<arg value="clean" />
		</exec>
191 192 193 194 195
		<exec executable="make" dir="${src.reagent}">
			<arg value="clean" />
		</exec>
		

Lukáš Marek's avatar
Lukáš Marek committed
196 197
	</target>

198 199 200
	<target name="javadoc" depends="package,eclipse">
		<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"/>
	</target>
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217

	<property name="dist.excludes" value="
		.classpath,
		.project,
		${dist}/**,
		bin/**,
		build/**,
		src-test/**,
		run**" />

	<target name="dist-tar">
		<mkdir dir="${dist}" />
		<tar
			destfile="${dist}/disl-src-${disl.version}.tar"
			basedir="."
			excludes="${dist.excludes}" />
	</target>
218
	
219 220 221 222 223 224 225 226
	<target name="dist-zip">
		<mkdir dir="${dist}" />
		<zip
			destfile="${dist}/disl-src-${disl.version}.zip"
			basedir="."
			excludes="${dist.excludes}" />
	</target>

227 228
	<!-- *** test instrumentaion package *** -->

František Haas's avatar
František Haas committed
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338
	<!-- iterates over files and runs targets on them, dir is passed as property -->
	<!-- property passed in the targets must be used directly -->
	<scriptdef name="package-test2-script" language="javascript">
		<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()) {
					dir = it.next().getName();
					self.project.setProperty( "tmp.test2.name", dir); 
					self.project.executeTarget( "package-test2-app");
					self.project.executeTarget( "package-test2-instr");
				}
			}
		]]>
	</scriptdef>
	
	<target name="package-test2-app">
		<jar jarfile="${build.test}/disl-app-${tmp.test2.name}.jar"
		     basedir="${bin}"
		     includes="ch/usi/dag/disl/test2/suite/${tmp.test2.name}/app/**">
			<manifest>
				<attribute name="Main-Class" value="ch.usi.dag.disl.test2.suite.${tmp.test2.name}.app.TargetClass" />
			</manifest>
		</jar>
	</target>
	
	<target name="package-test2-instr">
		<jar jarfile="${build.test}/disl-instr-${tmp.test2.name}.jar"
		     basedir="${bin}"
		     includes="ch/usi/dag/disl/test2/suite/${tmp.test2.name}/instr/**"
		     excludes="ch/usi/dag/disl/test2/suite/${tmp.test2.name}/instr/MANIFEST.MF">
			<manifest>
				<attribute name="DiSL-Classes" value="ch.usi.dag.disl.test2.suite.${tmp.test2.name}.instr.DiSLClass" />
			</manifest>
		</jar>
	</target>

	<target name="package-test2">
		<mkdir dir="${build.test}"/>
		<package-test2-script>
			<dirset dir="src-test/ch/usi/dag/disl/test2/suite/">
				<include name="*" />
			</dirset>
		</package-test2-script>
	</target>

	<target name="copy-test2">
		<copy todir="${bin}">
			<fileset dir="${src.test}">
				<include name="**/*.resource" />
			</fileset>
		</copy>
	</target>

	<target name="prepare-test2" depends="prepare-all, copy-test2, package-test2" />

	<target name="test2" depends="prepare-test2">
		<junit 
				haltonfailure="no"
				haltonerror="no"
				failureproperty="junit.failure">
			<classpath refid="classpath" />
			<formatter type="brief" usefile="false" />
			<!-- allows properties starting with "-Ddisl." to be passed to tests -->
			<syspropertyset>
				<propertyref prefix="disl" />
			</syspropertyset>
			<batchtest fork="yes">
				<fileset dir="${src.test}">
					<include name="*ch/usi/dag/disl/test2/junit/*Test.java" />
					<include name="*ch/usi/dag/disl/test2/suite/*/junit/*Test.java" />
				</fileset>
			</batchtest>
		</junit>
	</target>
	
	<target
			name="report-test2-name"
			depends="check-test2-name"
			unless="test2.name.set">
		<fail message="Property test2.name is not set. Set it using -Dtest2.name=value" />
	</target>
	
	<target name="check-test2-name">
		<condition property="test2.name.set">
			<isset property="test2.name"/>
		</condition>
	</target>
	
	<target name="suite-test2" depends="prepare-test2, report-test2-name">
		<junit 
				haltonfailure="no"
				haltonerror="no"
				failureproperty="junit.failure">
			<classpath refid="classpath" />
			<formatter type="brief" usefile="false" />
			<!-- allows properties starting with "-Ddisl." to be passed to tests -->
			<syspropertyset>
				<propertyref prefix="disl" />
			</syspropertyset>
			<batchtest fork="yes">
				<fileset dir="${src.test}">
					<include name="*ch/usi/dag/disl/test2/suite/${test2.name}/junit/*Test.java" />
				</fileset>
			</batchtest>
		</junit>
	</target>
	
339 340 341 342 343 344 345 346 347 348 349 350 351 352
	<target name="check-test-property">
		<condition property="test.set">
			<isset property="test.name"/>
		</condition>
	</target>

	<target name="report-missing-property" depends="check-test-property" unless="test.set">
		<fail message="Property test.name is not set. Set it using -Dtest.name=value" />
	</target>

	<property name="test.path" value="ch/usi/dag/disl/test/${test.name}"/>

	<target name="package-test" depends="report-missing-property,prepare-all" description="create instrumentation package for specified test">
		<mkdir dir="${build}"/>
František Haas's avatar
František Haas committed
353 354
		<jar jarfile="${build}/${instr.jar.name}.jar"
		     basedir="${bin}"
František Haas's avatar
František Haas committed
355
		     includes="${test.gath}/**"
František Haas's avatar
František Haas committed
356 357 358 359 360 361 362 363 364
		     excludes="${test.path}/TargetClass*.class ${test.path}/MANIFEST.MF"
		     manifest="${src.test}/${test.path}/MANIFEST.MF">
		</jar>
	</target>

	<!-- unsafe for missing dependencies -->
	<target name="unsafe-package-test" description="create instrumentation package for specified test">
		<mkdir dir="${build}"/>
		<jar jarfile="${build}/disl-instr-${test.name}.jar"
365
		     basedir="${bin}"
366
		     includes="${test.path}/**"
367 368 369 370 371
		     excludes="${test.path}/TargetClass*.class ${test.path}/MANIFEST.MF"
		     manifest="${src.test}/${test.path}/MANIFEST.MF">
		</jar>
	</target>

Lukáš Marek's avatar
Lukáš Marek committed
372
</project>