Skip to content

Commit

Permalink
Merge pull request #207 from libvips/fix-libname
Browse files Browse the repository at this point in the history
[WIP] improve libname generation
  • Loading branch information
jcupitt authored Sep 24, 2019
2 parents 602bcf1 + 3c12206 commit e8135da
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 23 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## master

## Version 2.0.16 (2019-9-21)

* better library name generation [renchap]

## Version 2.0.15 (2019-6-12)

* better error messages from `write_to_memory` [linkyndy]
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.15
2.0.16
47 changes: 26 additions & 21 deletions lib/vips.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,29 @@
# This module uses FFI to make a simple layer over the glib and gobject
# libraries.

# Generate a library name for ffi.
#
# Platform notes:
# linux:
# Some distros allow "libvips.so", but only if the -dev headers have been
# installed. To work everywhere, you must include the ABI number.
# Confusingly, the file extension is not at the end. ffi adds the "lib"
# prefix.
# mac:
# As linux, but the extension is at the end and is added by ffi.
# windows:
# The ABI number must be included, but with a hyphen. ffi does not add a
# "lib" prefix or a ".dll" suffix.
def library_name(name, abi_number)
if FFI::Platform.windows?
"lib#{name}-#{abi_number}.dll"
elsif FFI::Platform.mac?
"#{name}.#{abi_number}"
else
"#{name}.so.#{abi_number}"
end
end

module GLib
class << self
attr_accessor :logger
Expand All @@ -19,13 +42,7 @@ class << self

extend FFI::Library

if FFI::Platform.windows?
glib_libname = 'libglib-2.0-0.dll'
else
glib_libname = 'glib-2.0'
end

ffi_lib glib_libname
ffi_lib library_name('glib-2.0', 0)

attach_function :g_malloc, [:size_t], :pointer

Expand Down Expand Up @@ -117,13 +134,7 @@ def self.set_log_domain domain
module GObject
extend FFI::Library

if FFI::Platform.windows?
gobject_libname = 'libgobject-2.0-0.dll'
else
gobject_libname = 'gobject-2.0'
end

ffi_lib gobject_libname
ffi_lib library_name('gobject-2.0', 0)

# we can't just use ulong, windows has different int sizing rules
if FFI::Platform::ADDRESS_SIZE == 64
Expand Down Expand Up @@ -459,13 +470,7 @@ module GObject
module Vips
extend FFI::Library

if FFI::Platform.windows?
vips_libname = 'libvips-42.dll'
else
vips_libname = 'vips'
end

ffi_lib vips_libname
ffi_lib library_name('vips', 42)

LOG_DOMAIN = "VIPS"
GLib::set_log_domain LOG_DOMAIN
Expand Down
2 changes: 1 addition & 1 deletion lib/vips/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Vips
VERSION = "2.0.15"
VERSION = "2.0.16"
end

0 comments on commit e8135da

Please sign in to comment.