diff --git a/local-tool/Makefile b/local-tool/Makefile index 984894a..546e13d 100644 --- a/local-tool/Makefile +++ b/local-tool/Makefile @@ -459,16 +459,38 @@ dmg: wails-macos ## hdiutil UDZO → dist/visiona-local.dmg @file $(DIST)/visiona-local.dmg exe: wails-windows ## ⚠️ 必須在 Windows 上跑:Inno Setup → dist/visiona-local-*-windows-x64.exe - @if ! command -v iscc > /dev/null 2>&1 && ! command -v iscc.exe > /dev/null 2>&1; then \ + @ISCC_BIN="$$ISCC"; \ + if [ -z "$$ISCC_BIN" ]; then \ + if command -v iscc > /dev/null 2>&1; then ISCC_BIN=iscc; \ + elif command -v iscc.exe > /dev/null 2>&1; then ISCC_BIN=iscc.exe; \ + else \ + for p in "/c/Program Files (x86)/Inno Setup 6/ISCC.exe" \ + "/c/Program Files/Inno Setup 6/ISCC.exe" \ + "/c/Program Files (x86)/Inno Setup 5/ISCC.exe"; do \ + if [ -f "$$p" ]; then ISCC_BIN="$$p"; break; fi; \ + done; \ + fi; \ + fi; \ + ISCC_OK=0; \ + if [ -n "$$ISCC_BIN" ]; then \ + if [ -e "$$ISCC_BIN" ] || command -v "$$ISCC_BIN" > /dev/null 2>&1; then ISCC_OK=1; fi; \ + fi; \ + if [ "$$ISCC_OK" = "0" ]; then \ echo ""; \ - echo "❌ Inno Setup Compiler (iscc) 未安裝"; \ + echo "❌ Inno Setup Compiler (iscc) 未安裝 / 找不到"; \ + echo " 已嘗試偵測的路徑:"; \ + echo " - \$$ISCC 環境變數"; \ + echo " - PATH 上的 iscc / iscc.exe"; \ + echo " - /c/Program Files (x86)/Inno Setup 6/ISCC.exe"; \ + echo " - /c/Program Files/Inno Setup 6/ISCC.exe"; \ echo " 請從 https://jrsoftware.org/isdl.php 下載並安裝 Inno Setup 6"; \ - echo " 安裝後將 iscc.exe 目錄加入 PATH"; \ + echo " 或設定 ISCC 環境變數指向 ISCC.exe 絕對路徑"; \ echo ""; \ exit 1; \ - fi - @mkdir -p $(DIST) - iscc installer/windows/visiona-local.iss + fi; \ + echo "==> 使用 ISCC: $$ISCC_BIN"; \ + mkdir -p $(DIST); \ + "$$ISCC_BIN" installer/windows/visiona-local.iss @echo "==> 產出:" @ls -lh $(DIST)/visiona-local-*-windows-x64.exe 2>/dev/null || echo "未找到產出檔" diff --git a/local-tool/scripts/bootstrap-windows.ps1 b/local-tool/scripts/bootstrap-windows.ps1 index 15b371a..cf41c2b 100644 --- a/local-tool/scripts/bootstrap-windows.ps1 +++ b/local-tool/scripts/bootstrap-windows.ps1 @@ -104,22 +104,51 @@ function Convert-ToMsysPath($winPath) { } $msysPython = Convert-ToMsysPath $realPython -# 找 Inno Setup Compiler (iscc.exe),winget 裝在 Program Files (x86) 不在 PATH 裡 -$isccCandidates = @( - "${env:ProgramFiles(x86)}\Inno Setup 6\iscc.exe", - "$env:ProgramFiles\Inno Setup 6\iscc.exe", - "${env:ProgramFiles(x86)}\Inno Setup 5\iscc.exe" -) -$isccPath = $null -foreach ($p in $isccCandidates) { - if ($p -and (Test-Path $p)) { $isccPath = $p; break } +# 找 Inno Setup Compiler (ISCC.exe) +# 重要:檔名是 ISCC.exe(大寫),winget 裝在 Program Files (x86) 不在 PATH 裡 +function Find-Iscc { + $candidates = @( + "${env:ProgramFiles(x86)}\Inno Setup 6\ISCC.exe", + "$env:ProgramFiles\Inno Setup 6\ISCC.exe", + "${env:ProgramFiles(x86)}\Inno Setup 5\ISCC.exe" + ) + foreach ($p in $candidates) { + if ($p -and (Test-Path $p)) { return $p } + } + # 從登錄檔找 Inno Setup 的安裝路徑 + $regPaths = @( + 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Inno Setup 6_is1', + 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Inno Setup 6_is1' + ) + foreach ($rp in $regPaths) { + $item = Get-ItemProperty $rp -ErrorAction SilentlyContinue + if ($item -and $item.InstallLocation) { + $p = Join-Path $item.InstallLocation 'ISCC.exe' + if (Test-Path $p) { return $p } + } + } + # 最後備案:掃 Program Files 底下 + $found = Get-ChildItem -Path "${env:ProgramFiles(x86)}","$env:ProgramFiles" ` + -Filter 'ISCC.exe' -Recurse -ErrorAction SilentlyContinue -Force | + Select-Object -First 1 + if ($found) { return $found.FullName } + return $null +} + +$isccPath = Find-Iscc +if (-not $isccPath) { + Log 'Inno Setup 偵測不到,用 winget 重裝一次' + winget install -e --id JRSoftware.InnoSetup --accept-source-agreements --accept-package-agreements --force + $isccPath = Find-Iscc } if ($isccPath) { Log "偵測到 Inno Setup: $isccPath" $msysIsccDir = Convert-ToMsysPath (Split-Path $isccPath -Parent) + $msysIsccExe = Convert-ToMsysPath $isccPath } else { - Log 'WARN: 找不到 Inno Setup(iscc.exe),make exe 步驟會失敗' + Log 'WARN: 仍然找不到 Inno Setup(iscc.exe),make exe 步驟會失敗' $msysIsccDir = $null + $msysIsccExe = $null } # Makefile 需要 bash + make,透過 MSYS2 bash 執行 @@ -136,6 +165,9 @@ $bashParts = @( if ($msysIsccDir) { $bashParts += "export PATH=`"$msysIsccDir`":`$PATH" } +if ($msysIsccExe) { + $bashParts += "export ISCC=`"$msysIsccExe`"" +} $bashParts += 'make vendor-python-windows vendor-wheels-windows vendor-ffmpeg-windows vendor-ytdlp-windows' $bashParts += 'make payload-windows'