Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
158 lines (148 sloc) 5.59 KB
<project name="openark kit" default="dist" basedir=".">
<taskdef resource="net/sf/antcontrib/antcontrib.properties">
<classpath>
<pathelement location="/usr/share/java/ant-contrib.jar"/>
</classpath>
</taskdef>
<property name="python.distribution.dir" value="py-dist"/>
<property name="debian.distribution.dir" value="deb-dist"/>
<property name="rpm.distribution.dir" value="rpm-dist"/>
<property name="doc.templates.dir" value="doc/templates"/>
<property name="doc.html.dir" value="doc/html"/>
<target name="clean">
<delete dir="build"/>
<delete dir="dist"/>
<delete dir="${python.distribution.dir}"/>
<delete dir="${debian.distribution.dir}"/>
<delete dir="${rpm.distribution.dir}"/>
</target>
<target name="revnumber" description="Get the SVN greatest revision number">
<mkdir dir="ant-tmp"/>
<exec dir="." executable="svn" output="ant-tmp/svn_output" failifexecutionfails="false" description="Get SVN info for all files recursively">
<arg value="info"/>
<arg value="--recursive"/>
</exec>
<exec dir="." executable="awk" input="ant-tmp/svn_output" outputproperty="svn.revision" failifexecutionfails="false" description="Extract highest revision number">
<arg value="BEGIN {max=0} /Revision:/ {if ($2 > max) max=$2} END {print max}"/>
</exec>
<condition property="svn.revision" value="0">
<not>
<isset property="svn.revision"/>
</not>
</condition>
<delete dir="ant-tmp"/>
<tstamp description="To be used as build number"/>
<echo>revision: ${svn.revision}</echo>
</target>
<target name="scripts" depends="revnumber">
<mkdir dir="build/scripts"/>
<copy todir="build/scripts">
<fileset dir="src/oak">
<exclude name="**/__init__.py"/>
</fileset>
<globmapper from="*.py" to="*"/>
</copy>
</target>
<target name="python-module" depends="scripts">
<mkdir dir="${python.distribution.dir}"/>
<copy file="py-dist-cfg/setup.py" todir="build"/>
<replace file="build/setup.py" token="revision.placeholder" value="${svn.revision}"/>
<copy file="py-dist-cfg/MANIFEST.in" todir="build"/>
<copy todir="build/">
<fileset dir="doc"/>
</copy>
<exec dir="build" executable="python">
<arg value="setup.py"/>
<arg value="sdist"/>
</exec>
<move todir="${python.distribution.dir}">
<fileset dir="build/dist"/>
</move>
</target>
<target name="deb" depends="scripts">
<mkdir dir="${debian.distribution.dir}/openark-kit/usr/bin"/>
<mkdir dir="${debian.distribution.dir}/openark-kit/DEBIAN"/>
<copy todir="${debian.distribution.dir}/openark-kit/DEBIAN">
<fileset dir="deb-dist-cfg/control"/>
</copy>
<replace file="${debian.distribution.dir}/openark-kit/DEBIAN/control" token="revision.placeholder" value="${svn.revision}"/>
<copy todir="${debian.distribution.dir}/openark-kit/usr/bin">
<fileset dir="build/scripts"/>
</copy>
<chmod perm="755">
<fileset dir="${debian.distribution.dir}/openark-kit/usr/bin"/>
</chmod>
<exec dir="${debian.distribution.dir}" executable="dpkg-deb">
<arg value="--build"/>
<arg value="openark-kit"/>
<arg value="openark-kit-${svn.revision}-1.deb"/>
</exec>
</target>
<target name="rpm" depends="revnumber, scripts">
<mkdir dir="${rpm.distribution.dir}"/>
<copy file="py-dist-cfg/setup.py" todir="build"/>
<replace file="build/setup.py" token="revision.placeholder" value="${svn.revision}"/>
<copy file="py-dist-cfg/MANIFEST.in" todir="build"/>
<copy todir="build/">
<fileset dir="doc"/>
</copy>
<exec dir="build" executable="python">
<arg value="setup.py"/>
<arg value="bdist_rpm"/>
</exec>
<move todir="${rpm.distribution.dir}">
<fileset dir="build/dist"/>
</move>
</target>
<target name="dist" depends="clean, deb, rpm, python-module">
<mkdir dir="dist"/>
<copy todir="dist">
<fileset dir="py-dist"/>
</copy>
<copy todir="dist">
<fileset dir="${debian.distribution.dir}">
<include name="*.deb"/>
</fileset>
<fileset dir="${rpm.distribution.dir}">
<include name="*.rpm"/>
</fileset>
</copy>
<echo>dist: rev ${svn.revision}</echo>
</target>
<target name="doc">
<foreach param="tooldoc_filename" target="tooldoc">
<path>
<fileset dir="${doc.templates.dir}/tools">
<include name="*.html"/>
</fileset>
</path>
</foreach>
<foreach param="generaldoc_filename" target="generaldoc">
<path>
<fileset dir="${doc.templates.dir}/general">
<include name="*.html"/>
</fileset>
</path>
</foreach>
</target>
<target name="tooldoc">
<basename property="doc_basename" file="${tooldoc_filename}"/>
<basename property="toolname" file="${tooldoc_filename}" suffix=".html"/>
<echo message="Generating documentation for ${toolname} tool" />
<concat destfile="${doc.html.dir}/${doc_basename}">
<filelist dir="${doc.templates.dir}" files="head.html.template, ${tooldoc_filename}, tail.html.template"/>
</concat>
<replace file="${doc.html.dir}/${doc_basename}" token="pagetitle" value="${toolname}"/>
<replace file="${doc.html.dir}/${doc_basename}" token="pagename" value="${toolname}"/>
</target>
<target name="generaldoc">
<basename property="doc_basename" file="${generaldoc_filename}"/>
<basename property="docname" file="${generaldoc_filename}" suffix=".html"/>
<echo message="Generating documentation for ${docname} file" />
<concat destfile="${doc.html.dir}/${doc_basename}">
<filelist dir="${doc.templates.dir}" files="head.html.template, ${generaldoc_filename}, tail.html.template"/>
</concat>
<replace file="${doc.html.dir}/${doc_basename}" token="pagetitle" value="${docname}"/>
<replace file="${doc.html.dir}/${doc_basename}" token="pagename" value="${docname}"/>
</target>
</project>