build.xml 17.8 KB
Newer Older
1
<project name="disl" default="build" basedir=".">
2

3
	<property file="disl.version" />
4
	<property file="build.properties" />
5

6 7

	<path id="asm.classpath">
8
		<pathelement location="${asm.path}" />
9 10 11
	</path>

	<path id="junit.classpath">
František Haas's avatar
František Haas committed
12 13 14 15
		<pathelement location="${junit.core.path}" />
		<pathelement location="${junit.hamcrest.path}" />
	</path>

16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34

	<path id="util.classpath">
		<pathelement location="${build.util}" />
	</path>

	<path id="disl.classpath">
		<pathelement location="${build.disl}" />
	</path>

	<path id="disl.bypass.classpath">
		<pathelement location="${build.disl.bypass}/always" />
	</path>

	<path id="shvm.classpath">
		<pathelement location="${build.shvm}" />
		<pathelement location="${build.shvm.dispatch}" />
	</path>


František Haas's avatar
František Haas committed
35
	<path id="classpath">
36
		<pathelement location="${build.disl}" />
František Haas's avatar
František Haas committed
37 38 39
		<pathelement location="${asm.path}" />
		<pathelement location="${junit.core.path}" />
		<pathelement location="${junit.hamcrest.path}" />
40 41
	</path>

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

	<!-- Initialization -->

	<target name="init">
		<!--
			Define additional tasks from ant-contrib.
		-->
		<taskdef resource="${ant-contrib.resource}">
			<classpath>
				<pathelement location="${ant-contrib.path}" />
			</classpath>
		</taskdef>

		<!--
			Determine the names of native agent libraries.
			Mac OS X (Darwin) is considered a Unix family.
		-->
		<if>
			<os family="windows" />
			<then>
				<property name="dl.prefix" value="" />
				<property name="dl.suffix" value=".dll" />
			</then>
			<else><if>
				<os family="unix" />
				<then>
					<property name="dl.prefix" value="lib" />
					<if>
						<os family="mac" />
						<then>
							<property name="dl.suffix" value=".jnilib" />
						</then>
						<else>
							<property name="dl.suffix" value=".so" />
						</else>
					</if>
				</then>
				<else>
					<fail message="Unsupported operating system: ${os.name}" />
				</else>
			</if></else>
		</if>

		<property name="disl.agent.lib" value="${dl.prefix}dislagent${dl.suffix}" />
		<property name="shvm.agent.lib" value="${dl.prefix}dislreagent${dl.suffix}" />

		<!--
			Create initial build directories.
		-->
		<mkdir dir="${build}" />
		<mkdir dir="${build.disl}" />
		<mkdir dir="${dist.lib}" />
	</target>


	<!-- DiSL bypass -->

	<target name="compile-tlvi" depends="init">
		<mkdir dir="${build.disl}" />
		<javac srcdir="${src.disl}" includes="ch/usi/dag/disl/utilinstr/tlvinserter/" destdir="${build.disl}" includeAntRuntime="false">
			<classpath>
				<path refid="asm.classpath" />
			</classpath>
Lukáš Marek's avatar
Lukáš Marek committed
105
		</javac>
106 107
	</target>

108 109 110

	<target name="create-disl-thread" depends="compile-tlvi">
		<mkdir dir="${build.disl.thread}" />
111
		<java fork="true" classname="ch.usi.dag.disl.utilinstr.tlvinserter.ExtendThread">
112 113 114 115 116
			<classpath>
				<path refid="disl.classpath" />
				<path refid="asm.classpath" />
			</classpath>
			<arg value="${basedir}/${build.disl.thread}" />
117
		</java>
Lukáš Marek's avatar
Lukáš Marek committed
118 119 120
	</target>


