turtle/build/build.xml
2012-09-15 20:26:39 +00:00

168 lines
6.5 KiB
XML

<project name="turtle" default="all">
<property environment="env"/>
<import file="${env.PONEY_HOME}/poney.xml"/>
<target name="clean" description="clean intermediate build artifacts">
<delete dir="${out.dir}"/>
</target>
<target name="configure" description="update external libraries">
<update name="boost"/>
</target>
<presetdef name="build-turtle-test">
<build-test input="test" depends="boost" mode="all" excludes="bench_*,fail_*">
<compilerarg value="-Wno-uninitialized" location="mid" if="is-cygwin"/>
<compilerarg value="/wd4505" if="is-vc80"/>
</build-test>
</presetdef>
<target name="test" description="run unit tests">
<delete dir="${tests.dir}/test/bin"/>
<build-turtle-test name="turtle"/>
<build-turtle-test name="turtle_max_args">
<defineset>
<define name="MOCK_MAX_ARGS" value="21"/>
</defineset>
</build-turtle-test>
<build-turtle-test name="turtle_use_conversions">
<defineset define="MOCK_USE_CONVERSIONS"/>
</build-turtle-test>
</target>
<target name="analyse" description="run errors analyser">
<quiet>
<mkdir dir="${reports.dir}"/>
<delete file="${reports.dir}/errors-${platform}.log"/>
<touch file="${reports.dir}/errors-${platform}.log"/>
</quiet>
<for param="file">
<fileset dir="${tests.dir}/test" includes="fail*.cpp"/>
<sequential>
<record name="${reports.dir}/errors-${platform}.log" action="start" append="true"/>
<ant target="-analyse">
<property name="file" value="@{file}"/>
</ant>
<record name="${reports.dir}/errors-${platform}.log" action="stop"/>
</sequential>
</for>
</target>
<target name="-analyse">
<trycatch>
<try>
<echo>${file}</echo>
<compile name="errors" input="${tests.dir}/errors_test" outdir="${out.dir}/errors_test" excludes="**">
<includepath path="${libraries.dir}"/>
<fileset file="${file}"/>
</compile>
</try>
</trycatch>
</target>
<target name="bench" description="run compilation benchmark">
<mkdir dir="${reports.dir}"/>
<quiet>
<delete file="${reports.dir}/benchmark-${platform}.log"/>
<touch file="${reports.dir}/benchmark-${platform}.log"/>
<delete dir="${out.dir}/bench_test"/>
<delete dir="${tests.dir}/test/bin"/>
</quiet>
<for param="file">
<fileset dir="${tests.dir}/test" includes="bench_*.cpp"/>
<sequential>
<record name="${reports.dir}/benchmark-${platform}.log" action="start" append="true"/>
<ant target="-bench">
<property name="file" value="@{file}"/>
</ant>
<record name="${reports.dir}/benchmark-${platform}.log" action="stop"/>
</sequential>
</for>
</target>
<target name="-bench">
<echo>${file}</echo>
<stopwatch name="bench"/>
<quiet>
<compile name="bench" input="${tests.dir}/test" outdir="${out.dir}/bench_test" excludes="**">
<includepath path="${libraries.dir}"/>
<fileset file="${file}"/>
</compile>
</quiet>
<stopwatch name="bench" action="total"/>
</target>
<target name="reports" description="generate code analysis reports">
<headers name="turtle" excludes="**/*_iterate.hpp,**/*_template.hpp"/>
<check name="turtle"/>
</target>
<target name="export" description="export distribution">
<sync todir="${dist.dir}/include">
<fileset dir="${libraries.dir}" includes="turtle/**"/>
</sync>
<info version="svn rev ${svn.revision}" todir="${dist.dir}"/>
</target>
<target name="package" depends="export" description="package distribution">
<mkdir dir="${dist.dir}"/>
<zip destfile="${dist.dir}/${ant.project.name}.zip">
<fileset dir="${dist.dir}" includes="include/**"/>
<fileset dir="${root.dir}" includes="*.txt"/>
</zip>
<tar destfile="${dist.dir}/${ant.project.name}.tar.bz2" compression="bzip2">
<fileset dir="${dist.dir}" includes="include/**"/>
<fileset dir="${root.dir}" includes="*.txt"/>
</tar>
</target>
<property name="boost.dir" value="${out.dir}/../boost"/>
<target name="boost" description="convert to boost">
<delete dir="${boost.dir}"/>
<copy todir="${boost.dir}/boost/mock">
<fileset dir="${libraries.dir}/turtle" includes="**"/>
</copy>
<copy todir="${boost.dir}/libs/mock">
<fileset dir="${tests.dir}" includes="test/**"/>
<fileset dir="boost" includes="test/**,doc/**,index.html"/>
</copy>
<copy todir="${boost.dir}/libs/mock/doc/html">
<fileset dir="${env.BOOST_ROOT}/doc/src" includes="**/*.css,**/**.png"/>
</copy>
<copy todir="${boost.dir}">
<fileset dir="boost" includes="LICENSE_1_0.txt,Jamroot.jam,Jamfile.v2"/>
</copy>
<replaceregexp match="MOCK" replace="BOOST_MOCK" flags="g">
<fileset dir="${boost.dir}" includes="**/*.hpp,**/*.cpp"/>
</replaceregexp>
<replaceregexp match="BOOST_MOCK_BOOST_MOCK" replace="BOOST_MOCK" flags="g">
<fileset dir="${boost.dir}" includes="**/*.hpp,**/*.cpp"/>
</replaceregexp>
<replaceregexp match='"([^"]+\.hpp)"' replace="&lt;boost/mock/\1&gt;" flags="g">
<fileset dir="${boost.dir}" includes="**/*.hpp"/>
</replaceregexp>
<replaceregexp match='"\.\./([^"]+\.hpp)"' replace="&lt;boost/mock/\1&gt;" flags="g">
<fileset dir="${boost.dir}" includes="**/*.hpp"/>
</replaceregexp>
<replaceregexp match="&lt;turtle/([^&gt;]+)" replace="&lt;boost/mock/\1" flags="g">
<fileset dir="${boost.dir}" includes="**/*.hpp,**/*.cpp"/>
</replaceregexp>
<replaceregexp match="(namespace mock)" replace="namespace boost${line.separator}{${line.separator}\1" flags="g">
<fileset dir="${boost.dir}" includes="**/*.hpp,**/*.cpp"/>
</replaceregexp>
<replaceregexp match="} // mock" replace="}${line.separator}}" flags="g">
<fileset dir="${boost.dir}" includes="**/*.hpp,**/*.cpp"/>
</replaceregexp>
<replaceregexp match="( mock::)" replace=" boost::mock::" flags="g">
<fileset dir="${boost.dir}" includes="**/*.hpp,**/*.cpp"/>
</replaceregexp>
<replaceregexp match="http://turtle.sourceforge.net" replace="Boost.Mock" flags="g">
<fileset dir="${boost.dir}" includes="**/*.hpp,**/*.cpp"/>
</replaceregexp>
</target>
<target name="all" depends="configure,test,bench,reports,export,package" description="configure, build and run tests and benchmark, export and package distribution"/>
</project>