compiler-design-eth/build.xml
Carlos Galindo bf60a078d7
Homework 2
2020-01-15 22:30:09 +01:00

111 lines
4.6 KiB
XML

<project name="compiler-design" default="generate-parser" basedir="." xmlns:jacoco="antlib:org.jacoco.ant">
<!-- A very simple ant file that primarily exists to run cup and lex;
it also includes targets to build the compiler and run tests for those
who would rather not use Eclipse -->
<!-- Set project properties. -->
<property name="src.dir" value="${basedir}/src"/>
<property name="test.dir" value="${basedir}/test"/>
<property name="javali_tests.dir" value="${basedir}/javali_tests"/>
<property name="parser.dir" value="${src.dir}/cd/frontend/parser"/>
<property name="parser.jar" value="${basedir}/lib/javaliParserObf.jar"/>
<property name="build.dir" value="${basedir}/bin"/>
<property name="junit.jar" value="${basedir}/lib/junit-4.12.jar"/>
<property name="hamcrest.jar" value="${basedir}/lib/hamcrest-core-1.3.jar"/>
<property name="antlr.jar" value="${basedir}/lib/antlr-4.7.1-complete.jar"/>
<property name="antlr.profile" value="false"/>
<property name="antlr.report" value="false"/>
<property name="jacocoant.jar" value="${basedir}/lib/jacocoant.jar"/>
<property name="coverage.file" location="${build.dir}/jacoco.exec"/>
<property name="min.coverage" value="0.5"/>
<property name="coverage.check" value="cd.frontend.*:cd.backend.*"/>
<target name="generate-parser">
<echo message="ANTLR4 ${parser.dir}/Javali.g4" level="info"/>
<echo>${basedir}</echo>
<java classname="org.antlr.v4.Tool" failonerror="true" classpath="${antlr.jar}">
<arg value="${parser.dir}/Javali.g4" />
<arg value="-o" />
<arg value="${parser.dir}" />
<arg value="-no-listener" />
<arg value="-visitor" />
</java>
</target>
<!-- Deletes the generated ANTLR parser files. Don't use in HW1! -->
<target name="clean-parser">
<delete file="${parser.dir}/Javali.tokens"/>
<delete file="${parser.dir}/JavaliLexer.java"/>
<delete file="${parser.dir}/JavaliParser.java"/>
<delete file="${parser.dir}/JavaliWalker.tokens"/>
<delete file="${parser.dir}/JavaliWalker.java"/>
<delete file="${parser.dir}/JavaliBaseListener.java"/>
<delete file="${parser.dir}/JavaliBaseVisitor.java"/>
<delete file="${parser.dir}/JavaliListener.java"/>
<delete file="${parser.dir}/JavaliVisitor.java"/>
<delete file="${parser.dir}/JavaliLexer.tokens"/>
<delete file="${parser.dir}/Javali.interp"/>
<delete file="${parser.dir}/JavaliLexer.interp"/>
</target>
<!-- Cleans generated code, but NOT the parser source! -->
<target name="clean">
<delete dir="${build.dir}"/>
</target>
<!-- Builds the compiler framework for HW > HW1. -->
<target name="compile" depends="generate-parser">
<mkdir dir="${build.dir}"/>
<javac debug="true" destdir="${build.dir}" includeantruntime="false">
<src path="${src.dir}"/>
<src path="${test.dir}"/>
<classpath>
<pathelement location="${antlr.jar}"/>
<pathelement location="${junit.jar}"/>
<pathelement location="${hamcrest.jar}"/>
</classpath>
</javac>
</target>
<!-- Deletes all byproducts of running the tests -->
<target name="clean-test">
<delete>
<fileset dir="${javali_tests.dir}" includes="**/*.err"/>
<fileset dir="${javali_tests.dir}" includes="**/*.s"/>
<fileset dir="${javali_tests.dir}" includes="**/*.bin"/>
<fileset dir="${javali_tests.dir}" includes="**/*.dot"/>
<fileset dir="${javali_tests.dir}" includes="**/*.exe"/>
<fileset dir="${javali_tests.dir}" includes="**/*.ref"/>
</delete>
</target>
<taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
<classpath path="${jacocoant.jar}"/>
</taskdef>
<!-- Runs the tests. Use the compile target first! -->
<target name="test" depends="compile">
<jacoco:coverage destfile="${coverage.file}">
<junit fork="true" forkmode="once" failureproperty="tests-failed" outputtoformatters="false">
<formatter type="brief" usefile="false"/>
<batchtest skipNonTests="true">
<fileset dir="bin" includes="**/*.class" />
</batchtest>
<assertions enablesystemassertions="true" />
<sysproperty key="cd.meta_hidden.Version" value="REFERENCE" />
<classpath>
<pathelement location="${build.dir}"/>
<pathelement location="${junit.jar}"/>
<pathelement location="${hamcrest.jar}"/>
<pathelement location="${antlr.jar}"/>
<pathelement location="${parser.jar}"/>
</classpath>
</junit>
</jacoco:coverage>
<fail if="tests-failed" />
</target>
</project>