121 122 123 124 125 126
	<target name="compile-disl-bypass" depends="create-disl-thread">
		<mkdir dir="${build.disl.bypass}" />
		
		<mkdir dir="${build.disl.bypass}/always" />
		<javac srcdir="${src.disl.bypass}" destdir="${build.disl.bypass}/always" debug="true" includeAntRuntime="false">
			<compilerarg value="-Xbootclasspath/p:${basedir}/${build.disl.thread}" />
127
		</javac>
Lukáš Marek's avatar
Lukáš Marek committed
128

129 130 131 132 133
		<mkdir dir="${build.disl.bypass}/dynamic" />
		<javac srcdir="${src.disl.bypass.dynamic}" destdir="${build.disl.bypass}/dynamic" debug="true" includeAntRuntime="false">
			<classpath>
				<path refid="disl.bypass.classpath" />
			</classpath>
134 135 136
		</javac>
	</target>

137

138
	<!-- DiSL Java agent -->
139

140 141 142 143 144 145
	<target name="compile-disl-agent-java" depends="compile-disl-bypass">
		<mkdir dir="${build.disl.agent.java}" />
		<javac srcdir="${src.disl.agent.java}" destdir="${build.disl.agent.java}" debug="true" includeAntRuntime="false">
			<classpath>
				<path refid="disl.bypass.classpath" />
			</classpath>
146 147 148
		</javac>
	</target>

149 150 151 152 153 154 155 156 157 158 159 160 161 162 163

	<target name="package-disl-agent-java" depends="compile-disl-agent-java">
		<jar destfile="${dist.lib}/disl-agent.jar">
			<fileset dir="${build.disl.agent.java}" />
			<fileset dir="${build.disl.bypass}/always" />
			<mappedresources>
				<fileset dir="${build.disl.bypass}/dynamic" />
				<globmapper from="*/DynamicBypassCheck.class" to="DynamicBypassCheck-AfterBootstrap.class" />
			</mappedresources>
			<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>
		</jar>
164 165
	</target>

166 167 168 169 170 171

	<!-- Shared utility code -->

	<target name="compile-util" depends="init">
		<mkdir dir="${build.util}" />
		<javac srcdir="${src.util}" destdir="${build.util}" debug="true" includeAntRuntime="false" />
172 173
	</target>

174 175 176 177 178 179 180 181 182 183 184

	<!-- DiSL -->

	<target name="compile-disl" depends="compile-disl-bypass,compile-util">
		<javac srcdir="${src.disl}" destdir="${build.disl}" debug="true" includeAntRuntime="false">
			<classpath>
				<!-- path refid="util.classpath" / -->
				<path refid="disl.classpath" />
				<path refid="disl.bypass.classpath" />
				<path refid="asm.classpath" />
			</classpath>
185 186 187
		</javac>
	</target>

Lukáš Marek's avatar
Lukáš Marek committed
188

189 190
	<target name="package-disl" depends="compile-disl">
		<jar destfile="${dist.lib}/disl-server.jar">
191
			<manifest>
192
				<attribute name="Class-Path" value="${asm.lib}" />
193
				<attribute name="Main-Class" value="ch.usi.dag.dislserver.DiSLServer" />
194
				<attribute name="DiSL-Version" value="${disl.version}" />
195
			</manifest>
196 197 198 199

			<!-- fileset dir="${build.util}" includes="**/*" / -->
			<fileset dir="${build.disl}" includes="**/*" excludes="**/ExtendThread.class" />
			<fileset dir="${build.disl.bypass}/always" includes="**/*" />
200 201 202
		</jar>
	</target>

203 204 205 206 207 208

	<!-- DiSL agent -->

	<target name="compile-disl-agent" depends="init">
		<exec executable="make" dir="${src.disl.agent}/javahome" />
		<exec executable="make" dir="${src.disl.agent}" />
209 210 211
	</target>


212 213 214
	<target name="copy-disl-agent" depends="compile-disl-agent">
		<copy file="${src.disl.agent}/${dl.prefix}dislagent${dl.suffix}" todir="${dist.lib}" />
	</target>
215 216


217
	<!-- Shadow VM -->
