build.xml 3.65 KB
Newer Older
Anders Nilsson's avatar
Anders Nilsson committed
1 2 3 4 5 6
<!--
 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
Oscar Olsson's avatar
Oscar Olsson committed
7
       cleanGen        - removes all generated files and their class files
Anders Nilsson's avatar
Anders Nilsson committed
8 9 10 11 12 13 14 15 16 17
-->
<project name="LabComm" default="build" basedir=".">

<!-- "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="tools"/>
	
<!-- "test" is the directory where tests are located. -->
18
<property name="test" value="../test"/>
Anders Nilsson's avatar
Anders Nilsson committed
19 20 21 22 23 24 25 26 27 28 29 30
	
<!-- "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">
31
	<javac debug="true" nowarn="true" srcdir="." includes="**/*.java" excludes="test/** examples/**" classpath=".:${tools}/beaver-rt.jar:${tools}/junit.jar"
Anders Nilsson's avatar
Anders Nilsson committed
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
   fork="true" memoryMaximumSize="128M"/>
</target>
	

<!-- generate compiler source files -->
<target name="gen">
	<!-- create AST node types and weave aspect modules -->
		<echo message = "Running JastAdd"/>
		<jastadd package="${package}" rewrite="true" beaver="true" novisitcheck="true" lazyMaps="true" outdir="${basedir}">
			<fileset dir=".">
				<include name="**/*.ast"/>
				<include name="**/*.jrag"/>
				<include name="**/*.jadd"/>
			</fileset>
		</jastadd>
	<!-- generate the scanner -->
		<echo message = "Running jflex"/>
		<jflex file="LabCommScanner.flex" outdir="AST" nobak="yes"/>
	<!-- generate the parser phase 1, create a full .lalr specification from fragments-->
		<echo message = "Running parser phase 1"/>
		<concat destfile="AST/LabCommParser.all" binary="true">
	    <fileset dir=".">
	      <include name="*.parser"/>
	    </fileset>
	</concat>
	<!-- generate the parser phase 2, translating .lalr to .beaver -->
		<java fork="true" dir="${basedir}" classpath="${tools}/proj.jar:${tools}/beaver-rt.jar" classname="Main">
			<arg line="AST/LabCommParser.all AST/LabCommParser.beaver"/>
		</java>
	<!-- generate the parser phase 3, translating .beaver to .java -->
	<beaver file="AST/LabCommParser.beaver" terminalNames="yes" compress="yes" useSwitch="yes"/>
</target>


<!-- compile sources -->
<target name="test" depends="jar">
  <echo message = "Running tests"/>
69
  <exec executable="./run" dir="../test"> 
Anders Nilsson's avatar
Anders Nilsson committed
70 71 72 73 74 75 76 77 78 79
    <env key="PYTHONPATH" value="../lib/python"/>
    <!--arg value="hej"/-->
  </exec>
</target>
	
<!-- remove generated source files and .class files -->
<target name="clean" depends="cleanGen">
     <!-- delete all .class files recursively -->
    <delete>
      <fileset dir="." includes="**/*.class"/>
80
      <fileset dir="." includes="labcomm_compiler.jar"/>
Anders Nilsson's avatar
Anders Nilsson committed
81
    </delete>
Oscar Olsson's avatar
Oscar Olsson committed
82

Anders Nilsson's avatar
Anders Nilsson committed
83 84 85 86 87 88 89 90 91 92
</target>


<!-- remove generated source files and their .class files -->
<target name="cleanGen">
	 <delete dir="${package}"/>
</target>


<target name="jar" depends="build">
93
  <jar destfile="labcomm_compiler.jar">
Anders Nilsson's avatar
Anders Nilsson committed
94 95 96 97 98 99 100 101 102 103 104 105 106
    <fileset dir="." includes="LabComm*.class"/>
    <fileset dir="." includes="AST/*.class"/>
    <zipfileset src="tools/beaver-rt.jar" includes="beaver/*.class"/>
    <manifest>
      <attribute name="Main-Class" value="LabComm"/>
    </manifest>
  </jar>
</target>
		  

</project>