diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2014-06-12 22:47:22 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2014-06-12 22:47:22 -0700 |
commit | b6de464bacfc3aac73d84468a074d2860df8c94f (patch) | |
tree | acbdc63fb6169ae06bbd28d3c31a042a7bb2da09 /lib | |
parent | adad6731147283f692e1d8a7c782cb0aab163a9e (diff) | |
download | ffi-yajl-b6de464bacfc3aac73d84468a074d2860df8c94f.tar.gz |
working on dlopen problem
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ffi_yajl/ext.rb | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/lib/ffi_yajl/ext.rb b/lib/ffi_yajl/ext.rb index 3a25174..d3d7222 100644 --- a/lib/ffi_yajl/ext.rb +++ b/lib/ffi_yajl/ext.rb @@ -7,34 +7,32 @@ require 'libyajl2' begin require 'fiddle' rescue LoadError +end +begin require 'dl' +rescue LoadError end module FFI_Yajl + # FIXME: DRY with ffi_yajl/ffi.rb + libname = ::FFI.map_library_name("yajl") + libpath = File.expand_path(File.join(Libyajl2.opt_path, libname)) + libpath.gsub!(/dylib/, 'bundle') + libpath = ::FFI.map_library_name("yajl") unless File.exist?(libpath) + if defined?(Fiddle) && Fiddle.respond_to?(:dlopen) + ::Fiddle.dlopen(libpath) + elsif defined?(DL) && DL.respond_to?(:dlopen) + ::DL.dlopen(libpath) + else + ffi_lib libpath + end + class Parser - # FIXME: DRY with ffi_yajl/ffi.rb - libname = ::FFI.map_library_name("yajl") - libpath = File.expand_path(File.join(Libyajl2.opt_path, libname)) - libpath.gsub!(/dylib/, 'bundle') - if defined?(Fiddle) && Fiddle.respond_to?(:dlopen) - ::Fiddle.dlopen(libpath) - else - ::DL.dlopen(libpath) - end require 'ffi_yajl/ext/parser' include FFI_Yajl::Ext::Parser end class Encoder - # FIXME: DRY with ffi_yajl/ffi.rb - libname = ::FFI.map_library_name("yajl") - libpath = File.expand_path(File.join(Libyajl2.opt_path, libname)) - libpath.gsub!(/dylib/, 'bundle') - if defined?(Fiddle) && Fiddle.respond_to?(:dlopen) - ::Fiddle.dlopen(libpath) - else - ::DL.dlopen(libpath) - end require 'ffi_yajl/ext/encoder' include FFI_Yajl::Ext::Encoder end |