fix
This commit is contained in:
parent
07331f8d48
commit
553abeb0c3
2 changed files with 9 additions and 7 deletions
1
build.rs
1
build.rs
|
|
@ -1,5 +1,6 @@
|
||||||
use std::{env, path::PathBuf, process::Command};
|
use std::{env, path::PathBuf, process::Command};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
println!("cargo:rustc-link-arg=-rdynamic");
|
||||||
println!("cargo:rustc-link-lib=z"); // TODO: if features Ruby
|
println!("cargo:rustc-link-lib=z"); // TODO: if features Ruby
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -72,17 +72,18 @@ impl RubyThread {
|
||||||
let (sender, receiver) = crossbeam_channel::unbounded::<Box<dyn FnOnce(Ruby) + Send>>();
|
let (sender, receiver) = crossbeam_channel::unbounded::<Box<dyn FnOnce(Ruby) + Send>>();
|
||||||
|
|
||||||
let handle = thread::spawn(move || {
|
let handle = thread::spawn(move || {
|
||||||
let argc: i32 = 0;
|
let argc: i32 = 3;
|
||||||
let argv = vec![CString::new("ruby").unwrap(), CString::new("-e").unwrap()];
|
let mut argv = vec![
|
||||||
let mut argv = argv
|
CString::new("ruby").unwrap().into_raw(),
|
||||||
.iter()
|
CString::new("-e").unwrap().into_raw(),
|
||||||
.map(|cs| cs.as_ptr() as *mut _)
|
CString::new("").unwrap().into_raw(),
|
||||||
.collect::<Vec<_>>();
|
];
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
let mut variable_in_this_stack_frame: VALUE = 0;
|
let mut variable_in_this_stack_frame: VALUE = 0;
|
||||||
ruby_init_stack(&mut variable_in_this_stack_frame as *mut VALUE as *mut _);
|
ruby_init_stack(&mut variable_in_this_stack_frame as *mut VALUE as *mut _);
|
||||||
rb_sys::ruby_init();
|
rb_sys::ruby_init();
|
||||||
|
rb_sys::ruby_init_loadpath();
|
||||||
rb_sys::ruby_options(argc, argv.as_mut_ptr());
|
rb_sys::ruby_options(argc, argv.as_mut_ptr());
|
||||||
};
|
};
|
||||||
while let Ok(f) = receiver.recv() {
|
while let Ok(f) = receiver.recv() {
|
||||||
|
|
@ -90,7 +91,7 @@ impl RubyThread {
|
||||||
f(ruby);
|
f(ruby);
|
||||||
}
|
}
|
||||||
unsafe {
|
unsafe {
|
||||||
ruby_finalize();
|
rb_sys::ruby_finalize();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue