<?xml version="1.0"?>
<!--
Customization layer for build files.

You can override these settings by defining them on the command line or by
defining them in doc.build.user which is included here if it exists.

Example content of doc.build.user:
<property name="applications" value="TortoiseGit, TortoiseMerge" />
<property name="docformats" value="html" />

This will only build the english HTML help file for TortoiseGit

-->

<project name="customize">
  <description>Customization layer for build file</description>

  <include buildfile="doc.build.user" if="${file::exists('doc.build.user')}"/>

  <!-- ============================================================ -->
  <!-- List of applications, languages and output formats in which  -->
	<!-- the documentation will be created by default                 -->

	<property name="applications"
		value="TortoiseGit,TortoiseMerge"
		unless="${property::exists('applications')}"
	/>

	<!-- pdf,html -->
	<property name="docformats"
		value="html"
		unless="${property::exists('docformats')}"
	/>

	<!-- ============================================================ -->
	<!-- Settings for the help mapping file generation                -->
	<!-- Attention, this is implemented as a target, because I could  -->
	<!-- not find a better way to create the property depending on    -->
	<!-- the app name                                                 -->

	<target name="help.prepare.TortoiseGit">
	<echo message="help.prepare.TortoiseGit"/>
		<property name="help.resource.TortoiseGit"
		  value="../src/TortoiseProc/resource.h"
			unless="${property::exists('help.resource.TortoiseGit')}"
		/>
		<property name="help.resource" value="${help.resource.TortoiseGit}" />
		<property name="help.mappingfile.TortoiseGit"
		  value="../src/Resources/TGitHelpMapping.ini"
			unless="${property::exists('help.mappingfile.TortoiseGit')}"
		/>
		<property name="help.mappingfile" value="${help.mappingfile.TortoiseGit}" />
	</target>
	<target name="help.prepare.TortoiseMerge">
	<echo message="help.prepare.TortoiseMerge"/>
		<property name="help.resource.TortoiseMerge"
	  	value="../src/TortoiseMerge/resource.h"
			unless="${property::exists('help.resource.TortoiseMerge')}"
		/>
		<property name="help.resource" value="${help.resource.TortoiseMerge}" />
		<property name="help.mappingfile.TortoiseMerge"
		  value="../src/Resources/TGitMergeHelpMapping.ini"
			unless="${property::exists('help.mappingfile.TortoiseMerge')}"
		/>
		<property name="help.mappingfile" value="${help.mappingfile.TortoiseMerge}" />
	</target>

	<!-- ============================================================ -->
	<!-- Paths to the binaries                                        -->
	<property name="path.bin"
		value="${path::get-full-path('../Tools')}"
		unless="${property::exists('path.bin')}"
	/>
	<property name="path.fop"
		value="${path::get-full-path('../Tools/fop')}"
		unless="${property::exists('path.fop')}"
	/>
	<property name="name.fop"
		value="fop.bat"
		unless="${property::exists('name.fop')}"
	/>
	<property name="path.xsl"
		value="${string::replace(path::get-full-path('../Tools/xsl'), '\', '/')}"
		unless="${property::exists('path.xsl')}"
	/>
	<property name="path.gettext"
		value="${path::get-full-path('../Tools')}"
		unless="${property::exists('path.gettext')}"
	/>
	<property name="name.python"
		value="python3"
		unless="${property::exists('name.python')}"
	/>

	<!-- ============================================================ -->
	<!-- Settings for XSLTPROC                                        -->

	<property name="external.gitdocs"
		value="0"
		unless="${property::exists('external.gitdocs')}"
	/>

	<property name="help.mapping"
		value="1"
		unless="${property::exists('help.mapping')}"
	/>

	<!-- Paths where the xsl and css files are found                  -->
	<property name="path.user.xsl" value="./xsl"/>
	<property name="path.user.css" value="./source"/>

	<!-- stylesheets and stringparams                                 -->
	<property name="xsl.pdf.params" value="--nonet --xinclude --stringparam gitdoc.external ${external.gitdocs}"/>
	<property name="xsl.pdf.file" value="pdfdoc.xsl"/>
	<property name="xsl.htmlchunk.params" value="--nonet --xinclude --stringparam chunker.output.encoding UTF-8 --stringparam html.stylesheet styles_html.css --stringparam use.id.as.filename 1 --stringparam gitdoc.external ${external.gitdocs} --stringparam generate.help.mapping ${help.mapping}"/>
	<property name="xsl.htmlchunk.file" value="htmlchunk.xsl"/>

<!-- ====================================================================== -->
<!-- Custom target to prepare the build                                     -->
<!-- ====================================================================== -->

	<target name="prepare.custom"
		description="Prepare XSL files, create help context file"
		depends="PrepareVersionInfo">

		<!-- Store path to docbook stylesheets in helper stylesheets -->
		<echo message="&lt;xsl:stylesheet xmlns:xsl=&quot;http://www.w3.org/1999/XSL/Transform&quot; version=&quot;1.0&quot;&gt;" file="${path.user.xsl}/db_pdfdoc.xsl"/>
		<echo message="&lt;xsl:import href=&quot;${path.xsl}/fo/docbook.xsl&quot;/&gt;" file="${path.user.xsl}/db_pdfdoc.xsl" append="true"/>
		<echo message="&lt;/xsl:stylesheet&gt;" file="${path.user.xsl}/db_pdfdoc.xsl" append="true"/>

		<echo message="&lt;xsl:stylesheet xmlns:xsl=&quot;http://www.w3.org/1999/XSL/Transform&quot; version=&quot;1.0&quot;&gt;" file="${path.user.xsl}/db_htmlchunk.xsl"/>
		<echo message="&lt;xsl:import href=&quot;${path.xsl}/html/chunk.xsl&quot;/&gt;" file="${path.user.xsl}/db_htmlchunk.xsl" append="true"/>
		<echo message="&lt;/xsl:stylesheet&gt;" file="${path.user.xsl}/db_htmlchunk.xsl" append="true"/>

	</target>

<!-- ====================================================================== -->
<!-- Prepare version info for version file and output filenames             -->
<!-- ====================================================================== -->

	<target name="PrepareVersionInfo" description="Prepares version info for version file and output filenames">

		<if test="${not environment::variable-exists('MajorVersion')}">
			<setenv>
				<variable name="MajorVersion" value="2" />
				<variable name="MinorVersion" value="17" />
				<variable name="MicroVersion" value="0" />
			</setenv>
		</if>

		<property name="docverstring" value="${environment::get-variable('MajorVersion')}.${environment::get-variable('MinorVersion')}.${environment::get-variable('MicroVersion')}"/>

	</target>

</project>
