Skip to content

Commit

Permalink
try to link against the mise install of ruby
Browse files Browse the repository at this point in the history
  • Loading branch information
sxlijin committed Jul 23, 2024
1 parent 14edfaa commit 064f165
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions engine/language_client_ruby/ext/ruby_ffi/build.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
use std::process::Command;

pub fn main() {
// This is derived from the rustc commands that 'rake compile' runs, e.g.
//
// cargo rustc --package ruby_ffi --manifest-path /Users/sam/baml/engine/language_client_ruby/ext/ruby_ffi/Cargo.toml --target-dir /Users/sam/baml/engine/target --lib --profile release -- -C linker=clang -L native=/Users/sam/.local/share/mise/installs/ruby/3.1.6/lib -L native=/opt/homebrew/opt/gmp/lib -C link-arg=-Wl,-undefined,dynamic_lookup
//
// You need to run 'rake compile' from language_client_ruby itself to see these paths.

match Command::new("mise").args(["where", "ruby"]).output() {
Ok(output) => {
let ruby_path = String::from_utf8_lossy(&output.stdout).trim().to_string();
println!("cargo:rustc-link-search=native={}/lib", ruby_path);
}
Err(e) => {
println!(
"cargo:rustc-warning=Failed to execute 'mise where ruby': {}",
e
);
}
}

println!("cargo:rustc-link-arg=-Wl,-undefined,dynamic_lookup");
}

0 comments on commit 064f165

Please sign in to comment.