ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From peter reilly <peter.rei...@corvil.com>
Subject A couple of usefull tasks
Date Fri, 07 Mar 2003 17:07:33 GMT
Included is a couple of useful tasks. I am currently moving
a load of makefiles to ant and found that there were a number
of make targets like:

generated.h generated.cpp : mib.mib ../include/common.h
    mibgen -i ../include mib.mib -c generated.cpp
    mibgen -i ../include mib.mib -h generated.h

In other words multiple targets depend on multiple sources.
This is possible to do in ant with uptodate and exec or script, however
it is not nice.

The two tasks I use are outoutdate and shellscript. Shellscript is
a modification of a task submitted to ant-contrib by stephan beal (sgbeal)
patch number 547018 (modified to use a temp file and not a fixed file)
and outofdate is a modification of uptodate which allows multible targets
and contains an embedded do element.

Using these tasks the make extract above can be encoded as (assuming
defines for gen.dir, include.dir and mib.dir):

<outofdate>
    <targetfile name="${gen.dir}/generated.h"/>
    <targetfile name="${gen.dir}/generated.cpp"/>
    <srcfile name="${mib.dir}/mib.mib"/>
    <srcfile name="${include.dir}/common.h"/>
    <do>
        <shellscript shell="bash">
                mibgen -i ../include mib.mib -c generated.cpp
                mibgen -i ../include mib.mib -h generated.h
       </shellscript>
    </do>
</outofdate>

This is a bit more verbose than the make extract, but it is quite
easy to understand.

Peter
Mime
View raw message