Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add all files in a fileset as an argument to the exec task?

Tags:

ant

fileset

I'm trying to provide all *.cpp files in a folder to the c++ compiler through ant. But I get no further than ant giving gpp a giant string containing all the files. I tried to prove it by using a small test application:

int main( int argc, char**args ){
   for( --argc; argc != 0; --argc ) printf("arg[%d]: %s\n",argc,args[argc]);
}

With the ant script like this:

    <target name="cmdline">
            <fileset id="fileset" dir=".">
                    <include name="*"/>
            </fileset>
            <pathconvert refid="fileset" property="converted"/>
            <exec executable="a.exe">
                    <arg value="${converted}"/>
            </exec>
    </target>

My a.exe's output is this:

[exec] arg[1]: .a.cpp.swp .build.xml.swp a.cpp a.exe build.xml

Now here's the question: how do I provide all files in the fileset individually as an argument to the executable?

like image 928
xtofl Avatar asked Nov 13 '11 18:11

xtofl


1 Answers

This is what the apply task in ANT was designed to support.

For example:

  <target name="cmdline">
        <apply executable="a.exe" parallel="true">
            <srcfile/>               
            <fileset dir="." includes="*.cpp"/>
        </apply>
  </target>

The parallel argument runs the program once using all the files as arguments.

like image 86
Mark O'Connor Avatar answered Oct 25 '22 23:10

Mark O'Connor