218

219 220 221 222 223 224 225
	<target name="compile-shvm" depends="init">
		<mkdir dir="${build.shvm}" />
		<javac srcdir="${src.shvm}" destdir="${build.shvm}" debug="true" includeAntRuntime="false">
			<classpath>
				<path refid="asm.classpath" />
			</classpath>
		</javac>
226 227
	</target>

228 229 230

	<target name="package-shvm" depends="compile-shvm">
		<jar basedir="${build.shvm}" destfile="${dist.lib}/dislre-server.jar" includes="ch/usi/dag/**">
231
			<manifest>
232
				<attribute name="Class-Path" value="${asm.lib}" />
233
				<attribute name="Main-Class" value="ch.usi.dag.dislreserver.DiSLREServer" />
234
				<attribute name="DiSL-Version" value="${disl.version}" />
235 236 237 238
			</manifest>
		</jar>
	</target>

239 240 241 242

	<target name="compile-shvm-dispatch" depends="init">
		<mkdir dir="${build.shvm.dispatch}" />
		<javac srcdir="${src.shvm.dispatch}" destdir="${build.shvm.dispatch}" debug="true" includeAntRuntime="false" />
243 244
	</target>

245

246 247
	<target name="package-shvm-dispatch" depends="compile-shvm-dispatch">
		<jar basedir="${build.shvm.dispatch}" destfile="${dist.lib}/dislre-dispatch.jar" includes="ch/usi/dag/**" />
248
	</target>
249 250


251
	<!-- Shadow VM agent -->
Lukáš Marek's avatar
Lukáš Marek committed
252

253 254 255
	<target name="compile-shvm-agent">
		<exec executable="make" dir="${src.shvm.agent}/javahome" />
		<exec executable="make" dir="${src.shvm.agent}" />
256 257 258
	</target>


259 260
	<target name="copy-shvm-agent" depends="compile-shvm-agent">
		<copy file="${src.shvm.agent}/${dl.prefix}dislreagent${dl.suffix}" todir="${dist.lib}" />
261
	</target>
František Haas's avatar
František Haas committed
262

263

264
	<!-- JUnit tests and DiSL/Shadow VM test suites -->
265

266 267 268 269 270 271 272 273 274 275 276
	<target name="compile-test" depends="compile-util,compile-disl,compile-shvm,compile-shvm-dispatch">
		<mkdir dir="${build.test}" />
		<javac srcdir="${src.test}" destdir="${build.test}" debug="true" includeAntRuntime="false" >
			<classpath>
				<path refid="util.classpath" />
				<path refid="disl.classpath" />
				<path refid="shvm.classpath" />
				<path refid="junit.classpath" />
				<path refid="asm.classpath" />
			</classpath>
		</javac>
František Haas's avatar
František Haas committed
277

278 279 280 281 282 283
		<!-- Copy test resource files from source to class output directory. -->
		<copy todir="${build.test}">
			<fileset dir="${src.test}">
				<include name="**/*.resource" />
			</fileset>
		</copy>
František Haas's avatar
František Haas committed
284 285 286
	</target>


287 288 289 290 291 292 293 294 295 296
	<macrodef name="package2path">
		<attribute name="package" />
		<attribute name="property" />
		<sequential>
			<pathconvert property="@{property}">
				<path path="@{package}" />
				<mapper type="unpackage" from="${basedir}/*" to="*" />
			</pathconvert>
		</sequential>
	</macrodef>
František Haas's avatar
František Haas committed
297

František Haas's avatar
František Haas committed
298

299 300 301 302 303 304 305 306
	<target name="package-test" depends="compile-test">
		<mkdir dir="${build.test.jars}" />
		<property name="suite.base.pkg" value="ch.usi.dag.disl.test.suite" />
		<package2path package="${suite.base.pkg}" property="suite.base.path" />

		<condition property="test.suites" value="${test.name}" else="*">
			<isset property="test.name" />
		</condition>
