Skip to content

Commit

Permalink
(ext) update dynamic library file name on osx
Browse files Browse the repository at this point in the history
  • Loading branch information
stakach committed Oct 12, 2018
1 parent bf50fd3 commit a679fe9
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 16 deletions.
31 changes: 17 additions & 14 deletions lib/libuv/ext/ext.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def self.malloc(bytes)
def self.free(pointer)
::Libuv::Ext::LIBC.free(pointer)
end


def self.path_to_internal_libuv
@path_to_internal_libuv ||= ::File.expand_path("../../../../ext/libuv/lib/libuv.#{FFI::Platform::LIBSUFFIX}", __FILE__)
Expand All @@ -49,22 +49,25 @@ def self.path_to_internal_libuv
# Using home/user/lib is the best we can do on OSX
# Primarily a dev platform so that is OK
paths.unshift "#{ENV['HOME']}/lib"
elsif FFI::Platform.windows?
module Kernel32
extend FFI::Library
ffi_lib 'Kernel32'

attach_function :add_dll_dir, :AddDllDirectory,
[ :buffer_in ], :pointer
LIBUV_PATHS = paths.map{|path| "#{path}/libuv.1.#{FFI::Platform::LIBSUFFIX}"}
else
LIBUV_PATHS = paths.map{|path| "#{path}/libuv.#{FFI::Platform::LIBSUFFIX}"}
if FFI::Platform.windows?
module Kernel32
extend FFI::Library
ffi_lib 'Kernel32'

attach_function :add_dll_dir, :AddDllDirectory,
[ :buffer_in ], :pointer
end
# This ensures that externally loaded libraries like the libcouchbase gem
# will always use the same binary image and not load a second into memory
Kernel32.add_dll_dir "#{lib_path}\0".encode("UTF-16LE")
else # UNIX
# TODO:: ??
end
# This ensures that externally loaded libraries like the libcouchbase gem
# will always use the same binary image and not load a second into memory
Kernel32.add_dll_dir "#{lib_path}\0".encode("UTF-16LE")
else # UNIX
# TODO:: ??
end

LIBUV_PATHS = paths.map{|path| "#{path}/libuv.#{FFI::Platform::LIBSUFFIX}"}
libuv = ffi_lib(LIBUV_PATHS + %w{libuv}).first
rescue LoadError
warn <<-WARNING
Expand Down
2 changes: 1 addition & 1 deletion lib/libuv/ext/tasks/mac.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
FileUtils.cp("ext/libuv/.libs/libuv.1.#{FFI::Platform::LIBSUFFIX}", "ext/libuv/lib/libuv.#{FFI::Platform::LIBSUFFIX}")

# Primrary load location - falls back to above if not available
FileUtils.cp("ext/libuv/.libs/libuv.1.#{FFI::Platform::LIBSUFFIX}", "#{user_lib}/libuv.#{FFI::Platform::LIBSUFFIX}")
FileUtils.cp("ext/libuv/.libs/libuv.1.#{FFI::Platform::LIBSUFFIX}", "#{user_lib}/libuv.1.#{FFI::Platform::LIBSUFFIX}")
end

CLOBBER.include("ext/libuv/.libs/libuv.1.#{FFI::Platform::LIBSUFFIX}")
2 changes: 2 additions & 0 deletions lib/libuv/reactor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ def initialize(pointer) # :notnew:


def stop_cb
return unless @reactor_running
Thread.current.thread_variable_set(:reactor, nil)
@reactor_running = false

Expand Down Expand Up @@ -541,6 +542,7 @@ def log(error, msg = nil, trace = nil)

# Closes handles opened by the reactor class and completes the current reactor iteration (thread safe)
def stop
return unless @reactor_running
@stop_reactor.call
end

Expand Down
2 changes: 1 addition & 1 deletion lib/libuv/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Libuv
VERSION = '4.0.4'
VERSION = '4.1.0'
end

0 comments on commit a679fe9

Please sign in to comment.