tirbofish/dropbear · diff
need to build fat jar
jarvis, run github actions
Signature present but could not be verified.
Unverified
@@ -44,10 +44,10 @@ Then run this to build the project git clone git@github.com:4tkbytes/dropbear cd dropbear +# eucalyptus-editor requires dropbear-1.0-SNAPSHOT-all.jar to be built first +./gradlew build # this will build all the projects in the workspace cargo build -# ensure that rust is built before gradlew as rust produces a cdylib which gradlew needs to link to -./gradlew build ``` [//]: # (# ensure submodules are checked-out) @@ -57,7 +57,9 @@ cargo build [//]: # (git submodule update) > [!TIP] -> It is recommended to use IntelliJ IDEA with the Rust plugin to help contribute to the engine. If you are a normal joe, +> It is recommended to use IntelliJ IDEA with the Rust plugin to help contribute to the engine. +> +> If you are a normal joe, > then just use the standard IntelliJ IDEA. ### Prebuilt @@ -46,14 +46,21 @@ pub struct ScriptManager { impl ScriptManager { pub fn new() -> anyhow::Result<Self> { - Ok(Self { + let mut result = Self { jvm: None, library: None, script_target: Default::default(), entity_tag_database: HashMap::new(), jvm_created: false, lib_path: None, - }) + }; + + let jvm = JavaContext::new()?; + result.jvm = Some(jvm); + result.jvm_created = true; + log::debug!("Created new JVM instance"); + + Ok(result) } pub fn init_script( @@ -69,7 +76,7 @@ impl ScriptManager { self.lib_path = Some(library_path.clone()); if !self.jvm_created { - let jvm = JavaContext::new(library_path)?; + let jvm = JavaContext::new()?; self.jvm = Some(jvm); self.jvm_created = true; log::debug!("Created new JVM instance"); @@ -102,23 +109,25 @@ impl ScriptManager { pub fn load_script( &mut self, world: WorldPtr, - _input_state: &InputState, ) -> anyhow::Result<()> { - if matches!(self.script_target, ScriptTarget::JVM { .. }) - && let Some(jvm) = &mut self.jvm { - jvm.init(world)?; - - for tag in self.entity_tag_database.keys() { - log::trace!("Loading systems for tag: {}", tag); - jvm.load_systems_for_tag(tag)?; + match &self.script_target { + ScriptTarget::JVM { library_path } => { + if let Some(jvm) = &mut self.jvm { + jvm.init(library_path, world)?; + for tag in self.entity_tag_database.keys() { + log::trace!("Loading systems for tag: {}", tag); + jvm.load_systems_for_tag(tag)?; + } + return Ok(()); + } + } + ScriptTarget::Native { library_path: _ } => { + return Err(anyhow::anyhow!("Native library loading not implemented yet")); + } + ScriptTarget::None => { + return Err(anyhow::anyhow!("No script target set")); } - return Ok(()); - } - - if matches!(self.script_target, ScriptTarget::Native { .. }) { - // TODO: native implementation - return Err(anyhow::anyhow!("Native library loading not implemented yet")); } Err(anyhow::anyhow!("Invalid script target configuration")) @@ -23,7 +23,8 @@ pub struct JavaContext { } impl JavaContext { - pub fn new(jar_path: impl AsRef<Path>) -> anyhow::Result<Self> { + /// Creates a new JVM instance + pub fn new() -> anyhow::Result<Self> { let root = app_dirs2::app_root(app_dirs2::AppDataType::UserData, &APP_INFO)?; let deps = root.join("dependencies"); let host_jar_filename = "dropbear-1.0-SNAPSHOT-all.jar"; @@ -45,6 +46,7 @@ impl JavaContext { "-Djava.class.path={}", host_jar_path.display() )) + .option("-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:6741") .build()?; let jvm = JavaVM::new(jvm_args)?; @@ -54,11 +56,12 @@ impl JavaContext { jvm, dropbear_engine_class: None, system_manager_instance: None, - jar_path: jar_path.as_ref().to_owned(), + jar_path: PathBuf::new(), }) } - pub fn init(&mut self, world: WorldPtr) -> anyhow::Result<()> { + pub fn init(&mut self, jar_path: impl AsRef<Path>, world: WorldPtr) -> anyhow::Result<()> { + self.jar_path = jar_path.as_ref().to_owned(); let mut env = self.jvm.attach_current_thread()?; if let Some(old_ref) = self.dropbear_engine_class.take() {