$ProjectRoot = if ($PSScriptRoot) { Split-Path -Parent $PSScriptRoot } else { (Get-Location).Path }
Set-Location $ProjectRoot

$MainScript = Join-Path $ProjectRoot "main.py"
$IconPath = Join-Path $ProjectRoot "icon.ico"
$MariadbPath = Join-Path $ProjectRoot "mariadb"

python -m PyInstaller `
  --noconfirm `
  --clean `
  --onedir `
  --windowed `
  --name "Golder" `
  --icon "$IconPath" `
  --distpath "build\pyinstaller" `
  --workpath "build\pyinstaller\work" `
  --specpath "build\pyinstaller" `
  --add-data "${MariadbPath};mariadb" `
  --collect-submodules "core" `
  --collect-submodules "ui" `
  --collect-submodules "modules" `
  "$MainScript"