Module: Valkey::Bindings

Extended by:
FFI::Library
Defined in:
lib/valkey/bindings.rb

Defined Under Namespace

Classes: AsyncClientData, BatchInfo, BatchOptionsInfo, ClientData, ClientType, CmdInfo, CommandError, CommandResponse, CommandResult, ConnectionResponse, OpenTelemetryConfig, OpenTelemetryMetricsConfig, OpenTelemetryTracesConfig, ScriptHashBuffer, Statistics

Class Method Summary collapse

Class Method Details

.platform_infoObject

Determine platform-specific library extension and directory name



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
43
44
45
46
47
48
49
# File 'lib/valkey/bindings.rb', line 8

def self.platform_info
  os = if FFI::Platform.mac?
         "darwin"
       elsif FFI::Platform.windows?
         "windows"
       else
         "linux"
       end

  # Detect architecture
  arch = case RbConfig::CONFIG["host_cpu"]
         when /x86_64|amd64/i
           "x86_64"
         when /aarch64|arm64/i
           "aarch64"
         when /i[3-6]86/i
           "x86"
         else
           RbConfig::CONFIG["host_cpu"]
         end

  lib_ext = case os
            when "darwin"
              "dylib"
            when "windows"
              "dll"
            else
              "so"
            end

  # Platform directory name matches Rust target triple convention
  platform_dir = case os
                 when "darwin"
                   "#{arch}-apple-darwin"
                 when "linux"
                   "#{arch}-unknown-linux-gnu"
                 when "windows"
                   "#{arch}-pc-windows-msvc"
                 end

  { os: os, arch: arch, lib_ext: lib_ext, platform_dir: platform_dir }
end