<?xml version="1.0"?>

<!--
     Use this file to set the paths to the required tools
     TortoiseSVN needs to build everything.

     First make a copy of this file and rename the copy to
     default.build.user then check the TODO comments and
     adjust the paths in the "value" field if necessary.

     Note: if you followed the instructions in build.txt,
     the build script should automatically use the correct
     paths.
-->

<project name="ToolPaths" default="env">

  <!-- ====================================================================== -->
  <!-- These two targets have to exist in doc.build.user                      -->
  <!-- ====================================================================== -->

  <target name="VSNET" description="Checks if the env variables for VS2022 are set">
    <if test="${not environment::variable-exists('VCINSTALLDIR')}">
      <fail>You must first call "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars32.bat"</fail>
    </if>

    <!-- Uncomment and modify the path of the statement below if you're building
         a version of TSVN which uses a different working copy format than
         the working copy you have checked out. -->
    <!-- <property name="SubWCRevFileName" value="C:\Program Files\TortoiseSVN\bin\SubWCRev.exe"/> -->

  </target>

  <target name="env" depends="VSNET">
    <!--
      WiX3 installer already sets an environment variable to
      its target folder. We need to move it to the \bin folder
      conditionally as "manual" installations might not have
      that sub-folder.
    -->

    <if test="${not environment::variable-exists('WIX')}">
      <setenv>
        <!-- TODO: change path value, if WIX is not defined -->
        <variable name="WIX" value="C:\Program Files (x86)\WiX Toolset v3.14" />
      </setenv>
    </if>
    <if test="${file::exists(environment::get-variable('WIX') + '\bin\candle.exe')}">
      <setenv>
        <variable name="WIX" value="%WIX%\bin" />
      </setenv>
    </if>

    <!--
      specifies the tool to use for signing the binaries.
      change to "scsigntool.exe" in case you're using a smart card and have scsigntool set up.
      See https://www.mgtek.com/smartcard for details about scsigntool
    -->
    <!-- <property name="signtool" value="scsigntool.exe" /> -->

    <!--
      Update environment & we are good to go.
    -->

    <!--
      Tools should be in ".\Tools" but you may set the TSVNTOOLS
      environment variable instead. If both isn't the case,
      modify the hard-coded path accordingly.
    -->

    <if test="${not environment::variable-exists('TSVNTOOLS')}">
      <setenv>
        <variable name="TSVNTOOLS" value="${project::get-base-directory() + '\Tools'}" />
      </setenv>
    </if>
    <if test="${not file::exists(environment::get-variable('TSVNTOOLS') + '\hhc.exe')}">
      <setenv>
        <!--
          TODO: change path value, if neither TSVNTOOLS is defined
          nor have tools be copied directly below the TSVN root.
        -->
        <variable name="TSVNTOOLS" value="D:\Development\SVN\TortoiseSVN\Tools" />
      </setenv>
    </if>

    <!-- When creating the msi for a release, the task can also
         zip all debug symbols. To do that, specify the path to
         7zip here -->
    <property name="sevenzip" value="c:\program files\7-zip\7z.exe" />

    <!--
      Update environment & we are good to go.
    -->

    <setenv>
      <variable name="PATH" value="D:\smartcardtools\x86;%PATH%" if="${platform != 'x64'}" />
      <variable name="PATH" value="D:\smartcardtools\x64;%PATH%" if="${platform == 'x64'}" />
      <variable name="PATH" value="D:\smartcardtools\x64;%PATH%" if="${platform == 'ARM64'}" />
      <variable name="PATH" value="%TSVNTOOLS%\;%PATH%" />
      <variable name="PATH" value="%TSVNTOOLS%\fop;%PATH%" />
      <variable name="PATH" value="%WIX%;%PATH%" />
      <variable name="WIXUI" value="%WIX%" />
      <variable name="HHLOC" value="%TSVNTOOLS%\hhc.exe" />
      <variable name="XSLROOT" value="%TSVNTOOLS%\xsl" />
    </setenv>
    <if test="${not environment::variable-exists('DEBUGTOOLS')}">
      <setenv>
        <variable name="DEBUGTOOLS" value="C:\Program Files (x86)\Windows Kits\10\Debuggers\x86" />
      </setenv>
    </if>
  </target>
</project>
