fix(local-tool): 強化 Inno Setup 偵測,支援 ISCC 環境變數 override

Makefile (exe target):
- 新增 ISCC 環境變數 override(絕對路徑優先)
- 偵測順序:\$ISCC → command -v iscc → 已知絕對路徑
- 找不到時列出已嘗試路徑方便 debug

bootstrap-windows.ps1:
- Find-Iscc 函數改用多層策略:固定路徑 → 登錄檔 InstallLocation → Program Files 遞迴掃描
- 偵測不到就自動 winget --force 重裝再試一次
- 同時 export PATH 和 ISCC 雙保險傳給 Makefile

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
jim800121chen 2026-04-12 02:27:38 +08:00
parent 634e4011fd
commit e6f7afe8db
2 changed files with 70 additions and 16 deletions

View File

@ -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 "未找到產出檔"

View File

@ -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"
# 找 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"
)
$isccPath = $null
foreach ($p in $isccCandidates) {
if ($p -and (Test-Path $p)) { $isccPath = $p; break }
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 Setupiscc.exemake exe 步驟會失敗'
Log 'WARN: 仍然找不到 Inno Setupiscc.exemake 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'