安装包 / Linux aarch64 (push) Canceled after 0s
安装包 / Linux x86_64 (push) Canceled after 0s
安装包 / Windows x86_64 (push) Canceled after 0s
安装包 / macOS arm64 (Apple Silicon) (push) Canceled after 0s
安装包 / macOS x86_64 (Intel) (push) Canceled after 0s
安装包 / 发布到 Release (push) Canceled after 0s
- 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 的文件名行, 失败时打印「文件 <- 依赖」方便定位
61 lines
1.9 KiB
Bash
Executable File
61 lines
1.9 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# 把 .app 里引用到的 Homebrew 动态库收进 Contents/Frameworks,并把引用改成包内相对路径。
|
|
# Homebrew 的 Qt 会链到 /opt/homebrew 下的 libpng / freetype 等,macdeployqt 不会带它们。
|
|
# 用法: bundle-libs.sh <VoiletMark.app>
|
|
set -euo pipefail
|
|
|
|
app=$1
|
|
if [ ! -d "$app" ]; then
|
|
echo "找不到 $app" >&2
|
|
exit 1
|
|
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))
|
|
changed=0
|
|
while IFS= read -r file; do
|
|
[ -f "$file" ] || continue
|
|
while IFS= read -r dep; do
|
|
case "$dep" in
|
|
/opt/homebrew/*|/usr/local/*)
|
|
base=$(basename "$dep")
|
|
if [ ! -f "$frameworks/$base" ]; then
|
|
cp "$dep" "$frameworks/$base"
|
|
chmod 755 "$frameworks/$base"
|
|
install_name_tool -id "@executable_path/../Frameworks/$base" "$frameworks/$base" 2>/dev/null || true
|
|
changed=1
|
|
fi
|
|
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" 2>/dev/null | tail -n +2 | awk '{print $1}')
|
|
done < <(list_macho)
|
|
|
|
[ "$changed" -eq 1 ] || break
|
|
done
|
|
|
|
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"
|