Sha256: 8726cf548f5fb24bb764c01af20dddfc4cdb9d367b19e7788087e21ae74f5254

Contents?: true

Size: 724 Bytes

Versions: 5

Compression:

Stored size: 724 Bytes

Contents

require 'rbconfig'

# Utility to load native binaries on Java CLASSPATH
#HACK until jruby returns a more specific 'host_os' than 'linux'
class NativeFolder
  attr_reader :os, :bit

  LINUX_FORMAT = 'linux%s'.freeze
  ARM32 = '-armv6hf'.freeze
  ARM64 = '-aarch64'.freeze

  def initialize
    @os = RbConfig::CONFIG['host_os'].downcase
    @bit = java.lang.System.get_property('os.arch')
  end

  def name
    if /linux/.match?(os)
      return format(LINUX_FORMAT, '64') if /amd64/.match?(bit)
      return format(LINUX_FORMAT, ARM32) if /arm/.match?(bit)
      return format(LINUX_FORMAT, ARM64) if /aarch/.match?(bit)
    end
    raise RuntimeError, "Unsupported Architecture"
  end

  def extension
    '*.so'
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
picrate-2.2.0-java lib/picrate/native_folder.rb
picrate-2.1.2-java lib/picrate/native_folder.rb
picrate-2.1.1-java lib/picrate/native_folder.rb
picrate-2.1.0-java lib/picrate/native_folder.rb
picrate-2.0.1-java lib/picrate/native_folder.rb