Skip to content
Snippets Groups Projects
build.xml 3.57 KiB
Newer Older
  • Learn to ignore specific revisions
  • Anders Nilsson's avatar
    Anders Nilsson committed
    <!--
     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
           genClean        - removes all generated files and their class files
    -->
    <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. -->
    <property name="test" value="test"/>
    	
    <!-- "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">
    	<javac debug="true" nowarn="true" srcdir="." includes="**/*.java" excludes="test/**" classpath=".:${tools}/beaver-rt.jar:${tools}/junit.jar"
       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"/>
      <exec executable="./run" dir="test"> 
        <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"/>
        </delete>
    </target>
    
    
    <!-- remove generated source files and their .class files -->
    <target name="cleanGen">
    	 <delete dir="${package}"/>
    </target>
    
    
    <target name="jar" depends="build">
      <jar destfile="labComm.jar">
        <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>