You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

apply.html 4.9 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Language" content="en-us">
  4. <title>Ant User Manual</title>
  5. </head>
  6. <body>
  7. <h2><a name="apply">Apply</a></h2>
  8. <h3>Description</h3>
  9. <p>Executes a system command. When the <i>os</i> attribute is specified, then
  10. the command is only executed when Ant is run on one of the specified operating
  11. systems.</p>
  12. <p>The files and/or directories of a number of <a
  13. href="../CoreTypes/fileset.html">FileSet</a>s are passed as arguments to the system
  14. command. The timestamp of each source file is compared to the
  15. timestamp of a target file which is defined by a nested <a
  16. href="../CoreTypes/mapper.html">mapper</a> element. At least one fileset and exactly
  17. one mapper element are required.</p>
  18. <h3>Parameters</h3>
  19. <table border="1" cellpadding="2" cellspacing="0">
  20. <tr>
  21. <td valign="top"><b>Attribute</b></td>
  22. <td valign="top"><b>Description</b></td>
  23. <td align="center" valign="top"><b>Required</b></td>
  24. </tr>
  25. <tr>
  26. <td valign="top">executable</td>
  27. <td valign="top">the command to execute without any command line
  28. arguments.</td>
  29. <td align="center" valign="top">Yes</td>
  30. </tr>
  31. <tr>
  32. <td valign="top">dest</td>
  33. <td valign="top">the directory where the target files will be placed.</td>
  34. <td align="center" valign="top">Yes</td>
  35. </tr>
  36. <tr>
  37. <td valign="top">dir</td>
  38. <td valign="top">the directory in which the command should be executed.</td>
  39. <td align="center" valign="top">No</td>
  40. </tr>
  41. <tr>
  42. <td valign="top">os</td>
  43. <td valign="top">list of Operating Systems on which the command may be
  44. executed.</td>
  45. <td align="center" valign="top">No</td>
  46. </tr>
  47. <tr>
  48. <td valign="top">output</td>
  49. <td valign="top">the file to which the output of the command should be
  50. redirected.</td>
  51. <td align="center" valign="top">No</td>
  52. </tr>
  53. <tr>
  54. <td valign="top">timeout</td>
  55. <td valign="top">Stop the command if it doesn't finish within the
  56. specified time (given in milliseconds).</td>
  57. <td align="center" valign="top">No</td>
  58. </tr>
  59. <tr>
  60. <td valign="top">failonerror</td>
  61. <td valign="top">Stop the buildprocess if the command exits with a
  62. returncode other than 0.</td>
  63. <td align="center" valign="top">No</td>
  64. </tr>
  65. <tr>
  66. <td valign="top">parallel</td>
  67. <td valign="top">Run the command only once, appending all files as
  68. arguments. If false, command will be executed once for every file.
  69. Defaults to false. </td>
  70. <td align="center" valign="top">No</td>
  71. </tr>
  72. <tr>
  73. <td valign="top">type</td>
  74. <td valign="top">One of <i>file</i>, <i>dir</i> or
  75. <i>both</i>. If set to <i>file</i>, only the names of plain
  76. files will be sent to the command. If set to <i>dir</i>, only
  77. the names of directories are considered.</td>
  78. <td align="center" valign="top">No, default is <i>file</i></td>
  79. </tr>
  80. </table>
  81. <h3>Parameters specified as nested elements</h3>
  82. <h4>fileset</h4>
  83. <p>You can use any number of nested <code>&lt;fileset&gt;</code>
  84. elements to define the files for this task and refer to
  85. <code>&lt;fileset&gt;</code>s defined elsewhere.</p>
  86. <h4>arg</h4>
  87. <p>Command line arguments should be specified as nested
  88. <code>&lt;arg&gt;</code> elements. See <a
  89. href="../using.html#arg">Command line arguments</a>.</p>
  90. <h4>srcfile</h4>
  91. <p>By default the file names of the source files will be added to the
  92. end of the command line. If you need to place it somewhere different,
  93. use a nested <code>&lt;srcfile&gt;</code> element between your
  94. <code>&lt;arg&gt;</code> elements to mark the insertion point.</p>
  95. <h4>targetfile</h4>
  96. <p><code>&lt;targetfile&gt;</code> is similar to
  97. <code>&lt;srcfile&gt;</code> and marks the position of the target
  98. filename on the command line. If omitted, the target filenames will
  99. not be added to the command line at all.</p>
  100. <h4>env</h4>
  101. <p>It is possible to specify environment variables to pass to the
  102. system command via nested <code>&lt;env&gt;</code> elements. See the
  103. description in the section about <a href="exec.html#env">exec</a></p>
  104. <p>Please note that the environment of the current Ant process is
  105. <b>not</b> passed to the system command if you specify variables using
  106. <code>&lt;env&gt;</code>.</p>
  107. <h3>Examples</h3>
  108. <blockquote><pre>
  109. &lt;apply executable=&quot;cc&quot; dest=&quot;src/C&quot; parallel=&quot;false&quot;&gt;
  110. &lt;arg value=&quot;-c&quot;/&gt;
  111. &lt;arg value=&quot;-o&quot;/&gt;
  112. &lt;targetfile/&gt;
  113. &lt;srcfile/&gt;
  114. &lt;fileset dir=&quot;src/C&quot; includes=&quot;*.c&quot;/&gt;
  115. &lt;mapper type=&quot;glob&quot; from=&quot;*.c&quot; to=&quot;*.o&quot;/&gt;
  116. &lt;/apply&gt;
  117. </pre></blockquote>
  118. <p>invokes <code>cc -c -o TARGETFILE SOURCEFILE</code> for each
  119. <code>.c</code> file that is newer than the corresponding
  120. <code>.o</code>, replacing TARGETFILE with the absolute filename of
  121. the <code>.o</code> and SOURCEFILE with the absolute name of the
  122. <code>.c</code> file.</p>
  123. <hr><p align="center">Copyright &copy; 2000,2001 Apache Software Foundation. All rights
  124. Reserved.</p>
  125. </body>
  126. </html>