Ruby support #1
					 4 changed files with 20 additions and 10 deletions
				
			
		|  | @ -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"] |  | ||||||
|  | @ -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" | 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" | repository = "https://github.com/jarkonik/bevy_scriptum" | ||||||
| keywords = ["bevy", "rhai", "scripting", "game", "gamedev"] | keywords = ["bevy", "rhai", "scripting", "game", "gamedev"] | ||||||
|  | links = "lz" # TODO: conditional, probably will need a crate for ruby | ||||||
| 
 | 
 | ||||||
| [features] | [features] | ||||||
| lua = ["dep:mlua", "mlua/luajit"] | lua = ["dep:mlua", "mlua/luajit"] | ||||||
|  | @ -33,6 +34,7 @@ mlua = { version = "0.9.8", features = [ | ||||||
| ], optional = true } | ], optional = true } | ||||||
| magnus = { version = "0.7.1", optional = true } | magnus = { version = "0.7.1", optional = true } | ||||||
| rb-sys = { version = "*", default-features = false, features = ["link-ruby", "ruby-static"], 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" | crossbeam-channel = "0.5.15" | ||||||
| 
 | 
 | ||||||
| [[example]] | [[example]] | ||||||
|  |  | ||||||
							
								
								
									
										10
									
								
								build.rs
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								build.rs
									
									
									
									
									
								
							|  | @ -1,6 +1,8 @@ | ||||||
| use std::{env, path::PathBuf, process::Command}; |  | ||||||
| 
 |  | ||||||
| fn main() { | fn main() { | ||||||
|     println!("cargo:rustc-link-arg=-rdynamic"); |     #[cfg(feature = "ruby")] | ||||||
|     println!("cargo:rustc-link-lib=z"); // TODO: if features Ruby
 |     { | ||||||
|  |         println!("cargo:rustc-link-arg=-rdynamic"); | ||||||
|  |         println!("cargo:rustc-link-arg=-lz"); | ||||||
|  |         println!("cargo:rustc-link-lib=z"); | ||||||
|  |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -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); |     scripting_tests!(RubyRuntime, "ruby", "rb", BevyEntity, BevyVec3); | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue