From 7799b5e0d2472be5c65c91e459dd5cf35c5cd445 Mon Sep 17 00:00:00 2001 From: baiqing Date: Wed, 6 May 2026 11:12:06 +0800 Subject: [PATCH 1/2] =?UTF-8?q?chore(release-prep):=20=E6=B8=85=E7=90=86?= =?UTF-8?q?=20#268/#279=20=E5=8F=8C=E6=96=B9=E6=A1=88=E6=AE=8B=E7=95=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit main 上 #268 (millionart/codex/register-windows-ime-nsis-installer) 与 #279 (本人) 都修了 NSIS 注册 TSF DLL,merge #279 时未手动解决冲突,导致: 1. tauri.conf.json 出现两个 windows.nsis block(line 92-95 和 105-108), serde_json 用最后写入的覆盖前面,结果 #268 的 nsis/openless-ime-hooks.nsh 被丢弃,实际生效的是 #279 的 installer.nsh。 2. #279 的 bundle.resources 把 dll 多打一份到 $INSTDIR\tsf-ime\,与 #268 PREINSTALL File 直接装到 $INSTDIR\windows-ime\ 并存。 3. installer.nsh 与 openless-ime-payload/ 残留为死代码。 #268 方案更稳:x64 注册带 Sysnative + DisableX64FSRedirection 双保险,有 POSTUNINSTALL 清理 hook,有测试覆盖(4a7a1b6b/test、933e014a/test),且 不污染 MSI(不用 bundle.resources,避免 dll 重复)。 清理: - 删除 tauri.conf.json 重复 nsis block,保留 nsis/openless-ime-hooks.nsh - 删除 bundle.resources(#268 不需要) - 删除死文件 installer.nsh - 删除死目录 openless-ime-payload/ release-tauri.yml 里"复制 dll 到 openless-ime-payload"步骤、build-mac.sh 与 Linux build 的 --config '{"bundle":{"resources":{}}}' override 暂留 — 没有 bundle.resources 后这些是 noop,不会破坏 build;当前 token 没有 workflow scope,等下一次有需求再清。 --- openless-all/app/src-tauri/installer.nsh | 52 ------------------- .../openless-ime-payload/x64/OpenLessIme.dll | 0 .../openless-ime-payload/x86/OpenLessIme.dll | 0 openless-all/app/src-tauri/tauri.conf.json | 8 --- 4 files changed, 60 deletions(-) delete mode 100644 openless-all/app/src-tauri/installer.nsh delete mode 100644 openless-all/app/src-tauri/openless-ime-payload/x64/OpenLessIme.dll delete mode 100644 openless-all/app/src-tauri/openless-ime-payload/x86/OpenLessIme.dll diff --git a/openless-all/app/src-tauri/installer.nsh b/openless-all/app/src-tauri/installer.nsh deleted file mode 100644 index e6675c39..00000000 --- a/openless-all/app/src-tauri/installer.nsh +++ /dev/null @@ -1,52 +0,0 @@ -; NSIS installer hook:注册 / 反注册 OpenLess TSF 输入法 DLL。 -; -; 背景:MSI 包通过 wix/openless-ime.wxs 的 CustomAction 跑 regsvr32,可正常注册到 -; HKLM 下的 TSF 注册表四件套;NSIS 包没有等价钩子 → NSIS 安装的用户在 -; "设置 → 权限"页面看到 "Windows 输入法后端:不可用"。 -; -; 这里的 hook 在 NSIS 安装/卸载流程里调 regsvr32 把 OpenLessIme.dll 注册到 HKLM。 -; bundle.resources 把 x64 / x86 DLL 拷到 $INSTDIR\tsf-ime\{x64,x86}\OpenLessIme.dll -; (resources map 的 target 必须避开 wxs fragment 已声明的 windows-ime\x64\ -; 路径,否则 MSI 包里同一路径会被两个 component 占用)。 -; tauri.conf.json 的 nsis.installMode = "perMachine" 让 NSIS 以管理员身份运行 -; (写 HKLM 必需)。 -; -; 必须同时注册 x64 + x86 两份 dll:windows_ime_profile.rs 的 -; inspect_windows_ime_registration() 会用 KEY_WOW64_64KEY 和 KEY_WOW64_32KEY 两次 -; 检查 HKLM CLSID InprocServer32,少了任何一边都会被判 RegistrationBroken。 -; -; ⚠️ NSIS installer 自身是 32-bit 进程,会触发 WOW64 文件系统重定向: -; - 32-bit 进程里的 $SYSDIR / $WINDIR\System32 都被重定向到 $WINDIR\SysWOW64, -; 运行的是 32-bit regsvr32 → 注册结果落在 HKLM\Software\Wow6432Node(即 -; KEY_WOW64_32KEY 视图),Rust 端 KEY_WOW64_64KEY 查不到 → 仍判"不可用"。 -; - 32-bit 进程访问真正的 64-bit System32 必须走 $WINDIR\Sysnative 这个 alias。 -; 因此: -; - x64 dll → $WINDIR\Sysnative\regsvr32.exe → 写 KEY_WOW64_64KEY 视图 -; - x86 dll → $WINDIR\SysWOW64\regsvr32.exe → 写 KEY_WOW64_32KEY 视图 -; -; regsvr32 失败时不阻塞安装:用户仍可以靠 SendInput / 粘贴兜底完成上屏。 - -!macro NSIS_HOOK_POSTINSTALL - DetailPrint "Registering OpenLess TSF IME (x64) ..." - nsExec::ExecToLog '"$WINDIR\Sysnative\regsvr32.exe" /s "$INSTDIR\tsf-ime\x64\OpenLessIme.dll"' - Pop $0 - ${If} $0 != 0 - DetailPrint "OpenLess TSF IME x64 registration failed (exit $0); fallback insertion paths still work." - ${EndIf} - - DetailPrint "Registering OpenLess TSF IME (x86) ..." - nsExec::ExecToLog '"$WINDIR\SysWOW64\regsvr32.exe" /s "$INSTDIR\tsf-ime\x86\OpenLessIme.dll"' - Pop $0 - ${If} $0 != 0 - DetailPrint "OpenLess TSF IME x86 registration failed (exit $0); fallback insertion paths still work." - ${EndIf} -!macroend - -!macro NSIS_HOOK_PREUNINSTALL - DetailPrint "Unregistering OpenLess TSF IME (x86) ..." - nsExec::ExecToLog '"$WINDIR\SysWOW64\regsvr32.exe" /s /u "$INSTDIR\tsf-ime\x86\OpenLessIme.dll"' - Pop $0 - DetailPrint "Unregistering OpenLess TSF IME (x64) ..." - nsExec::ExecToLog '"$WINDIR\Sysnative\regsvr32.exe" /s /u "$INSTDIR\tsf-ime\x64\OpenLessIme.dll"' - Pop $0 -!macroend diff --git a/openless-all/app/src-tauri/openless-ime-payload/x64/OpenLessIme.dll b/openless-all/app/src-tauri/openless-ime-payload/x64/OpenLessIme.dll deleted file mode 100644 index e69de29b..00000000 diff --git a/openless-all/app/src-tauri/openless-ime-payload/x86/OpenLessIme.dll b/openless-all/app/src-tauri/openless-ime-payload/x86/OpenLessIme.dll deleted file mode 100644 index e69de29b..00000000 diff --git a/openless-all/app/src-tauri/tauri.conf.json b/openless-all/app/src-tauri/tauri.conf.json index 6164ca12..1349489a 100644 --- a/openless-all/app/src-tauri/tauri.conf.json +++ b/openless-all/app/src-tauri/tauri.conf.json @@ -79,10 +79,6 @@ "icons/icon.icns", "icons/icon.ico" ], - "resources": { - "openless-ime-payload/x64/OpenLessIme.dll": "tsf-ime/x64/OpenLessIme.dll", - "openless-ime-payload/x86/OpenLessIme.dll": "tsf-ime/x86/OpenLessIme.dll" - }, "macOS": { "minimumSystemVersion": "12.0", "infoPlist": "Info.plist", @@ -101,10 +97,6 @@ "OpenLessImeDllX64Component", "OpenLessImeDllX86Component" ] - }, - "nsis": { - "installMode": "perMachine", - "installerHooks": "installer.nsh" } } }, From 3414e1ff5efd05582236aef717c24059d924a662 Mon Sep 17 00:00:00 2001 From: baiqing Date: Wed, 6 May 2026 11:20:24 +0800 Subject: [PATCH 2/2] =?UTF-8?q?chore(release-prep):=20=E4=BF=AE=20P2=20+?= =?UTF-8?q?=20=E6=B8=85=E7=90=86=20noop=20bundle.resources=20override?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 完整审查 CI 流程后发现两类问题: 1. windows-build-gnu.ps1 不 build OpenLessIme.dll 也不 export OPENLESS_IME_DLL_X64 / _X86 env,但 NSIS hook (nsis/openless-ime-hooks.nsh) PREINSTALL 用 File "$%OPENLESS_IME_DLL_X64%" / _X86 引用 dll, makensis 编译时 env 为空 → File 路径无效 → NSIS bundle 失败。 补 IME dll 双平台 (x64 / Win32) build + Set-Item Env:。 (Codex PR #280 P2 review) 2. build-mac.sh 之前为绕过 bundle.resources 占位 dll 加的 --config '{"bundle":{"resources":{}}}' override, PR #280 已删除 bundle.resources,此 override 退化为 noop,删除让命令更干净。 release-tauri.yml 还有 2 处同源遗留("复制 dll 到 openless-ime-payload" 死步骤、Linux build 同样的 noop override)需要 workflow scope 才能动, 留待下一个 PR。 --- openless-all/app/scripts/build-mac.sh | 4 +--- .../app/scripts/windows-build-gnu.ps1 | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/openless-all/app/scripts/build-mac.sh b/openless-all/app/scripts/build-mac.sh index 3a51ea81..63b7c94e 100755 --- a/openless-all/app/scripts/build-mac.sh +++ b/openless-all/app/scripts/build-mac.sh @@ -25,9 +25,7 @@ else fi echo "▶ tauri build" -# bundle.resources 里有 Windows TSF DLL(仅 NSIS/MSI 需要),mac 端用空 map 覆盖避免 -# 把 0 字节占位 OpenLessIme.dll 打进 .app/Contents/Resources。 -TAURI_BUILD_ARGS=(build --config '{"bundle":{"resources":{}}}') +TAURI_BUILD_ARGS=(build) if [ -n "${TAURI_SIGNING_PRIVATE_KEY:-}" ] || [ -n "${TAURI_SIGNING_PRIVATE_KEY_PATH:-}" ]; then TAURI_BUILD_ARGS+=(--config '{"bundle":{"createUpdaterArtifacts":true}}') fi diff --git a/openless-all/app/scripts/windows-build-gnu.ps1 b/openless-all/app/scripts/windows-build-gnu.ps1 index 2d875d96..e647035e 100644 --- a/openless-all/app/scripts/windows-build-gnu.ps1 +++ b/openless-all/app/scripts/windows-build-gnu.ps1 @@ -53,6 +53,28 @@ try { Copy-Item -LiteralPath (Join-Path $releaseRoot "openless.exe") -Destination (Join-Path $artifactDevRoot "openless.exe") -Force Copy-Item -LiteralPath (Resolve-WebView2Loader) -Destination (Join-Path $artifactDevRoot "WebView2Loader.dll") -Force + # Build OpenLessIme.dll (x64 + x86) 并导出绝对路径 env var—— + # nsis/openless-ime-hooks.nsh 的 PREINSTALL 用 File "$%OPENLESS_IME_DLL_X64%" / _X86 + # 在 makensis 编译时把 dll 嵌入 NSIS 包;wix/openless-ime.wxs 也用同一对 env 解析 + # candle/light 的绝对路径(CI release-tauri.yml 同款做法)。 + foreach ($t in @( + @{ Platform = 'x64'; Folder = 'x64'; EnvName = 'OPENLESS_IME_DLL_X64' }, + @{ Platform = 'Win32'; Folder = 'x86'; EnvName = 'OPENLESS_IME_DLL_X86' } + )) { + $out = Join-Path $buildRoot "src-tauri\target\windows-ime-msvc\$($t.Folder)\Release" + $obj = Join-Path $buildRoot "src-tauri\target\windows-ime-msvc\obj\$($t.Folder)\Release" + & ./scripts/windows-ime-build.ps1 -Configuration Release -Platform $t.Platform -OutputDirectory $out -IntermediateDirectory $obj + if ($LASTEXITCODE -ne 0) { + throw "OpenLessIme $($t.Platform) build failed with exit $LASTEXITCODE" + } + $dll = (Resolve-Path (Join-Path $out 'OpenLessIme.dll')).Path + if (-not (Test-Path $dll)) { + throw "OpenLessIme.dll not produced at $dll" + } + Set-Item -Path "Env:$($t.EnvName)" -Value $dll + Write-Host "[ok] built $dll (exported $($t.EnvName))" + } + npm run tauri build -- --target x86_64-pc-windows-gnu --bundles msi nsis } finally { Pop-Location