Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 74c20e6

Browse files
authored
Merge pull request #390 from kleisauke/single-shared-vips-compat
Ensure compatibility with a single shared libvips library
2 parents 866f509 + 2cb995d commit 74c20e6

File tree

2 files changed

+37
-5
lines changed

2 files changed

+37
-5
lines changed

‎CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## master
44

5+
* fix compat with unified (semistatic) libvips binaries [kleisauke]
6+
57
## Version 2.2.1 (2024年02月21日)
68

79
* add `Vips.block_untrusted` method to block all untrusted operations. Only for libvips >= 8.13. [Docs](https://www.libvips.org/API/current/libvips-vips.html#vips-block-untrusted-set). [#382](https://github.com/libvips/ruby-vips/pull/382) [aglushkov](https://github.com/aglushkov)

‎lib/vips.rb

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,30 @@ def library_name(name, abi_number)
3333
end
3434
end
3535

36+
# we can sometimes get dependent libraries from libvips -- either the platform
37+
# will open dependencies for us automatically, or the libvips binary has been
38+
# built to includes all main dependencies (common on windows, can happen
39+
# elsewhere)
40+
#
41+
# we must get glib functions from libvips if we can, since it will be the
42+
# one that libvips itself is using, and they will share runtime types
43+
module Vips
44+
extend FFI::Library
45+
46+
ffi_lib library_name("vips", 42)
47+
48+
begin
49+
attach_function :g_malloc, [:size_t], :pointer
50+
@@is_unified = true
51+
rescue FFI::NotFoundError
52+
@@is_unified = false
53+
end
54+
55+
def self.unified?
56+
@@is_unified
57+
end
58+
end
59+
3660
module GLib
3761
class << self
3862
attr_accessor :logger
@@ -42,7 +66,11 @@ class << self
4266

4367
extend FFI::Library
4468

45-
ffi_lib library_name("glib-2.0", 0)
69+
if Vips.unified?
70+
ffi_lib library_name("vips", 42)
71+
else
72+
ffi_lib library_name("glib-2.0", 0)
73+
end
4674

4775
attach_function :g_malloc, [:size_t], :pointer
4876

@@ -134,7 +162,11 @@ def self.set_log_domain domain
134162
module GObject
135163
extend FFI::Library
136164

137-
ffi_lib library_name("gobject-2.0", 0)
165+
if Vips.unified?
166+
ffi_lib library_name("vips", 42)
167+
else
168+
ffi_lib library_name("gobject-2.0", 0)
169+
end
138170

139171
# we can't just use ulong, windows has different int sizing rules
140172
if FFI::Platform::ADDRESS_SIZE == 64
@@ -568,9 +600,7 @@ module GObject
568600
# {Image#median}.
569601

570602
module Vips
571-
extend FFI::Library
572-
573-
ffi_lib library_name("vips", 42)
603+
# we've already opened the libvips library
574604

575605
LOG_DOMAIN = "VIPS"
576606
GLib.set_log_domain LOG_DOMAIN

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /