Module: TBClient::SharedLib

Defined in:
lib/tb_client/shared_lib.rb

Constant Summary collapse

PKG_DIR =
'../../ext/tb_client/pkg'.freeze

Class Method Summary collapse

Class Method Details

.pathObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/tb_client/shared_lib.rb', line 6

def path
  prefix = ''
  linux_libc = ''
  suffix = ''

  arch, os = RUBY_PLATFORM.split('-')

  arch =
    case arch
    when 'x86_64', 'amd64' then 'x86_64'
    when 'aarch64', 'arm64' then 'aarch64'
    else
      raise "Unsupported architecture: #{arch}"
    end

  case os
  when /darwin/
    prefix = 'lib'
    system = 'macos'
    suffix = '.dylib'
  when 'linux'
    prefix = 'lib'
    system = 'linux'
    linux_libc = detect_libc
    suffix = '.so'
  when 'windows'
    system = 'windows'
    suffix = '.dll'
  else
    raise "Unsupported system: #{os}"
  end

  File.expand_path(
    "#{PKG_DIR}/#{arch}-#{system}#{linux_libc}/#{prefix}tb_client#{suffix}",
    __dir__
  )
end