Skip to content

Commit

Permalink
Merge pull request #2306 from paddor/master
Browse files Browse the repository at this point in the history
Problem: Ruby bindings outdated with regards to zproject
  • Loading branch information
sappo authored Nov 28, 2024
2 parents 5a8d6d8 + 7673b7f commit 5b5c640
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions bindings/ruby/lib/czmq/ffi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,21 @@ def self.available?
end

begin
lib_name = 'libczmq'
lib_dirs = ['/usr/local/lib', '/opt/local/lib', '/usr/lib64']
env_name = "#{lib_name.upcase}_PATH"
lib_dirs = [*ENV[env_name].split(':'), *lib_dirs] if ENV[env_name]
lib_paths = lib_dirs.map { |path| "#{path}/#{lib_name}.#{::FFI::Platform::LIBSUFFIX}" }
ffi_lib lib_paths + [lib_name]
lib_name = 'libczmq'
major_version = '4'
lib_dirs = ['/usr/local/lib', '/opt/local/lib', '/usr/lib64', '/usr/lib']
lib_dirs = [*ENV['LD_LIBRARY_PATH'].split(':'), *lib_dirs] if ENV['LD_LIBRARY_PATH']
lib_dirs = [*ENV["#{lib_name.upcase}_PATH"].split(':'), *lib_dirs] if ENV["#{lib_name.upcase}_PATH"]
lib_paths = lib_dirs.map do |path|
[
"#{path}/#{lib_name}.#{::FFI::Platform::LIBSUFFIX}",
"#{path}/#{lib_name}.#{::FFI::Platform::LIBSUFFIX}.#{major_version}"
]
end.flatten

lib_paths.concat [lib_name, "#{lib_name}.#{::FFI::Platform::LIBSUFFIX}.#{major_version}"]

ffi_lib lib_paths
@available = true
rescue LoadError
warn ""
Expand Down

0 comments on commit 5b5c640

Please sign in to comment.