fix(build): macOS/Linux builds and make the build process handle its own dependencies#251
Open
yuunalein wants to merge 7 commits into
Open
fix(build): macOS/Linux builds and make the build process handle its own dependencies#251yuunalein wants to merge 7 commits into
yuunalein wants to merge 7 commits into
Conversation
…dio/src-tauri/build.rs
…cess of open-pdf-studio
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I found this project, thought it looked neat, and tried to run it on my Mac. It didn't run. Cloning and building dumped me straight into an app that refused to even start, so I ended up fixing it just to see the thing work at all. The fix turned out to be more than a one-liner, so against my better judgment I cleaned it up properly and I'm sending it as a PR.
There are already several open issues from other people hitting the exact same broken non-Windows builds. I'd rather not toss another ignored bug report onto that pile, so here's the actual fix instead of a complaint.
(#249, #244, #242, ...)
What was broken
pdfium.dllwas committed straight intosrc-tauri/binaries/win-x64/and referenced as a bundle resource. Windows only. Nothing for macOS, nothing for Linux.build.rsjust assumed thepdfium-workerbinary had already been compiled and staged somewhere by someone else. It tried to copy the file if it happened to exist and otherwise did nothing at all — silently, of course.pdfium-workeronly looked for its dynamic library in the current working directory (the Windows way) and nowhere else.target/wasn't gitignored, so build artefacts were merrily piling up in version control.pdfium-worker.exewas looked up by that literal name, unconditionally. On every non-Windows platform the worker pool quietly gave up and fell back to in-process PDFium.What this PR does
build.rsso it actually handles its own dependency setup instead of hoping someone did it first. It compilespdfium-workerviacargo build --message-format json(parsing the output to find the executable), then downloads the correct pdfium release from bblanchon/pdfium-binaries for the current target —libpdfium.so,libpdfium.dylib, orpdfium.dll— with SHA-256 verification. Everything lands intarget/runtime-deps/instead ofsrc-tauri/binaries/.pdfium-workerso it looks where the library actually lives on each platform: the app bundle on macOS, and the AppImage or/usr/libon Linux, instead of blindly checking the working directory like it's still on Windows.pdfium.dllandbinaries/win-x64/from the repo, and addstarget/to.gitignorewhere it belonged in the first place.pdfium-workersidecar before the Tauri build.binaries/win-x64/pdfium.dllreference fromtauri.conf.jsonbundle resources.lib.rsandworker_pool/mod.rsto usepdfium-worker(no extension) on Unix andpdfium-worker.exeon Windows, like it should have from the start.Cargo.lockfiles from sub-crates.In the meantime
Until this actually gets merged, I've made a release on my fork with working Linux and macOS downloads, so anyone else who just wants the thing to run doesn't have to go through all of this themselves.