diff options
author | Wayne Meissner <wmeissner@gmail.com> | 2009-09-29 21:47:43 +1000 |
---|---|---|
committer | Wayne Meissner <wmeissner@gmail.com> | 2009-09-29 21:47:43 +1000 |
commit | 002e922940cfbc23d29cd9c0d252edaf9a299f31 (patch) | |
tree | 1f36bbfa5c13b0a41dba5295f6c9264a2b967c8a | |
parent | 973060292566bce8834cf8210717daf9f8c8c3a1 (diff) | |
download | ffi-002e922940cfbc23d29cd9c0d252edaf9a299f31.tar.gz |
Don't raise exceptions on unknown os/cpu/lib extension, just default the values.
-rw-r--r-- | lib/ffi/platform.rb | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/lib/ffi/platform.rb b/lib/ffi/platform.rb index 26ae16c..148465a 100644 --- a/lib/ffi/platform.rb +++ b/lib/ffi/platform.rb @@ -17,8 +17,9 @@ module FFI when /win|mingw/ "windows" else - raise FFI::PlatformError, "Unknown operating system: #{Config::CONFIG['host_os']}" + Config::CONFIG['host_os'].downcase end + ARCH = case CPU.downcase when /amd64|x86_64/ "x86_64" @@ -27,8 +28,9 @@ module FFI when /ppc|powerpc/ "powerpc" else - raise FFI::PlatformError, "Unknown cpu architecture: #{ARCH_}" + Config::CONFIG['host_cpu'] end + private def self.is_os(os) OS == os @@ -43,6 +45,7 @@ module FFI IS_BSD = IS_MAC || IS_FREEBSD || IS_OPENBSD CONF_DIR = File.dirname(__FILE__) public + LIBC = if IS_WINDOWS "msvcrt" elsif IS_LINUX @@ -50,26 +53,33 @@ module FFI else "c" end + LIBPREFIX = IS_WINDOWS ? '' : 'lib' + LIBSUFFIX = case OS when /darwin/ 'dylib' when /linux|bsd|solaris/ 'so' - when /win/ + when /windows/ 'dll' else - raise PlatformError, "Cannot determine shared library extension for #{OS}" + # Punt and just assume a sane unix (i.e. anything but AIX) + 'so' end + def self.bsd? IS_BSD end + def self.windows? IS_WINDOWS end + def self.mac? IS_MAC end + def self.unix? !IS_WINDOWS end |