如何将文件集中的所有文件作为参数添加到exec任务中?

xto*_*ofl 12 ant fileset

我试图通过ant将文件夹中的所有*.cpp文件提供给c ++编译器.但我得到的不仅仅是给gpp一个包含所有文件的巨大字符串.我试图通过使用一个小测试应用程序来证明它:

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

使用这样的ant脚本:

    <target name="cmdline">
            <fileset id="fileset" dir=".">
                    <include name="*"/>
            </fileset>
            <pathconvert refid="fileset" property="converted"/>
            <exec executable="a.exe">
                    <arg value="${converted}"/>
            </exec>
    </target>
Run Code Online (Sandbox Code Playgroud)

我的a.exe的输出是这样的:

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

现在问题是:如何将文件集中的所有文件作为可执行文件的参数单独提供?

Mar*_*nor 14

这就是ANT中的应用任务旨在支持的内容.

例如:

  <target name="cmdline">
        <apply executable="a.exe" parallel="true">
            <srcfile/>               
            <fileset dir="." includes="*.cpp"/>
        </apply>
  </target>
Run Code Online (Sandbox Code Playgroud)

并行参数运行一次使用的所有文件作为参数的程序.


xto*_*ofl 5

找到它:区别似乎在于arg valuearg line.

<arg line="${converted}"/>
Run Code Online (Sandbox Code Playgroud)

产生了预期的产量:

 [exec] arg[5]: C:\cygwin\home\xtofl_2\antes\build.xml
 [exec] arg[4]: C:\cygwin\home\xtofl_2\antes\a.exe
 [exec] arg[3]: C:\cygwin\home\xtofl_2\antes\a.cpp
 [exec] arg[2]: C:\cygwin\home\xtofl_2\antes\.build.xml.swp
 [exec] arg[1]: C:\cygwin\home\xtofl_2\antes\.a.cpp.swp
Run Code Online (Sandbox Code Playgroud)