build_axf.xml 8.6 KB

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