@echo off
setlocal
cd /d "%~dp0"
title Build TiHiY Voice Translator v9.11.2 Installer

py tools\VERIFY_NO_SECRETS.py
if errorlevel 1 exit /b 1

if not exist "dist\TiHiY Voice Translator\TiHiY Voice Translator.exe" (
  echo Portable EXE not found. Building it first...
  call BUILD_EXE.bat
  if errorlevel 1 exit /b 1
)

set "ISCC="
if exist "C:\Program Files\Inno Setup 7\ISCC.exe" set "ISCC=C:\Program Files\Inno Setup 7\ISCC.exe"
if not defined ISCC if exist "C:\Program Files (x86)\Inno Setup 6\ISCC.exe" set "ISCC=C:\Program Files (x86)\Inno Setup 6\ISCC.exe"
if not defined ISCC if exist "C:\Program Files\Inno Setup 6\ISCC.exe" set "ISCC=C:\Program Files\Inno Setup 6\ISCC.exe"

if not defined ISCC (
  echo [ERROR] Inno Setup compiler ISCC.exe was not found.
  echo Install Inno Setup 7 or edit this BAT with your path.
  pause
  exit /b 1
)

"%ISCC%" "installer\TiHiY_Voice_Translator_v9_11_2.iss"
if errorlevel 1 (
  echo [ERROR] Installer build failed.
  pause
  exit /b 1
)

echo.
echo [OK] Installer:
echo %CD%\Output\TiHiY_Voice_Translator_v9_11_2_Setup.exe
pause