František Haas's avatar
František Haas committed
307

308
		<for param="suite.path">
František Haas's avatar
František Haas committed
309
			<path>
310 311
				<dirset dir="${src.test}/${suite.base.path}">
					<include name="${test.suites}" />
František Haas's avatar
František Haas committed
312 313 314
				</dirset>
			</path>
			<sequential>
315 316 317 318 319 320
				<local name="suite.name" />
				<basename file="@{suite.path}" property="suite.name" />
				<antcall target="package-test-suite">
					<param name="test.suite.name" value="${suite.name}" />
					<param name="test.suite.path" value="${suite.base.path}/${suite.name}" />
					<param name="test.suite.pkg" value="${suite.base.pkg}.${suite.name}" />
František Haas's avatar
František Haas committed
321 322 323 324 325
				</antcall>
			</sequential>
		</for>
	</target>

František Haas's avatar
František Haas committed
326

327 328 329 330 331 332 333 334 335 336
	<target name="package-test-suite">
		<!--
			Package target application classes.
		-->
		<jar jarfile="${build.test.jars}/${test.suite.name}-app.jar" basedir="${build.test}">
			<include name="${test.suite.path}/app/**" />
			<manifest>
				<attribute name="Main-Class" value="${test.suite.pkg}.app.TargetClass" />
			</manifest>
		</jar>
František Haas's avatar
František Haas committed
337

338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367
		<!--
			Package instrumentation classes.
		-->
		<property name="inst.jar" value="${build.test.jars}/${test.suite.name}-inst.jar" />
		<property name="inst.manifest" value="${test.suite.path}/instr/MANIFEST.MF" />

		<fileset id="inst.files" dir="${build.test}">
			<include name="${test.suite.path}/instr/**" />
			<exclude name="${inst.manifest}" />
		</fileset>

		<!--
			If the suite has a MANIFEST.MF, use it when creating the instrumentation
			jar file, otherwise generate a manifest with a default DiSL class.
		-->
		<if>
			<available file="${src.test}/${inst.manifest}" />
			<then>
				<jar jarfile="${inst.jar}" manifest="${src.test}/${inst.manifest}">
					<fileset refid="inst.files" />
				</jar>
			</then><else>
				<jar jarfile="${inst.jar}">
					<fileset refid="inst.files" />
					<manifest>
						<attribute name="DiSL-Classes" value="${test.suite.pkg}.instr.DiSLClass" />
					</manifest>
				</jar>
			</else>
		</if>
František Haas's avatar
František Haas committed
368
	</target>
František Haas's avatar
František Haas committed
369 370


371 372 373 374 375 376
	<target name="test" depends="package,package-test" description="Runs all tests or a selected (-Dtest.name=...) test suite.">
		<!--
			If test.name is set to a name of a test suite, only include the test suite
			in the batch of tests to be run, otherwise include all tests and suites.
		-->
		<if>
František Haas's avatar
František Haas committed
377
			<isset property="test.name" />
378 379 380 381 382 383 384 385 386 387 388 389 390
			<then>
				<echo>Running a single test suite: ${test.name}</echo>
				<fileset id="test.batch" dir="${src.test}">
					<include name="*ch/usi/dag/disl/test/suite/${test.name}/junit/*Test.java" />
				</fileset>
			</then><else>
				<echo>Running all tests.</echo>
				<fileset id="test.batch" dir="${src.test}">
					<include name="ch/usi/dag/disl/test/junit/*Test.java" />
					<include name="ch/usi/dag/disl/test/suite/*/junit/*Test.java" />
				</fileset>
			</else>
		</if>
František Haas's avatar
František Haas committed
391

392 393 394
		<!--
			Run the batch of junit tests and junit-wrapped test suites.
		-->
František Haas's avatar
František Haas committed
395
		<junit haltonfailure="no" haltonerror="no" failureproperty="junit.failure">
František Haas's avatar
František Haas committed
396
			<formatter type="brief" usefile="false" />
