bundle: Ship pdfium runtime library for native PDF viewing

This commit is contained in:
yenru0 committed 2026-09-22 19:52:41 +09:00
1 parent 617a8d3814
commit e39622d51c
2 files changed
+27 -1

No files matched your search

+5 -1
View File
@@ -18,7 +18,11 @@ rustflags = [
# We need lld to link libwebrtc.a successfully on aarch64-linux
[target.aarch64-unknown-linux-gnu]
rustflags = ["-C", "link-arg=-fuse-ld=lld"]
rustflags = ["-C", "link-arg=-fuse-ld=lld", "-C", "link-arg=-Wl,-rpath,$ORIGIN/../lib"]
# Lets dlopen("libpdfium.so") resolve the copy bundled in <app>/lib.
[target.x86_64-unknown-linux-gnu]
rustflags = ["-C", "link-arg=-Wl,-rpath,$ORIGIN/../lib"]
[env]
MACOSX_DEPLOYMENT_TARGET = "10.15.7"
+22
View File
@@ -171,6 +171,28 @@ mkdir -p "${zed_dir}/lib"
rm -rf "${zed_dir}/lib/*"
cp $(find_libs) "${zed_dir}/lib"
# PDFium is dlopen'd at runtime by the bundled pdf_viewer for native PDF viewing;
# find_libs cannot see it because the binaries are not linked against it.
case "$(uname -m)" in
x86_64) pdfium_arch="x64" ;;
aarch64) pdfium_arch="arm64" ;;
*) echo "Unsupported architecture for pdfium: $(uname -m)" >&2 && exit 1 ;;
esac
pdfium_tag="chromium/8066"
case "${pdfium_arch}" in
x64) pdfium_sha256="0b43f405477cf2cfc4dbff06905093c3309756c6bca1fb9da99234a2ca97fed2" ;;
arm64) pdfium_sha256="0e6f90dccbc6b81fd5d7106abaf164c4222178f024c204d00d526b60fd2ad535" ;;
esac
pdfium_tgz="${target_dir}/pdfium-linux-${pdfium_arch}.tgz"
if ! echo "${pdfium_sha256} ${pdfium_tgz}" | sha256sum --check --status 2>/dev/null; then
curl -fsSLo "${pdfium_tgz}" "https://github.com/bblanchon/pdfium-binaries/releases/download/${pdfium_tag}/pdfium-linux-${pdfium_arch}.tgz"
echo "${pdfium_sha256} ${pdfium_tgz}" | sha256sum --check -
fi
pdfium_tmp=$(mktemp -d)
tar -xzf "${pdfium_tgz}" -C "${pdfium_tmp}" "lib/libpdfium.so"
cp "${pdfium_tmp}/lib/libpdfium.so" "${zed_dir}/lib/libpdfium.so"
rm -rf "${pdfium_tmp}"
# Icons
mkdir -p "${zed_dir}/share/icons/hicolor/512x512/apps"
cp "crates/zed/resources/app-icon$suffix.png" "${zed_dir}/share/icons/hicolor/512x512/apps/zed.png"