Class: NativeFolder
- Inherits:
-
Object
- Object
- NativeFolder
- Defined in:
- lib/jruby_art/native_folder.rb
Overview
Utility to load native binaries on Java CLASSPATH HACK until jruby returns a more specific ‘host_os’ than ‘linux’
Constant Summary collapse
- LINUX_FORMAT =
'linux%s'.freeze
- ARM32 =
'-armv6hf'.freeze
- WIN_FORMAT =
ARM64 = ‘-aarch64’.freeze
'windows%d'.freeze
- WIN_PATTERNS =
[ /bccwin/i, /cygwin/i, /djgpp/i, /ming/i, /mswin/i, /wince/i ].freeze
Instance Attribute Summary collapse
-
#bit ⇒ Object
readonly
Returns the value of attribute bit.
-
#os ⇒ Object
readonly
Returns the value of attribute os.
Instance Method Summary collapse
- #extension ⇒ Object
-
#initialize ⇒ NativeFolder
constructor
A new instance of NativeFolder.
- #name ⇒ Object
Constructor Details
#initialize ⇒ NativeFolder
Returns a new instance of NativeFolder.
21 22 23 24 |
# File 'lib/jruby_art/native_folder.rb', line 21 def initialize @os = RbConfig::CONFIG['host_os'].downcase @bit = java.lang.System.get_property('os.arch') end |
Instance Attribute Details
#bit ⇒ Object (readonly)
Returns the value of attribute bit.
6 7 8 |
# File 'lib/jruby_art/native_folder.rb', line 6 def bit @bit end |
#os ⇒ Object (readonly)
Returns the value of attribute os.
6 7 8 |
# File 'lib/jruby_art/native_folder.rb', line 6 def os @os end |
Instance Method Details
#extension ⇒ Object
39 40 41 42 43 |
# File 'lib/jruby_art/native_folder.rb', line 39 def extension return '*.so' if /linux/.match?(os) return '*.dll' if WIN_PATTERNS.any? { |pat| pat =~ os } '*.dylib' # MacOS end |
#name ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/jruby_art/native_folder.rb', line 26 def name return 'macosx' if /darwin|mac/.match?(os) if /linux/.match?(os) return format(LINUX_FORMAT, '64') if /amd64/.match?(bit) return format(LINUX_FORMAT, ARM32) if /arm/.match?(bit) end if WIN_PATTERNS.any? { |pat| pat =~ os } return format(WINDOWS_FORMAT, '64') if /64/.match?(bit) return format(WINDOWS_FORMAT, '32') if /32/.match?(bit) end raise 'Unsupported Architecture' end |