build_dita2htmlhelp_template.xml 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. This file is part of the DITA Open Toolkit project.
  4. Copyright 2006 IBM Corporation
  5. See the accompanying LICENSE file for applicable license.
  6. -->
  7. <project xmlns:dita="http://dita-ot.sourceforge.net"
  8. xmlns:if="ant:if"
  9. xmlns:unless="ant:unless"
  10. name="dita2htmlhelp">
  11. <target name="dita2htmlhelp" unless="noMap"
  12. depends="dita2htmlhelp.init,
  13. build-init,
  14. use-init.envhhcdir,
  15. use-init.hhcdir,
  16. preprocess2,
  17. htmlhelp.topics,
  18. htmlhelp.copy-image,
  19. copy-css">
  20. <antcall target="dita.map.htmlhelp"/>
  21. </target>
  22. <target name="dita2htmlhelp.init">
  23. <property name="html-version" value="html"/>
  24. <property name="temp.output.dir.name" value="temp_chm_dir"/>
  25. <property name="preprocess.copy-image.skip" value="true"/>
  26. </target>
  27. <target name="use-init.envhhcdir" if="env.HHCDIR">
  28. <available file="${env.HHCDIR}/hhc.exe"
  29. property="HTMLHelpCompiler"
  30. value="${env.HHCDIR}${file.separator}hhc.exe"/>
  31. </target>
  32. <target name="use-init.hhcdir" unless="env.HHCDIR">
  33. <condition property="hhc.dir"
  34. value="${env.ProgramFiles(x86)}\HTML Help Workshop"
  35. else="${env.ProgramFiles}\HTML Help Workshop">
  36. <available file="${env.ProgramFiles(x86)}\HTML Help Workshop" type="dir"/>
  37. </condition>
  38. <available file="${hhc.dir}/hhc.exe"
  39. property="HTMLHelpCompiler"
  40. value="${hhc.dir}${file.separator}hhc.exe"/>
  41. </target>
  42. <target name="htmlhelp.copy-image" description="Copy image files">
  43. <copy todir="${dita.output.dir}" failonerror="false">
  44. <ditafileset format="image"/>
  45. <jobmapper type="temp"/>
  46. </copy>
  47. </target>
  48. <target name="htmlhelp.topics"
  49. depends="xhtml.init,
  50. xhtml.image-metadata">
  51. <topics.html>
  52. <dita:extension id="dita.conductor.xhtml.param" behavior="org.dita.dost.platform.InsertAction"/>
  53. <dita:extension id="dita.conductor.html.param" behavior="org.dita.dost.platform.InsertAction"/>
  54. </topics.html>
  55. </target>
  56. <target name="dita.map.htmlhelp"
  57. depends="dita.map.htmlhelp.init,
  58. dita.map.htmlhelp.hhp,
  59. dita.map.htmlhelp.hhc,
  60. dita.map.htmlhelp.hhk,
  61. dita.htmlhelp.convertlang,
  62. compile.HTML.Help"/>
  63. <target name="dita.map.htmlhelp.init" description="Init properties for HTMLHelp">
  64. <condition property="out.ext" value=".html">
  65. <not>
  66. <isset property="out.ext"/>
  67. </not>
  68. </condition>
  69. <property name="args.output.base" value="${dita.map.filename.root}"/>
  70. </target>
  71. <target name="dita.map.htmlhelp.hhp" depends="dita.map.htmlhelp.init"
  72. description="Build HTMLHelp HHP file">
  73. <local name="htmlhelp.hhp.output.dir"/>
  74. <condition property="htmlhelp.hhp.output.dir" value="${dita.output.dir}" else="${_dita.map.output.dir}">
  75. <isset property="inner.transform"/>
  76. </condition>
  77. <pipeline>
  78. <xslt destdir="${htmlhelp.hhp.output.dir}"
  79. style="${dita.plugin.org.dita.htmlhelp.dir}/xsl/map2hhp.xsl">
  80. <ditafileset input="true" processingRole="normal"/>
  81. <param name="OUTEXT" expression="${out.ext}" if:set="out.ext"/>
  82. <param name="HHCNAME" expression="${args.output.base}.hhc"/>
  83. <param name="INCLUDEFILE" expression="${args.htmlhelp.includefile}" if:set="args.htmlhelp.includefile"/>
  84. <param name="defaultLanguage" expression="${default.language}"/>
  85. <xmlcatalog refid="dita.catalog"/>
  86. <mapper type="merge" to="${args.output.base}.hhp"/>
  87. </xslt>
  88. </pipeline>
  89. </target>
  90. <target name="dita.map.htmlhelp.hhc" depends="dita.map.htmlhelp.init"
  91. description="Build HTMLHelp HHC file">
  92. <local name="htmlhelp.hhc.output.dir"/>
  93. <condition property="htmlhelp.hhc.output.dir" value="${dita.output.dir}" else="${_dita.map.output.dir}">
  94. <isset property="inner.transform"/>
  95. </condition>
  96. <pipeline>
  97. <xslt destdir="${htmlhelp.hhc.output.dir}"
  98. style="${dita.plugin.org.dita.htmlhelp.dir}/xsl/map2hhc.xsl">
  99. <ditafileset input="true" processingRole="normal"/>
  100. <param name="OUTEXT" expression="${out.ext}" if:set="out.ext"/>
  101. <param name="defaultLanguage" expression="${default.language}"/>
  102. <xmlcatalog refid="dita.catalog"/>
  103. <mapper type="merge" to="${args.output.base}.hhc"/>
  104. </xslt>
  105. </pipeline>
  106. </target>
  107. <target name="dita.map.htmlhelp.hhk" depends="dita.map.htmlhelp.init"
  108. description="Build HTMLHelp HHK file">
  109. <local name="htmlhelp.hhk.output.dir"/>
  110. <condition property="htmlhelp.hhk.output.dir" value="${dita.output.dir}" else="${_dita.map.output.dir}">
  111. <isset property="inner.transform"/>
  112. </condition>
  113. <pipeline message="Extract index term." inputmap="${user.input.file}">
  114. <module class="org.dita.dost.module.IndexTermExtractModule">
  115. <param name="output" location="${htmlhelp.hhk.output.dir}/${args.output.base}.hhk"/>
  116. <param name="targetext" value="${out.ext}"/>
  117. <param name="indextype" value="htmlhelp"/>
  118. <param name="indexclass" value="org.dita.dost.writer.CHMIndexWriter"/>
  119. <param name="encoding" value="${args.dita.locale}" if:set="args.dita.locale"/>
  120. <param name="defaultLanguage" expression="${default.language}"/>
  121. </module>
  122. </pipeline>
  123. </target>
  124. <target name="dita.htmlhelp.convertlang">
  125. <taskdef name="check-lang" classname="org.dita.dost.ant.CheckLang"/>
  126. <taskdef name="convert-lang" classname="org.dita.dost.ant.ConvertLang"/>
  127. <check-lang message="Check Language"
  128. basedir="${dita.dir}"
  129. tempdir="${dita.temp.dir}"
  130. inputmap="${user.input.file}"
  131. outputdir="${dita.output.dir}"/>
  132. <convert-lang message="Convert Language"
  133. basedir="${dita.dir}"
  134. outputdir="${dita.output.dir}"
  135. langcode="${htmlhelp.locale}"/>
  136. </target>
  137. <target name="compile.HTML.Help" if="HTMLHelpCompiler" description="Compile HTMLHelp output">
  138. <exec executable="${HTMLHelpCompiler}"
  139. failonerror="${failonerror}"
  140. failifexecutionfails="${failonerror}">
  141. <arg file="${dita.output.dir}/${args.output.base}.hhp"/>
  142. </exec>
  143. <copy todir="${output.dir}">
  144. <fileset dir="${dita.output.dir}" includes="*.chm"/>
  145. </copy>
  146. </target>
  147. </project>