From 28aa5c7102a253f61f34eceb74cf1564442865fb Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Nov 24 2019 13:15:46 +0000 Subject: Use RbConfig::MAKEFILE_CONFIG['DLEXT'] instead of hardcoding extensions * Since libsass is meant to be used with FFI, RbConfig::CONFIG['SOEXT'] would be better, but DLEXT is used as libsass is compiled by mkmf (#127). * Use RbConfig::MAKEFILE_CONFIG['DLEXT'] instead of just RbConfig::CONFIG['DLEXT'] so it's also correct on JRuby and not 'jar'. See https://github.com/rake-compiler/rake-compiler/blob/f808dd7a/lib/rake/extensiontask.rb#L41 * This lets Ruby implementations use another file extension than .so/.bundle for C extensions. For example, TruffleRuby 19.3.0 uses .dylib on macOS. * Some OS also use a different file extension, such as HPUX which uses .sl. --- diff --git a/lib/sassc/native.rb b/lib/sassc/native.rb index 3946b35..74e0099 100644 --- a/lib/sassc/native.rb +++ b/lib/sassc/native.rb @@ -6,7 +6,7 @@ module SassC module Native extend FFI::Library - dl_ext = (RbConfig::CONFIG['host_os'] =~ /darwin/ ? 'bundle' : 'so') + dl_ext = RbConfig::MAKEFILE_CONFIG['DLEXT'] begin ffi_lib File.expand_path("libsass.#{dl_ext}", __dir__) rescue LoadError # Some non-rvm environments don't copy a shared object over to lib/sassc