Skip to content

Commit

Permalink
varnam: Detect the architecture at runtime (#28)
Browse files Browse the repository at this point in the history
The current list works for i386 and amd64 but fails e.g on arm64, armhf
or mips. Use RbConfig to detect the arch at runtime

Co-authored-by: Guido Guenther <[email protected]>
  • Loading branch information
agx and Guido Guenther authored Dec 14, 2024
1 parent d5e47f8 commit f9a01c7
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion varnam.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ def gem_available?(name)
false
end

require 'rbconfig'

if not gem_available?('ffi')
puts "Can't find gem - ffi. To install run '[sudo] gem install ffi'"
exit(1)
Expand All @@ -17,7 +19,12 @@ def find_govarnam

# Trying to find out govarnam in the predefined locations if
# absolute path to the library is not specified
govarnam_search_paths = ['.', File.dirname(File.expand_path(__FILE__)), '/usr/local/lib', '/usr/local/lib/i386-linux-gnu', '/usr/local/lib/x86_64-linux-gnu', '/usr/lib/i386-linux-gnu', '/usr/lib/x86_64-linux-gnu', '/usr/lib']
arch = RbConfig::CONFIG['arch']
govarnam_search_paths = ['.', File.dirname(File.expand_path(__FILE__)),
'/usr/local/lib',
"/usr/local/lib/#{arch}",
"/usr/lib/#{arch}",
'/usr/lib']
govarnam_names = ['libgovarnam.so', "libgovarnam.so.#{$govarnam_major_version}", 'libgovarnam.dylib', 'varnam.dll']
govarnam_search_paths.each do |path|
govarnam_names.each do |fname|
Expand Down

0 comments on commit f9a01c7

Please sign in to comment.