Skip to content

Commit f9a01c7

Browse files
agxGuido Guenther
andauthored
varnam: Detect the architecture at runtime (#28)
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]>
1 parent d5e47f8 commit f9a01c7

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

varnam.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ def gem_available?(name)
66
false
77
end
88

9+
require 'rbconfig'
10+
911
if not gem_available?('ffi')
1012
puts "Can't find gem - ffi. To install run '[sudo] gem install ffi'"
1113
exit(1)
@@ -17,7 +19,12 @@ def find_govarnam
1719

1820
# Trying to find out govarnam in the predefined locations if
1921
# absolute path to the library is not specified
20-
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']
22+
arch = RbConfig::CONFIG['arch']
23+
govarnam_search_paths = ['.', File.dirname(File.expand_path(__FILE__)),
24+
'/usr/local/lib',
25+
"/usr/local/lib/#{arch}",
26+
"/usr/lib/#{arch}",
27+
'/usr/lib']
2128
govarnam_names = ['libgovarnam.so', "libgovarnam.so.#{$govarnam_major_version}", 'libgovarnam.dylib', 'varnam.dll']
2229
govarnam_search_paths.each do |path|
2330
govarnam_names.each do |fname|

0 commit comments

Comments
 (0)