revault_api 0.1.0-x86_64-linux

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rbconfig'
4
+
5
+ module Revault
6
+ module NativeLibrary
7
+ module_function
8
+
9
+ def path
10
+ return ENV['REVAULT_LIBRARY'] unless ENV['REVAULT_LIBRARY'].to_s.empty?
11
+ cpu = case RbConfig::CONFIG['host_cpu']
12
+ when 'x86_64', 'amd64' then 'x86_64'
13
+ when 'aarch64', 'arm64' then 'aarch64'
14
+ else raise "unsupported reVault architecture: #{RbConfig::CONFIG['host_cpu']}"
15
+ end
16
+ target, library = case RbConfig::CONFIG['host_os']
17
+ when /linux/ then ["linux-#{cpu}-gnu", 'librevault_api.so']
18
+ when /darwin/ then ["macos-#{cpu}", 'librevault_api.dylib']
19
+ when /mswin|mingw/ then ["windows-#{cpu}-msvc", 'revault_api.dll']
20
+ else raise "unsupported reVault operating system: #{RbConfig::CONFIG['host_os']}"
21
+ end
22
+ bundled = File.expand_path("../../native/#{target}/#{library}", __dir__)
23
+ return bundled if File.file?(bundled)
24
+ raise "revault-api native carrier is missing for #{target}; set REVAULT_LIBRARY for development"
25
+ end
26
+
27
+ def shim_path
28
+ return ENV['REVAULT_RUBY_SHIM'] unless ENV['REVAULT_RUBY_SHIM'].to_s.empty?
29
+ name = case RbConfig::CONFIG['host_os']
30
+ when /linux/ then 'librevault_ruby_shim.so'
31
+ when /darwin/ then 'librevault_ruby_shim.dylib'
32
+ when /mswin|mingw/ then 'revault_ruby_shim.dll'
33
+ else raise "unsupported reVault operating system: #{RbConfig::CONFIG['host_os']}"
34
+ end
35
+ bundled = File.join(File.dirname(path), name)
36
+ return bundled if File.file?(bundled)
37
+ raise "revault-api Ruby native shim is missing beside #{path}"
38
+ end
39
+ end
40
+ end