Module: SurrealDB::Native::Platform
- Defined in:
- lib/surrealdb/native/platform.rb
Overview
Resolves the platform-specific path to the libsurrealdb_c shared library.
Class Method Summary collapse
-
.host_cpu ⇒ Symbol
:x86_64 or :aarch64.
-
.host_os ⇒ Symbol
:linux, :macos, or :windows.
-
.library_extension ⇒ String
Shared library file extension for the current OS.
-
.library_name ⇒ String
Expected library filename.
-
.library_path ⇒ String
Absolute path or library name for FFI.ffi_lib.
Class Method Details
.host_cpu ⇒ Symbol
Returns :x86_64 or :aarch64.
42 43 44 45 46 47 48 |
# File 'lib/surrealdb/native/platform.rb', line 42 def host_cpu case RbConfig::CONFIG['host_cpu'] when /x86_64|amd64/i then :x86_64 when /aarch64|arm64/i then :aarch64 else RbConfig::CONFIG['host_cpu'].to_sym end end |
.host_os ⇒ Symbol
Returns :linux, :macos, or :windows.
33 34 35 36 37 38 39 |
# File 'lib/surrealdb/native/platform.rb', line 33 def host_os case RbConfig::CONFIG['host_os'] when /darwin/i then :macos when /mingw|mswin|cygwin/i then :windows else :linux end end |
.library_extension ⇒ String
Returns shared library file extension for the current OS.
16 17 18 19 20 21 22 |
# File 'lib/surrealdb/native/platform.rb', line 16 def library_extension case host_os when :macos then 'dylib' when :windows then 'dll' else 'so' end end |
.library_name ⇒ String
Returns expected library filename.
25 26 27 28 29 30 |
# File 'lib/surrealdb/native/platform.rb', line 25 def library_name case host_os when :windows then 'surrealdb_c.dll' else "libsurrealdb_c.#{library_extension}" end end |
.library_path ⇒ String
Returns absolute path or library name for FFI.ffi_lib.
11 12 13 |
# File 'lib/surrealdb/native/platform.rb', line 11 def library_path from_env || from_system end |