397 398 399 400 401 402 403 404 405 406

			<classpath>
				<path refid="asm.classpath" />
				<path refid="junit.classpath" />
				<pathelement location="${build.test}" />
				<pathelement location="${build.util}" />
				<pathelement location="${build.disl}" />
				<pathelement location="${build.shvm}" />
			</classpath>

407
			<!-- allow "disl.", "dislserver.", and "dislreserver." properties to be passed to tests -->
František Haas's avatar
František Haas committed
408
			<syspropertyset>
409 410 411
				<propertyref prefix="disl." />
				<propertyref prefix="dislserver." />
				<propertyref prefix="dislreserver." />
František Haas's avatar
František Haas committed
412
			</syspropertyset>
413 414 415 416 417 418
			
			<sysproperty key="disl.lib.dir" value="${dist.lib}" />
			<sysproperty key="test.lib.dir" value="${build.test.jars}" />
			<sysproperty key="disl.agent.lib" value="${disl.agent.lib}" />
			<sysproperty key="shvm.agent.lib" value="${shvm.agent.lib}" />

František Haas's avatar
František Haas committed
419
			<batchtest fork="yes">
420
				<fileset refid="test.batch" />
František Haas's avatar
František Haas committed
421 422 423
			</batchtest>
		</junit>
	</target>
