This commit is contained in:
Jaroslaw Konik 2025-05-21 07:00:00 +02:00
parent 553abeb0c3
commit 49a3ac716d
4 changed files with 20 additions and 10 deletions

View file

@ -1,6 +0,0 @@
[build]
# Without this flag, when linking static libruby, the linker removes symbols
# (such as `_rb_ext_ractor_safe`) which it thinks are dead code... but they are
# not, and they need to be included for the `embed` feature to work with static
# Ruby.
rustflags = ["-C", "link-dead-code=on", "-C", "link-arg=-lz"]

View file

@ -9,6 +9,7 @@ categories = ["game-development"]
description = "Plugin for Bevy engine that allows you to write some of your game logic in a scripting language"
repository = "https://github.com/jarkonik/bevy_scriptum"
keywords = ["bevy", "rhai", "scripting", "game", "gamedev"]
links = "lz" # TODO: conditional, probably will need a crate for ruby
[features]
lua = ["dep:mlua", "mlua/luajit"]
@ -33,6 +34,7 @@ mlua = { version = "0.9.8", features = [
], optional = true }
magnus = { version = "0.7.1", optional = true }
rb-sys = { version = "*", default-features = false, features = ["link-ruby", "ruby-static"], optional = true }
libz-sys = { version = "1.1", default-features = false, features = ["static"] }
crossbeam-channel = "0.5.15"
[[example]]

View file

@ -1,6 +1,8 @@
use std::{env, path::PathBuf, process::Command};
fn main() {
println!("cargo:rustc-link-arg=-rdynamic");
println!("cargo:rustc-link-lib=z"); // TODO: if features Ruby
#[cfg(feature = "ruby")]
{
println!("cargo:rustc-link-arg=-rdynamic");
println!("cargo:rustc-link-arg=-lz");
println!("cargo:rustc-link-lib=z");
}
}

View file

@ -676,5 +676,17 @@ mod ruby_tests {
}
}
#[test]
fn test_symbol_inspection() {
let mut app = build_test_app();
app.add_scripting::<RubyRuntime>(|_| {});
let runtime = app.world().get_resource::<RubyRuntime>().unwrap();
runtime.with_engine_thread(|engine| {
let symbol_string: String = engine.eval(":test_symbol.inspect").unwrap();
assert_eq!(symbol_string, ":test_symbol")
});
}
scripting_tests!(RubyRuntime, "ruby", "rb", BevyEntity, BevyVec3);
}