Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ffi/loadlib: add module #1938

Merged
merged 1 commit into from
Sep 23, 2024

Conversation

benoit-pierre
Copy link
Contributor

@benoit-pierre benoit-pierre commented Sep 22, 2024

Provide a ffi.loadlib helper, replacing ffi.load and util.ffiLoadCandidates for loading our libraries.

Prerequisite for #1920 & koreader/koreader#12545.


This change is Reviewable

Provide a `ffi.loadlib` helper, replacing `ffi.load` and
`util.ffiLoadCandidates` for loading our libraries.
@Frenzie Frenzie merged commit 7b07c9e into koreader:master Sep 23, 2024
3 of 4 checks passed
Copy link
Member

@NiLuJe NiLuJe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 23 of 23 files at r1, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion


ffi/jpeg.lua line 19 at r1 (raw file):

-- backward compatible: the major & patch numbers are always 0, and when
-- a new API version is made available, the minor number is incremented.
local turbojpeg = ffi.loadlib("turbojpeg", "0.3.0", "turbojpeg")

The idea behind the third argument is to fall-back to an unversioned library, right?

I wouldn't mind proper documentation about that in ffi/loadlib.lua itself ;).

(Specifically as far as this sort of stuff is concerned, as well as the util.loadSDL2 workflow where you can just pass a list of name, version tuples to a single call and they'll get chunked automatically).

@benoit-pierre benoit-pierre deleted the pr/add_ffi.loadlib_helper branch September 23, 2024 15:57
@benoit-pierre
Copy link
Contributor Author

Reviewed 23 of 23 files at r1, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion

ffi/jpeg.lua line 19 at r1 (raw file):

-- backward compatible: the major & patch numbers are always 0, and when
-- a new API version is made available, the minor number is incremented.
local turbojpeg = ffi.loadlib("turbojpeg", "0.3.0", "turbojpeg")

The idea behind the third argument is to fall-back to an unversioned library, right?

Actually, if the goal is to maybe not ship our libraries, for projects we don't patch (e.g. to use system libraries when building Linux packages), then the code should be amended to ffi.loadlib("turbojpeg", "0.3.0") or ffi.load("turbojpeg"), so we do fallback to the unversioned system library if we're not shipping ours and the system version is different: if the version is too old, the symbols we need will be unresolved, otherwise, any newer version should be backward compatible.

I wouldn't mind proper documentation about that in ffi/loadlib.lua itself ;).

See #1939.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants