From 98b3b1b20c08d64191b126914501743c83f9285b Mon Sep 17 00:00:00 2001 From: liyepan Date: Fri, 23 Oct 2026 14:48:50 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20v0.12.5=20=E2=80=94=E2=80=94=20=E4=BF=AE?= =?UTF-8?q?=20Windows=20=E9=93=BE=E6=8E=A5=E5=99=A8=E8=A2=AB=20Git=20Bash?= =?UTF-8?q?=20=E6=8A=A2=E3=80=81macOS=20=E5=8F=AA=E9=83=A8=E7=BD=B2?= =?UTF-8?q?=E9=9C=80=E8=A6=81=E7=9A=84=E6=8F=92=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Windows:Git Bash 的 /usr/bin/link.exe 会先于 MSVC 的 link.exe 被 nmake 找到, 把 cl.exe 所在目录放到 PATH 最前面;同时给 MSVC 加 /utf-8, 修掉 C4566 和潜在的中文串码 - macOS:macdeployqt 之后删掉 virtualkeyboard / platforminputcontexts / printsupport / iconengines / imageformats / tls / bearer 这些用不到的插件, 它们会把 /opt/homebrew 的一堆 dylib 拖进来 - bundle-libs.sh:改写失败不再静默吞掉,检查时跳过 otool 的文件名行, 失败时打印「文件 <- 依赖」方便定位 --- .github/workflows/packages.yml | 33 +++++++++++++++++++++++++++++++++ README.md | 4 ++-- VoiletMark.pro | 5 ++++- packaging/macos/bundle-libs.sh | 30 ++++++++++++++++++++++-------- 4 files changed, 61 insertions(+), 11 deletions(-) diff --git a/.github/workflows/packages.yml b/.github/workflows/packages.yml index 74624eb..b03c388 100644 --- a/.github/workflows/packages.yml +++ b/.github/workflows/packages.yml @@ -135,6 +135,18 @@ jobs: mkdir -p build cd build + # Git Bash 的 /usr/bin 里也有个 link.exe(coreutils 的硬链接工具), + # 必须把 MSVC 的 bin 放到 PATH 最前面,nmake 才会用真正的 link.exe + cl_path=$(command -v cl.exe || command -v cl || true) + if [ -z "$cl_path" ]; then + echo "PATH 里找不到 cl.exe" >&2 + exit 1 + fi + msvc_bin=$(dirname "$cl_path") + export PATH="$msvc_bin:$PATH" + echo "cl: $(command -v cl)" + echo "link: $(command -v link)" + qmake ../VoiletMark.pro CONFIG+=release nmake release || nmake if [ -f release/VoiletMark.exe ]; then @@ -236,6 +248,18 @@ jobs: grep -q arm64 /tmp/arch.txt "$QT_PREFIX/bin/macdeployqt" VoiletMark.app -always-overwrite + + # 只留平台插件和样式插件;虚拟键盘 / 打印 / 图片格式这些用不到, + # 留着只会把 Homebrew 的 dylib 拖进来 + rm -rf VoiletMark.app/Contents/PlugIns/virtualkeyboard \ + VoiletMark.app/Contents/PlugIns/platforminputcontexts \ + VoiletMark.app/Contents/PlugIns/printsupport \ + VoiletMark.app/Contents/PlugIns/iconengines \ + VoiletMark.app/Contents/PlugIns/imageformats \ + VoiletMark.app/Contents/PlugIns/networkinformation \ + VoiletMark.app/Contents/PlugIns/tls \ + VoiletMark.app/Contents/PlugIns/bearer + otool -L VoiletMark.app/Contents/MacOS/VoiletMark | head -30 - name: 收 Homebrew 依赖 + ad-hoc 签名 @@ -292,6 +316,15 @@ jobs: macdeployqt VoiletMark.app -always-overwrite + rm -rf VoiletMark.app/Contents/PlugIns/virtualkeyboard \ + VoiletMark.app/Contents/PlugIns/platforminputcontexts \ + VoiletMark.app/Contents/PlugIns/printsupport \ + VoiletMark.app/Contents/PlugIns/iconengines \ + VoiletMark.app/Contents/PlugIns/imageformats \ + VoiletMark.app/Contents/PlugIns/networkinformation \ + VoiletMark.app/Contents/PlugIns/tls \ + VoiletMark.app/Contents/PlugIns/bearer + - name: 收依赖 + ad-hoc 签名 run: | set -euo pipefail diff --git a/README.md b/README.md index 41a48e9..eb774fa 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ 一个轻量的跨平台 Markdown 编辑器,基于 **Qt 5 / C++17** 构建。 -当前版本 **0.12.4**。 +当前版本 **0.12.5**。 ## 界面 @@ -231,7 +231,7 @@ PR 或手动运行时编译,并打出下面这些安装包。 ### 发 Release -- 打 tag:`git tag v0.12.4 && git push origin v0.12.4`(同步到 GitHub 时把 tag 一起推过去) +- 打 tag:`git tag v0.12.5 && git push origin v0.12.4`(同步到 GitHub 时把 tag 一起推过去) - 不打 tag:**Actions → 安装包 → Run workflow**,勾上 **publish**,会用 `v<版本>` 当 tag - 普通推送 / PR 只上传 artifact,不发 Release——「发布到 Release」显示 skipped 是正常的 diff --git a/VoiletMark.pro b/VoiletMark.pro index e13eb06..8a5ccab 100644 --- a/VoiletMark.pro +++ b/VoiletMark.pro @@ -1,11 +1,14 @@ TEMPLATE = app TARGET = VoiletMark -VERSION = 0.12.4 +VERSION = 0.12.5 QT += core gui widgets CONFIG += c++17 warn_on +# 源码是 UTF-8(含中文和 ▾ 之类的符号),MSVC 默认按本地代码页会串码 / 报 C4566 +msvc: QMAKE_CXXFLAGS += /utf-8 + # 让 main.cpp 里的 QStringLiteral(VM_VERSION) 拿到版本号字符串 DEFINES += VM_VERSION=\\\"$$VERSION\\\" diff --git a/packaging/macos/bundle-libs.sh b/packaging/macos/bundle-libs.sh index 2cda616..12b256e 100755 --- a/packaging/macos/bundle-libs.sh +++ b/packaging/macos/bundle-libs.sh @@ -13,6 +13,10 @@ fi frameworks=$app/Contents/Frameworks mkdir -p "$frameworks" +list_macho() { + find "$app" -type f \( -perm -111 -o -name '*.dylib' \) -print +} + round=0 while [ "$round" -lt 12 ]; do round=$((round + 1)) @@ -26,21 +30,31 @@ while [ "$round" -lt 12 ]; do if [ ! -f "$frameworks/$base" ]; then cp "$dep" "$frameworks/$base" chmod 755 "$frameworks/$base" - install_name_tool -id "@executable_path/../Frameworks/$base" "$frameworks/$base" >/dev/null 2>&1 || true + install_name_tool -id "@executable_path/../Frameworks/$base" "$frameworks/$base" 2>/dev/null || true changed=1 fi - install_name_tool -change "$dep" "@executable_path/../Frameworks/$base" "$file" >/dev/null 2>&1 || true + if ! install_name_tool -change "$dep" "@executable_path/../Frameworks/$base" "$file" 2>/dev/null; then + echo "改写引用失败: $file <- $dep" >&2 + fi ;; esac - done < <(otool -L "$file" | tail -n +2 | awk '{print $1}') - done < <(find "$app" -type f \( -perm -111 -o -name '*.dylib' \) -print) + done < <(otool -L "$file" 2>/dev/null | tail -n +2 | awk '{print $1}') + done < <(list_macho) [ "$changed" -eq 1 ] || break done -left=$(find "$app" -type f \( -perm -111 -o -name '*.dylib' \) -exec otool -L {} + 2>/dev/null | grep -E '^[[:space:]]*(/opt/homebrew|/usr/local)/' | wc -l | tr -d ' ') -if [ "$left" -ne 0 ]; then - echo "还有 $left 个 Homebrew 依赖没处理:" >&2 - find "$app" -type f \( -perm -111 -o -name '*.dylib' \) -exec otool -L {} + 2>/dev/null | grep -E '^[[:space:]]*(/opt/homebrew|/usr/local)/' | head -20 >&2 +remaining=$(mktemp) +while IFS= read -r file; do + otool -L "$file" 2>/dev/null | tail -n +2 \ + | awk -v f="$file" '$1 ~ /^\/(opt\/homebrew|usr\/local)\// { print f ": " $1 }' +done < <(list_macho) > "$remaining" + +if [ -s "$remaining" ]; then + echo "还有 Homebrew 依赖没处理:" >&2 + head -30 "$remaining" >&2 + rm -f "$remaining" exit 1 fi +rm -f "$remaining" +echo "Homebrew 依赖已经收进 app"