diff --git a/ext/extconf.rb b/ext/extconf.rb index 08e067c..2ddb693 100644 --- a/ext/extconf.rb +++ b/ext/extconf.rb @@ -38,11 +38,14 @@ $CFLAGS.gsub!(/[\s+](-ansi|-std=[^\s]+)/, '') dir_config 'libsass' libsass_version = Dir.chdir(libsass_dir) do + ver = nil if File.exist?('.git') ver = %x[git describe --abbrev=4 --dirty --always --tags].chomp - File.write('VERSION', ver) - ver + elsif + spec = ::Gem::Specification.load(File.join(gem_root, "sassc.gemspec")) + ver = spec.version end + File.write('VERSION', ver) File.read('VERSION').chomp if File.exist?('VERSION') end --- a/lib/sassc/native.rb 2020-06-02 16:09:54.000000000 +0300 +++ b/lib/sassc/native.rb 2021-10-28 19:52:33.065000000 +0300 @@ -7,10 +7,23 @@ module SassC extend FFI::Library 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 - ffi_lib File.expand_path("libsass.#{dl_ext}", "#{__dir__}/../../ext") + + # Some non-rvm environments don't copy a shared object over to lib/sassc + # Some linuxes wish to use system library + files = + [ File.expand_path("libsass.#{dl_ext}", __dir__), + File.expand_path("libsass.#{dl_ext}", "#{__dir__}/../../ext"), + Dir[File.join(RbConfig::CONFIG['libdir'], "libsass.#{dl_ext}*")] ] + + lib = + files.flatten.find do |file| + File.file?(file) + end + + if lib + ffi_lib(lib) + else + raise "libsass.so can'be found, plase validate your installation" end require_relative "native/sass_value"