build_axf.xml 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. <?xml version="1.0"?>
  2. <!--
  3. This file is part of the DITA Open Toolkit project.
  4. Copyright 2011 Jarno Elovirta
  5. See the accompanying LICENSE file for applicable license.
  6. -->
  7. <project name="org.dita.pdf2.axf">
  8. <path id="axf.class.path">
  9. <path refid="project.class.path"/>
  10. <pathelement location="${dita.plugin.org.dita.pdf2.axf.dir}/lib/axf.jar"/>
  11. </path>
  12. <target name="transform.fo2pdf.ah.test-use">
  13. <condition property="use.ah.pdf.formatter">
  14. <equals arg1="${pdf.formatter}" arg2="ah"/>
  15. </condition>
  16. </target>
  17. <target name="transform.fo2pdf.ah.init" depends="transform.fo2pdf.ah.test-use" if="use.ah.pdf.formatter">
  18. <taskdef name="log-processor" classname="org.dita.dost.pdf2.AhfLogProcessorTask"
  19. classpathref="axf.class.path"/>
  20. <condition property="temp.transformation.file" value="${dita.plugin.org.dita.pdf2.axf.dir}/xsl/fo/topic2fo_shell_axf.xsl">
  21. <and>
  22. <not><isset property="args.xsl.pdf"/></not>
  23. <isset property="use.ah.pdf.formatter"/>
  24. </and>
  25. </condition>
  26. <!-- default output format -->
  27. <condition property="axf.formatter.output-format" value="@PDF">
  28. <not><isset property="axf.formatter.output-format"/></not>
  29. </condition>
  30. <!-- output file extension -->
  31. <condition property="xsl.formatter.ext" value=".ps">
  32. <and>
  33. <equals arg1="${axf.formatter.output-format}" arg2="@PS"/>
  34. <not><isset property="xsl.formatter.ext"/></not>
  35. </and>
  36. </condition>
  37. <condition property="xsl.formatter.ext" value=".txt">
  38. <and>
  39. <equals arg1="${axf.formatter.output-format}" arg2="@TEXT"/>
  40. <not><isset property="xsl.formatter.ext"/></not>
  41. </and>
  42. </condition>
  43. <condition property="xsl.formatter.ext" value=".inx">
  44. <and>
  45. <equals arg1="${axf.formatter.output-format}" arg2="@INX"/>
  46. <not><isset property="xsl.formatter.ext"/></not>
  47. </and>
  48. </condition>
  49. <condition property="xsl.formatter.ext" value=".svg">
  50. <and>
  51. <equals arg1="${axf.formatter.output-format}" arg2="@SVG"/>
  52. <not><isset property="xsl.formatter.ext"/></not>
  53. </and>
  54. </condition>
  55. <condition property="xsl.formatter.ext" value=".mda">
  56. <and>
  57. <equals arg1="${axf.formatter.output-format}" arg2="@MODCA"/>
  58. <not><isset property="xsl.formatter.ext"/></not>
  59. </and>
  60. </condition>
  61. <condition property="xsl.formatter.ext" value=".mif">
  62. <and>
  63. <equals arg1="${axf.formatter.output-format}" arg2="@MIF"/>
  64. <not><isset property="xsl.formatter.ext"/></not>
  65. </and>
  66. </condition>
  67. <condition property="xsl.formatter.ext" value=".AT.xml">
  68. <and>
  69. <equals arg1="${axf.formatter.output-format}" arg2="@AreaTree"/>
  70. <not><isset property="xsl.formatter.ext"/></not>
  71. </and>
  72. </condition>
  73. <condition property="xsl.formatter.ext" value=".xps">
  74. <and>
  75. <equals arg1="${axf.formatter.output-format}" arg2="@XPS"/>
  76. <not><isset property="xsl.formatter.ext"/></not>
  77. </and>
  78. </condition>
  79. <condition property="xsl.formatter.ext" value=".pdf">
  80. <and>
  81. <equals arg1="${axf.formatter.output-format}" arg2="@PDF"/>
  82. <not><isset property="xsl.formatter.ext"/></not>
  83. </and>
  84. </condition>
  85. </target>
  86. <!--Set up and run Antenna House-->
  87. <target name="transform.fo2pdf.ah" if="use.ah.pdf.formatter">
  88. <condition property="axf.opt" value="${env.AXF_OPT}">
  89. <and>
  90. <not><equals arg1="${env.AXF_OPT}" arg2=""/></not>
  91. <available file="${env.AXF_OPT}"/>
  92. </and>
  93. </condition>
  94. <condition property="axf.path" value="${env.AXF_DIR}">
  95. <and>
  96. <isset property="env.AXF_DIR"/>
  97. <or>
  98. <available file="${env.AXF_DIR}/run.sh"/>
  99. <available file="${env.AXF_DIR}/XSLCmd.exe"/>
  100. <available file="${env.AXF_DIR}/AHFCmd.exe"/>
  101. </or>
  102. </and>
  103. </condition>
  104. <property name="axf.failOnError" value="true"/>
  105. <!-- run.sh on Linux, AHFCmd.exe or XSLCmd.exe on Windows -->
  106. <condition property="fo.ah.program.name" value="run.sh">
  107. <and>
  108. <not><isset property="fo.ah.program.name"/></not>
  109. <os family="unix"/>
  110. <isset property="axf.path"/>
  111. <available file="${axf.path}/run.sh"/>
  112. </and>
  113. </condition>
  114. <condition property="fo.ah.program.name" value="AHFCmd.exe">
  115. <and>
  116. <not><isset property="fo.ah.program.name"/></not>
  117. <isset property="axf.path"/>
  118. <available file="${axf.path}/AHFCmd.exe"/>
  119. </and>
  120. </condition>
  121. <condition property="fo.ah.program.name" value="XSLCmd.exe">
  122. <and>
  123. <not><isset property="fo.ah.program.name"/></not>
  124. <isset property="axf.path"/>
  125. <available file="${axf.path}/XSLCmd.exe"/>
  126. </and>
  127. </condition>
  128. <condition property="axf.cmd" value="${axf.path}/${fo.ah.program.name}">
  129. <and>
  130. <not><isset property="axf.cmd"/></not>
  131. <isset property="axf.path"/>
  132. <isset property="fo.ah.program.name"/>
  133. </and>
  134. </condition>
  135. <!-- Fall back to brute force search -->
  136. <pathconvert property="axf.cmd" setonempty="false">
  137. <first>
  138. <union>
  139. <fileset dir="/Applications" includes="AntennaHouse/run.sh" erroronmissingdir="false"/>
  140. <fileset dir="/usr" includes="AHFormatterV*/run.sh" erroronmissingdir="false"/>
  141. <fileset dir="/usr" includes="XSLFormatterV*/run.sh" erroronmissingdir="false"/>
  142. <fileset dir="C:\Program Files\Antenna House" erroronmissingdir="false">
  143. <include name="AHFormatterV*\AHFCmd.exe"/>
  144. <include name="XSLFormatterV*\XSLCmd.exe"/>
  145. </fileset>
  146. <fileset dir="C:\Program Files\AntennaHouse" erroronmissingdir="false">
  147. <include name="AHFormatterV*\AHFCmd.exe"/>
  148. <include name="XSLFormatterV*\XSLCmd.exe"/>
  149. </fileset>
  150. <fileset dir="C:\Program Files\Antenna" erroronmissingdir="false">
  151. <include name="AHFormatterV*\AHFCmd.exe"/>
  152. <include name="XSLFormatterV*\XSLCmd.exe"/>
  153. </fileset>
  154. <fileset dir="C:\Program Files (x86)\Antenna House" erroronmissingdir="false">
  155. <include name="AHFormatterV*\AHFCmd.exe"/>
  156. <include name="XSLFormatterV*\XSLCmd.exe"/>
  157. </fileset>
  158. <fileset dir="C:\Program Files (x86)\AntennaHouse" erroronmissingdir="false">
  159. <include name="AHFormatterV*\AHFCmd.exe"/>
  160. <include name="XSLFormatterV*\XSLCmd.exe"/>
  161. </fileset>
  162. <fileset dir="C:\Program Files (x86)\Antenna" erroronmissingdir="false">
  163. <include name="AHFormatterV*\AHFCmd.exe"/>
  164. <include name="XSLFormatterV*\XSLCmd.exe"/>
  165. </fileset>
  166. </union>
  167. </first>
  168. </pathconvert>
  169. <fail message="Unable to locate AXF, set property axf.path or axf.cmd">
  170. <condition>
  171. <not>
  172. <and>
  173. <isset property="axf.cmd"/>
  174. <available file="${axf.cmd}" type="file"/>
  175. </and>
  176. </not>
  177. </condition>
  178. </fail>
  179. <condition property="outputFile" value="${dita.output.dir}/${outputFile.base}${xsl.formatter.ext}">
  180. <not><isset property="outputFile"/></not>
  181. </condition>
  182. <mkdir dir="${dita.output.dir}"/>
  183. <antcall target="transform.fo2pdf.ah.nooption"/>
  184. <antcall target="transform.fo2pdf.ah.hasoption"/>
  185. </target>
  186. <target name="transform.fo2pdf.ah.nooption" unless="axf.opt">
  187. <echo level="info" taskname="ahf">Processing ${pdf2.temp.dir}/topic.fo to ${outputFile}</echo>
  188. <exec executable="${axf.cmd}" resultproperty="errCode" output="${dita.temp.dir}/pdf2.ah.log">
  189. <arg value="-d"/>
  190. <arg value="${pdf2.temp.dir}/topic.fo"/>
  191. <arg value="-o"/>
  192. <arg value="${outputFile}"/>
  193. <arg value="-p"/>
  194. <arg value="${axf.formatter.output-format}"/>
  195. <arg value="-extlevel"/>
  196. <arg value="4"/>
  197. <arg value="-peb"/>
  198. <arg value="1"/>
  199. </exec>
  200. <log-processor file="${dita.temp.dir}/pdf2.ah.log" taskname="ahf"/>
  201. <dita-ot-fail id="PDFX013F">
  202. <condition>
  203. <not>
  204. <equals arg1="${errCode}" arg2="0"/>
  205. </not>
  206. </condition>
  207. </dita-ot-fail>
  208. </target>
  209. <target name="transform.fo2pdf.ah.hasoption" if="axf.opt">
  210. <echo level="info" taskname="ahf" >Processing ${pdf2.temp.dir}/topic.fo to ${outputFile}</echo>
  211. <exec executable="${axf.cmd}" resultproperty="errCode" output="${dita.temp.dir}/pdf2.ah.log">
  212. <arg value="-d"/>
  213. <arg value="${pdf2.temp.dir}/topic.fo"/>
  214. <arg value="-o"/>
  215. <arg value="${outputFile}"/>
  216. <arg value="-p"/>
  217. <arg value="${axf.formatter.output-format}"/>
  218. <arg value="-extlevel"/>
  219. <arg value="4"/>
  220. <arg value="-peb"/>
  221. <arg value="1"/>
  222. <arg value="-i"/>
  223. <arg value="${axf.opt}"/>
  224. </exec>
  225. <log-processor file="${dita.temp.dir}/pdf2.ah.log" taskname="ahf"/>
  226. <dita-ot-fail id="PDFX013F">
  227. <condition>
  228. <not>
  229. <equals arg1="${errCode}" arg2="0"/>
  230. </not>
  231. </condition>
  232. </dita-ot-fail>
  233. </target>
  234. </project>