Sha256: fe28aeda787eb04ceb09d4a21e331832ca3f32ea9177c707d91b791d445af490

Contents?: true

Size: 854 Bytes

Versions: 2

Compression:

Stored size: 854 Bytes

Contents

# stdlib
require "fiddle/import"

# modules
require "osqp/matrix"
require "osqp/solver"
require "osqp/version"

module OSQP
  class Error < StandardError; end

  class << self
    attr_accessor :ffi_lib
  end
  lib_path =
    if Gem.win_platform?
      "x64-mingw/osqp.dll"
    elsif RbConfig::CONFIG["host_os"] =~ /darwin/i
      if RbConfig::CONFIG["host_cpu"] =~ /arm|aarch64/i
        "arm64-darwin/libosqp.dylib"
      else
        "x86_64-darwin/libosqp.dylib"
      end
    else
      if RbConfig::CONFIG["host_cpu"] =~ /arm|aarch64/i
        "aarch64-linux/libosqp.so"
      else
        "x86_64-linux/libosqp.so"
      end
    end
  vendor_lib = File.expand_path("../vendor/#{lib_path}", __dir__)
  self.ffi_lib = [vendor_lib]

  # friendlier error message
  autoload :FFI, "osqp/ffi"

  def self.lib_version
    FFI.osqp_version.to_s
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
osqp-0.3.0 lib/osqp.rb
osqp-0.2.2 lib/osqp.rb