ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Doug Morse <mo...@pobox.com>
Subject [apply] and m4
Date Mon, 25 Jun 2001 16:22:34 GMT
Hi,

I am trying to use Ant to execute all m4 scripts in a directory to automated
the creation of SQL scripts (triggers).  The m4 scripts work just fine.
However, for some *unfathomable* reason, GNU m4 does *not* have any way
*whatsoever* (i.e., no syntax for it, no command line options for it) to
write its output anywhere other than standard output (stdout).  Ugh.  So,
the following does not work:

  <target name="create_triggers">
    <apply executable="m4" dir="../triggers" dest="../triggers"
      failonerror="true">
      <fileset dir="../triggers" includes="*.m4"/>
      <mapper type="glob" from="*.m4" to="*.sql"/>
    </apply>
  </target>

because the output gets written to stdout.  I've tried the following as well:

  <target name="create_triggers">
    <apply executable="m4" dir="../triggers" dest="../triggers"
      failonerror="true">
      <srcfile/>
      <arg line=" > "/>
      <targetfile/>
      <fileset dir="../triggers" includes="*.m4"/>
      <mapper type="glob" from="*.m4" to="*.sql"/>
    </apply>
  </target>

in an attempt to get Ant to redirect the output to the targetfile, but this
doesn't work either in that the ">" character just gets treated as a
filename by m4, as does the targetfile:

    [apply] /usr/bin/m4: >: No such file or directory
    [apply] /usr/bin/m4: Users_A_Audit_U01.sql: No such file or directory

Ant is probably ensuring that the commands it executes do not use
redirection (as it should, IMHO). However, this has me in bit of a quandary.
I could use the "output" parameter of the "apply" command, but this would
then mean I would need a separate "apply" for each file I want to process
(which pretty much defeats the purpose of using "apply").

What alternatives do I have?  I am going to perhaps have to write a Task
subclass to get the behavior I need?  Is there some other, easier way to
deal with this issue?

Any and all help greatly appreciated!  My apologies in advance for troubling
you all with this, in that I realize that the problem is really with m4's
idiotic insistence on writing to stdout rather than anything wrong with Ant.

Thanks!
Doug Morse
morse@pobox.com

Mime
View raw message