Rework library loading with a focus on cross-platform support #219
No reviewers
Labels
No labels
bug
dependencies
documentation
duplicate
enhancement
github_actions
good first issue
help wanted
invalid
java
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
java-gi/java-gi!219
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "libload-2"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This PR does several things that, in combination, enable the behaviors I described in #216:
windows-gtkCI script was extended to generate dependency metadata in a simple, text-based format. This uses thedumpbintool shipped with the preinstalled Visual Studio workloads, so it is easy to do in CI even if we can't do it on the end users device.LibLoadto automatically load dependencies before the dependent as needed.LibLoadwas updated to makejavagi.pathtake precedence over the system path and to not override that (this property wasn't respected by the JVM anyway and probably just broke other libraries)LibLoadwas extended to support loading libraries from the classpath. This should allow java-gi to provide a new module for Windows (or MacOS) that contains pre-compiled binaries, drastically lowering the amount of work needed to get started on Windows. (I don't know whether you'd want this to be published to maven or elsewhere, so I haven't set up this module yet)LibLoadwas modified to useSymbolLookup, allowing the wrapper inInteropto be cleaned up a bit.Closes #216
Thanks for the PR! I'll review and test it, but in the long term I think maybe we should split LibLoad into its own little project. Primarily because correctly loading DLLs is not specific to java-gi. Secondly, I am not sure I am able to properly support java-gi on Windows and macOS; right now it kinda works but I personally care mostly about the GNOME environment (developing GNOME apps in Java/Kotlin/...) and I don't have the time or experience to properly support Windows and macOS (even though it currently mostly works).
I don't want to spend my time with Windows either, but unfortunately that seems to be where most of my users are, so I'm kind of stuck with it.
To me, the best course of action seems to be supporting Windows on a best-effort basis (ie I'll open issues and try to create PRs if I notice anything breaking, and if none are opened, its probably fine)
Perhaps the CI can run some basic sanity checks vis JUnit but more than that shouldn't be needed.
On extracting LibLoad: I'm inclined to agree. The code I'm using here is based on similar code for another project that effectively had to reimplement the same thing. Sharing this code seems like a good idea, especially since it is a bit finicky.
@JFronny The action failed: https://github.com/jwharm/java-gi/actions/runs/14824869031/job/41616684759
I can create a new GitHub project, something like "jwharm/win-lib-load" and grant you commit access so you don't need to create PRs. I can already publish the releases on Maven Central for the io.github.jwharm.* namespace, so that part would be easy.