424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618


	<!-- Eclipse support -->

	<target name="package-eclipse-agent" depends="init">
		<jar jarfile="${out.dir}/eclipse-agent.jar">
			<manifest>
				<attribute name="Premain-Class" value="ch.usi.dag.disl.testtools.agent.Agent" />
			</manifest>
		</jar>
	</target>


	<target name="package-eclipse-bypass" depends="compile-disl-bypass">
		<jar destfile="${out.dir}/eclipse-dynamicbypass.jar">
			<fileset dir="${build.disl.bypass}/always" />
		</jar>
	</target>


	<!-- Documentation -->

	<target name="build-doc" depends="init">
		<delete dir="${build.doc.intro}" />
		<copy todir="${build.doc.intro}">
			<fileset dir="${src.doc.intro}" />
		</copy>
		<exec executable="rubber" dir="${build.doc.intro}">
			<arg value="--pdf" />
			<arg value="dislintro.tex" />
		</exec>

		<mkdir dir="${dist.doc.intro}" />
		<copy file="${build.doc.intro}/dislintro.pdf" todir="${dist.doc.intro}" />
	</target>


	<target name="build-jdoc" depends="compile">
		<mkdir dir="${dist.doc.jdoc}" />
		<javadoc destdir="${dist.doc.jdoc}"
			access="public" author="true" version="true" use="true" 
			nodeprecated="false" nodeprecatedlist="false"
			noindex="false" splitindex="true" nonavbar="false" notree="false"
			overview="${src.doc.jdoc}/overview.html"
			source="1.7"
		>
			<sourcepath>
				<pathelement path="${src.disl}" />
			</sourcepath>

			<sourcefiles>
				<fileset dir="${src.disl}">
					<include name="**/DiSL.java" />
					<include name="**/Scope.java" />
					<include name="**/ScopeImpl.java" />
					<include name="**/Shadow.java" />
				</fileset>
				<fileset dir="${src.disl.bypass}">
					<include name="**/DynamicBypass.java" />
				</fileset>
			</sourcefiles>

			<classpath>
				<path refid="disl.bypass.classpath" />
				<path refid="asm.classpath" />
			</classpath>

			<package name="ch.usi.dag.disl.annotation" />
			<package name="ch.usi.dag.disl.marker" />
			<package name="ch.usi.dag.disl.guardcontext" />
			<package name="ch.usi.dag.disl.staticcontext" />
			<package name="ch.usi.dag.disl.dynamiccontext" />
			<package name="ch.usi.dag.disl.classcontext" />
			<package name="ch.usi.dag.disl.processorcontext" />
			<package name="ch.usi.dag.disl.transformer" />
		</javadoc>
	</target>


	<!-- Miscellaneous -->

	<target name="copy-asm">
		<copy file="${asm.path}" tofile="${dist.lib}/${asm.lib}" />
	</target>

	<target name="copy-examples">
		<copy todir="${dist.bin}">
			<fileset dir="${src.bin}" />
		</copy>
		<chmod perm="ugo+x" type="file">
			<fileset dir="${dist.bin}" />
		</chmod>

		<copy todir="${dist.examples}">
			<fileset dir="${src.examples}" />
		</copy>
	</target>

	<target name="copy-misc">
		<copy todir="${dist}" flatten="true">
			<resources>
				<file file="COPYING" />
				<file file="README" />
				<file file="USER_ERRORS" />
			</resources>
		</copy>
	</target>

	<target name="package-src">
		<zip destfile="${dist}/src.zip">
			<zipfileset dir="${src.disl}" />
			<zipfileset dir="${src.disl.bypass}" />
			<zipfileset dir="${src.shvm}" />
			<zipfileset dir="${src.shvm.dispatch}" />
			<zipfileset dir="${src.util}" />
		</zip>
	</target>


	<!-- Releases -->

	<target name="release-bin"> 
		<zip destfile="${release.bin.zip}">
			<zipfileset dir="${dist}" />
		</zip>

		<tar destfile="${release.bin.tar}" compression="bzip2">
			<zipfileset src="${release.bin.zip}" />
		</tar>
	</target>


	<target name="release-src">
		<zip destfile="${release.src.zip}">
			<zipfileset prefix="disl-${disl.version}" dir=".">
				<include name="bin/" />
				<include name="doc/" />
				<include name="examples/" />
				<include name="lib/*.jar" />
				<include name="lib/*.txt" />
				<include name="COPYING" />
				<include name="README" />
				<include name="README_TESTS" />
				<include name="USER_ERRORS" />
				<include name="build.properties" />
				<include name="build.xml" />
				<include name="disl.version" />
				<include name=".settings/" />
				<include name=".project" />
				<include name=".classpath" />
				<include name="eclipse.*" />
			</zipfileset>
			<zipfileset prefix="disl-${disl.version}" dir="." includes="src*/" excludes="**/var,**/find.sh,**/*.so,**.jnilib,**/*.o" />
			<zipfileset prefix="disl-${disl.version}" dir="." includes="src*/**/find.sh" filemode="755" />
		</zip>

		<tar destfile="${release.src.tar}" compression="bzip2">
			<zipfileset src="${release.src.zip}" />
		</tar>
	</target>


	<!-- Summary targets -->

	<target name="compile" depends="compile-disl,compile-disl-agent,compile-disl-agent-java,compile-shvm,compile-shvm-agent" description="Compiles DiSL and Shadow VM" />

	<target name="package" depends="package-disl,copy-disl-agent,package-disl-agent-java,package-shvm,copy-shvm-agent,package-shvm-dispatch,copy-asm,copy-examples" description="Packages DiSL and Shadow VM" />

	<target name="eclipse" depends="package-eclipse-agent,package-eclipse-bypass" description="Creates supporting libraries for DiSL development under Eclipse" />

	<target name="build" depends="compile,package,build-doc,build-jdoc" />

	<target name="release" depends="build,package-src,copy-misc,release-bin,release-src" />


	<!-- Clean up -->

	<target name="clean">
		<delete dir="${out.dir}" />

		<exec executable="make" dir="${src.disl.agent}/javahome">
			<arg value="clean" />
		</exec>
		<exec executable="make" dir="${src.disl.agent}">
			<arg value="clean" />
		</exec>

		<exec executable="make" dir="${src.shvm.agent}/javahome">
			<arg value="clean" />
		</exec>
		<exec executable="make" dir="${src.shvm.agent}">
			<arg value="clean" />
		</exec>
	</target>

619
</project>