ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ralf Hauser" <ralfhau...@gmx.ch>
Subject RE: ant problem under cygwin and questions from a wanna-be Makefile convert
Date Thu, 17 Oct 2002 13:45:01 GMT


> -----Original Message-----
> From: Diane Holt [mailto:holtdl@yahoo.com]
> Sent: Donnerstag, 17. Oktober 2002 07:13
> To: Ant Users List; hauser@acm.org
> Subject: RE: ant problem under cygwin and questions from a wanna-be
> Makefile convert
>
> > > i) if there is a *.??.m4 file, run m4 on that file and create the
> > > corresponding *.??.html output file unless it exists already
> Yeah, didn't know 'm4' didn't let you specify an output file -- guess it
> expects you to be piping the output somewhere.
Yes, it unfortunately expects piping, I reported this in
http://www.seindal.dk/forum/read.php?f=2&i=76&t=76
> Anyway, to avoid the batch
> script, you could use the ant-contrib <foreach> and <if> tasks instead --
> for example:
>   <taskdef resource="net/sf/antcontrib/antcontrib.properties"/>
>
>   <target name="doM4">
>     <foreach target="runm4" param="m4.in">
>       <fileset dir="${basedir}" includes="m4files/*.??.m4"/>
>     </foreach>
>   </target>
>
>   <target name="runm4">
>     <basename property="base.m4.in" file="${m4.in}" suffix=".m4"/>
>     <dirname property="m4.dir" file="${m4.in}"/>
>     <property name="m4.out" location="${m4.dir}/${base.m4.in}.html"/>
>     <uptodate property="html.isUpToDate"
>        targetfile="${m4.out}" srcfile="${m4.in}"/>
>     <if>
>       <isset property="html.isUpToDate"/>
>     <then>
>       <echo>${m4.out} is up-to-date.</echo>
>     </then>
>     <else>
>       <echo>Processing ${base.m4.in}.m4 ...</echo>
        <exec executable="m4" output="${m4.out}">
>         <arg value="-P"/>
          <arg value="${base.m4.in}.m4"/>
>       </exec>
>     </else>
>     </if>
>   </target>
>
> Note: You will need to be running 1.5.1 to get the bug-fixed <basename>.

Diane, thanks for not giving up - it works!.

1) I added the missing quote around "output"
2) I upgraded ant to 1.5.1
3) got it from http://gump.covalent.net/jars/latest/ant-contrib/
4) added <arg value="${base.m4.in}.m4"/>

With that approach, I also got rid of the delete batch file (just one line)
that drops the apply srcfile argument: however, there must be a more
efficient solution!   ;)

  <target name="depPageFile" description="if the {page file}.m4 is newer,
                                remove its *.??.html descendants" >
    <foreach target="runDelete" param="outFileName.arg">
      <fileset dir="." includes="*.??.html"/>
    </foreach>
  </target>

  <target name="runDelete">
    <basename property="base.del.in0" file="${outFileName.arg}"
          suffix=".en.html"/>
    <basename property="fileName.del.in" file="${outFileName.arg}"/>
    <if>
        <!-- add one of these if statements for each language supported
             in a nested way-->
        <equals arg1="${base.del.in0}" arg2="${fileName.del.in}"/>
      <then>
        <basename property="base.del.in1" file="${outFileName.arg}"
            suffix=".de.html"/>
        <if>
             <equals arg1="${base.del.in1}" arg2="${fileName.del.in}"/>
          <then>
             <basename property="base.del.in2" file="${outFileName.arg}"
              suffix=".fr.html"/>
             <!-- add if statement for fr -->
          </then>
          <else>
             <property name="base.del.in" value="${base.del.in1}"/>
          </else>
        </if>
      </then>
      <else>
        <property name="base.del.in" value="${base.del.in0}"/>
      </else>
    </if>
    <uptodate property="html.isUpToDate"
       targetfile="${outFileName.arg}"
       srcfile="${base.del.in}.m4"/>
    <if>
        <isset property="html.isUpToDate"/>
      <then>
        <!--echo>${outFileName.arg} is up-to-date wrt.
                             ${base.del.in}.m4.</echo-->
      </then>
      <else>
        <delete file="${outFileName.arg}" verbose="true"/>
      </else>
    </if>
  </target>

it would be great if a list of {en, de, fr, ..} could be defined and then
some way to iterate through it.

Rgds Ralf


--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>


Mime
View raw message