Skip to content

Commit d56fd42

Browse files
adding macos shared object
1 parent 74319c7 commit d56fd42

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

build_ffi.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
3+
set -e # Exit immediately if any command fails
4+
5+
# Path to Rust repo
6+
RUST_REPO_DIR="../valkey-glide"
7+
RUBY_GEM_LIB_DIR="../../valkey-glide-ruby/lib/valkey"
8+
9+
echo "🔄 Updating Valkey Glide FFI..."
10+
11+
# Clone or update Rust repo
12+
if [ ! -d "$RUST_REPO_DIR" ]; then
13+
echo "📦 Cloning valkey-glide..."
14+
git clone https://github.com/valkey-io/valkey-glide.git "$RUST_REPO_DIR"
15+
else
16+
echo "📥 Pulling latest valkey-glide updates..."
17+
cd "$RUST_REPO_DIR" && git pull origin main && cd -
18+
fi
19+
20+
# Build Rust ffi
21+
echo "🔧 Building Rust FFI..."
22+
cd "$RUST_REPO_DIR/ffi"
23+
cargo build --release
24+
25+
# Copy built .so or .dylib to Ruby gem lib folder
26+
cp target/release/libglide_ffi.* "$RUBY_GEM_LIB_DIR"
27+
28+
echo "✅ Done! Copied shared library to:"
29+
ls -lh "$RUBY_GEM_LIB_DIR"/libglide_ffi.*

lib/valkey/bindings.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@ class Valkey
44
module Bindings
55
extend FFI::Library
66

7-
ffi_lib File.expand_path("./libglide_ffi.so", __dir__)
7+
ffi_lib_path = if RUBY_PLATFORM =~ /darwin/
8+
File.expand_path("./libglide_ffi.dylib", __dir__)
9+
else
10+
File.expand_path("./libglide_ffi.so", __dir__)
11+
end
12+
13+
ffi_lib ffi_lib_path
814

915
class ClientType < FFI::Struct
1016
layout(

lib/valkey/libglide_ffi.dylib

6.69 MB
Binary file not shown.

0 commit comments

Comments
 (0)