Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@ioquatix
Copy link
Contributor

@ioquatix ioquatix commented Jun 24, 2022

Fixes #728

cc @larskanis :)

@ioquatix
Copy link
Contributor Author

@ioquatix
Copy link
Contributor Author

cc @headius

@ioquatix
Copy link
Contributor Author

@larskanis what do you think about merging this?

Copy link
Member

@larskanis larskanis left a comment

Choose a reason for hiding this comment

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

Sorry @ioquatix for not responding earlier! I like the addition but added two comments to discuss.

end

def to_s
if root
Copy link
Member

Choose a reason for hiding this comment

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

I don't see much value to pass root through LibraryPath. It can be equally prepended externally.

Copy link
Contributor Author

@ioquatix ioquatix Apr 20, 2023

Choose a reason for hiding this comment

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

It's a more convenient interface:

e.g.

lib_path = __dir__ # or something
ffi_lib LibraryPath.new('vips', 42, lib_path)

It's easier to understand the intention of the user (a library in a given path) and easier to print out/debug later on.

A lot of native libraries follow this pattern, i.e. compile a shared library into a known path.

In theory, if someone provides a value of "/foo/bar/mylib.so", that would be split into a root and a name. However, in that case, the string is just returned since there is no point to manipulate it further. Without root we couldn't represent such values.

end
else
# Otherwise we just use a generic format:
"#{Platform::LIBPREFIX}#{name}.#{Platform::LIBSUFFIX}"
Copy link
Member

Choose a reason for hiding this comment

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

I would like to preserve the LIBSUFFIX-addition like so

      lib = "#{Platform::LIBPREFIX}#{name}"
      r = Platform::IS_WINDOWS || Platform::IS_MAC ? "\\.#{Platform::LIBSUFFIX}$" : "\\.so($|\\.[1234567890]+)"
      lib += ".#{Platform::LIBSUFFIX}" unless lib =~ /#{r}/
      lib

@larskanis larskanis merged commit 73c36d7 into ffi:master May 8, 2023
@ioquatix ioquatix deleted the library-path branch May 8, 2023 23:35
larskanis added a commit to larskanis/ffi that referenced this pull request Sep 15, 2023


Commit c95b8f3 removed a possibly already present ABI version number.
larskanis added a commit to larskanis/ffi that referenced this pull request Sep 15, 2023


Commit c95b8f3 removed a possibly already present ABI version number.
larskanis added a commit that referenced this pull request Sep 15, 2023
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.

Add some loading mechanism with library name and ABI version

2 participants