kitgit

tirbofish/dropbear · diff

cd2f70c · tk

updated actions and stuff

Unverified

diff --git a/.github/workflows/build_fatty.yaml b/.github/workflows/build_fatty.yaml
index c6f126d..730147a 100644
--- a/.github/workflows/build_fatty.yaml
+++ b/.github/workflows/build_fatty.yaml
@@ -25,11 +25,11 @@ jobs:
         run: chmod +x gradlew
 
       - name: Build with Gradle
-        run: ./gradlew build
+        run: ./gradlew build fatJar
 
       - name: Upload JAR artifact
         uses: actions/upload-artifact@v4
         with:
           name: application-jar
-          path: build/libs/*.jar
+          path: build/libs/*-all.jar
           retention-days: 30
\ No newline at end of file
diff --git a/.github/workflows/create_executable.yaml b/.github/workflows/create_executable.yaml
index 1433fc0..e21aa06 100644
--- a/.github/workflows/create_executable.yaml
+++ b/.github/workflows/create_executable.yaml
@@ -2,8 +2,8 @@ name: Build Executables
 
 on:
   push:
-    branches: 
-    - '**'
+    branches:
+      - '**'
   pull_request: {}
 
 jobs:
@@ -34,10 +34,28 @@ jobs:
         with:
           submodules: 'recursive'
 
+      - name: Set up JDK 21
+        uses: actions/setup-java@v4
+        with:
+          java-version: '21'
+          distribution: 'temurin'
+
+      - name: Setup Gradle
+        uses: gradle/actions/setup-gradle@v4
+        with:
+          gradle-version: 'wrapper'
+
+      - name: Make Gradlew Executable (Unix-like systems)
+        if: matrix.os != 'windows-latest'
+        run: chmod +x gradlew
+
+      - name: Build Host Library JAR (fatJar)
+        run: ./gradlew fatJar
+
       - name: Install Dependencies (Windows)
         if: matrix.os == 'windows-latest'
         run: choco install nasm -y
-        
+
       - name: Install Dependencies (Linux)
         if: matrix.os == 'ubuntu-latest'
         run: sudo apt-get update && sudo apt-get install -y nasm
@@ -81,10 +99,7 @@ jobs:
         env:
           AWS_LC_SYS_PREBUILT_NASM: ${{ env.AWS_LC_SYS_PREBUILT_NASM }}
         run: cargo build --release --package eucalyptus-editor --target ${{ matrix.target }}
-      
-      # - name: Build redback-runtime
-      #   run: cargo build --release --package redback-runtime --target ${{ matrix.target }}
-      
+
       - name: Prepare artifact
         run: |
           mkdir dist
@@ -105,4 +120,4 @@ jobs:
         uses: actions/upload-artifact@v4
         with:
           name: executables-${{ matrix.os_name }}
-          path: dist/
+          path: dist/
\ No newline at end of file
diff --git a/build.gradle.kts b/build.gradle.kts
index 639a8a0..0b7a94f 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -115,10 +115,6 @@ kotlin {
             compileTaskProvider.configure {
                 compilerOptions {
                     freeCompilerArgs.add("-Xexpect-actual-classes")
-                    // reminding kotlin that this is a library and not an executable
-                    freeCompilerArgs.add("-Xsuppress-warning=UNUSED_PARAMETER")
-                    freeCompilerArgs.add("-Xsuppress-warning=UNUSED_VARIABLE")
-                    freeCompilerArgs.add("-Xsuppress-warning=UNUSED_PRIVATE_MEMBER")
                 }
             }
         }
diff --git a/eucalyptus-core/src/scripting/jni.rs b/eucalyptus-core/src/scripting/jni.rs
index a6dd9b1..4e80bcf 100644
--- a/eucalyptus-core/src/scripting/jni.rs
+++ b/eucalyptus-core/src/scripting/jni.rs
@@ -1,9 +1,6 @@
 #![allow(non_snake_case)]
 //! Deals with the Java Native Interface (JNI) with the help of the [`jni`] crate
 
-pub mod hotreload;
-
-use std::fs::ReadDir;
 use dropbear_engine::entity::AdoptedEntity;
 use hecs::World;
 use jni::objects::{GlobalRef, JClass, JString, JValue};
@@ -12,7 +9,7 @@ use jni::sys::jobject;
 use jni::{InitArgsBuilder, JNIEnv, JNIVersion, JavaVM};
 use std::path::{Path, PathBuf};
 use crate::APP_INFO;
-use crate::logging::{LogLevel, LOG_LEVEL};
+use crate::logging::{LOG_LEVEL};
 use crate::ptr::WorldPtr;
 
 const LIBRARY_PATH: &[u8] = include_bytes!("../../../build/libs/dropbear-1.0-SNAPSHOT-all.jar");
@@ -33,8 +30,14 @@ impl JavaContext {
         let host_jar_path = deps.join(host_jar_filename);
 
         std::fs::create_dir_all(&deps)?;
-        std::fs::write(&host_jar_path, LIBRARY_PATH)?;
-        log::info!("Host library JAR written to {:?}", host_jar_path);
+
+        if !host_jar_path.exists() {
+            log::info!("Host library JAR not found at {:?}, writing embedded JAR.", host_jar_path);
+            std::fs::write(&host_jar_path, LIBRARY_PATH)?;
+            log::info!("Host library JAR written to {:?}", host_jar_path);
+        } else {
+            log::debug!("Host library JAR found at {:?}", host_jar_path);
+        }
 
         let jvm_args = InitArgsBuilder::new()
             .version(JNIVersion::V8)
diff --git a/eucalyptus-core/src/scripting/jni/hotreload.rs b/eucalyptus-core/src/scripting/jni/hotreload.rs
deleted file mode 100644
index 0a9b882..0000000
--- a/eucalyptus-core/src/scripting/jni/hotreload.rs
+++ /dev/null
@@ -1,202 +0,0 @@
-use std::path::Path;
-use crossbeam_channel::Sender;
-use tokio::io::{AsyncBufReadExt, BufReader};
-use tokio::process::Command;
-use tokio::task::JoinHandle;
-use tokio_util::sync::CancellationToken;
-use crate::scripting::get_gradle_command;
-
-pub enum HotReloadEvent {
-    SuccessBuild,
-    FailedBuild(String),
-}
-
-pub struct HotReloader {
-    cancellation_token: CancellationToken,
-    handle: Option<JoinHandle<()>>,
-}
-
-impl HotReloader {
-    pub fn new() -> Self {
-        Self {
-            cancellation_token: CancellationToken::new(),
-            handle: None,
-        }
-    }
-
-    pub fn start(
-        &mut self,
-        project_root: impl AsRef<Path>,
-        sender: Sender<HotReloadEvent>,
-    ) {
-        if self.is_running() {
-            self.stop();
-        }
-
-        let project_root = project_root.as_ref().to_path_buf();
-        let token = self.cancellation_token.clone();
-
-        let handle = tokio::spawn(async move {
-            let gradle_cmd = get_gradle_command(project_root.clone());
-
-            loop {
-                if token.is_cancelled() {
-                    log::info!("Hot reloader cancelled, stopping...");
-                    break;
-                }
-
-                let mut child = match Command::new(&gradle_cmd)
-                    .current_dir(&project_root)
-                    .args(["--continuous", "--console=plain", "jvmJar"])
-                    .stdout(std::process::Stdio::piped())
-                    .stderr(std::process::Stdio::piped())
-                    .kill_on_drop(true)
-                    .spawn()
-                {
-                    Ok(child) => child,
-                    Err(e) => {
-                        log::error!("Failed to start continuous build: {}", e);
-
-                        tokio::select! {
-                            _ = token.cancelled() => break,
-                            _ = tokio::time::sleep(tokio::time::Duration::from_secs(5)) => continue,
-                        }
-                    }
-                };
-
-                let stdout = child.stdout.take().expect("Stdout was piped");
-                let stderr = child.stderr.take().expect("Stderr was piped");
-
-                let stdout_handle = tokio::spawn({
-                    let sender = sender.clone();
-                    let token = token.clone();
-
-                    async move {
-                        let mut reader = BufReader::new(stdout).lines();
-
-                        loop {
-                            tokio::select! {
-                                _ = token.cancelled() => {
-                                    log::debug!("Stdout reader cancelled");
-                                    break;
-                                }
-                                result = reader.next_line() => {
-                                    match result {
-                                        Ok(Some(line)) => {
-                                            log::debug!("[Gradle] {}", line);
-
-                                            if line.contains("BUILD SUCCESSFUL") {
-                                                log::info!("Build completed, triggering hot-reload...");
-                                                let _ = sender.send(HotReloadEvent::SuccessBuild);
-                                            } else if line.contains("BUILD FAILED") {
-                                                log::error!("Build failed, waiting for next change...");
-                                                let _ = sender.send(HotReloadEvent::FailedBuild(line.clone()));
-                                            }
-                                        }
-                                        Ok(None) => break, // EOF
-                                        Err(e) => {
-                                            log::error!("Error reading stdout: {}", e);
-                                            break;
-                                        }
-                                    }
-                                }
-                            }
-                        }
-                    }
-                });
-
-                let stderr_handle = tokio::spawn({
-                    let token = token.clone();
-
-                    async move {
-                        let mut reader = BufReader::new(stderr).lines();
-
-                        loop {
-                            tokio::select! {
-                                _ = token.cancelled() => {
-                                    log::debug!("Stderr reader cancelled");
-                                    break;
-                                }
-                                result = reader.next_line() => {
-                                    match result {
-                                        Ok(Some(line)) => {
-                                            log::warn!("[Gradle Error] {}", line);
-                                        }
-                                        Ok(None) => break, // EOF
-                                        Err(e) => {
-                                            log::error!("Error reading stderr: {}", e);
-                                            break;
-                                        }
-                                    }
-                                }
-                            }
-                        }
-                    }
-                });
-
-                tokio::select! {
-                    _ = token.cancelled() => {
-                        log::info!("Hot reloader cancelled, cleaning up...");
-                        let _ = child.kill().await;
-
-                        tokio::time::sleep(tokio::time::Duration::from_millis(100)).await;
-
-                        stdout_handle.abort();
-                        stderr_handle.abort();
-                        let _ = tokio::join!(stdout_handle, stderr_handle);
-                        break;
-                    }
-                    status = child.wait() => {
-                        match status {
-                            Ok(exit_status) => {
-                                log::warn!("Gradle process exited with status: {}, restarting...", exit_status);
-                            }
-                            Err(e) => {
-                                log::error!("Error waiting for gradle process: {}", e);
-                            }
-                        }
-                        let _ = tokio::join!(stdout_handle, stderr_handle);
-                    }
-                }
-
-                tokio::select! {
-                    _ = token.cancelled() => break,
-                    _ = tokio::time::sleep(tokio::time::Duration::from_secs(2)) => {}
-                }
-            }
-
-            log::info!("Hot reloader task finished");
-        });
-
-        self.handle = Some(handle);
-    }
-
-    pub fn stop(&mut self) {
-        log::info!("Stopping hot reloader...");
-
-        self.cancellation_token.cancel();
-
-        if let Some(handle) = self.handle.take() {
-            handle.abort();
-        }
-
-        self.cancellation_token = CancellationToken::new();
-    }
-
-    pub fn is_running(&self) -> bool {
-        self.handle.as_ref().map_or(false, |h| !h.is_finished())
-            && !self.cancellation_token.is_cancelled()
-    }
-}
-
-impl Default for HotReloader {
-    fn default() -> Self {
-        Self::new()
-    }
-}
-
-impl Drop for HotReloader {
-    fn drop(&mut self) {
-        self.stop();
-    }
-}
\ No newline at end of file
diff --git a/eucalyptus-editor/src/editor/mod.rs b/eucalyptus-editor/src/editor/mod.rs
index d155860..9e040ac 100644
--- a/eucalyptus-editor/src/editor/mod.rs
+++ b/eucalyptus-editor/src/editor/mod.rs
@@ -47,7 +47,6 @@ use tokio::sync::oneshot;
 use transform_gizmo_egui::{EnumSet, Gizmo, GizmoMode};
 use wgpu::{Color, Extent3d, RenderPipeline};
 use winit::{keyboard::KeyCode, window::Window};
-use eucalyptus_core::scripting::jni::hotreload::{HotReloadEvent, HotReloader};
 
 pub struct Editor {
     scene_command: SceneCommand,
@@ -110,11 +109,6 @@ pub struct Editor {
     pub last_build_error: Option<String>,
     pub show_build_error_window: bool,
 
-    // hot reloading
-    pub hot_reloader: HotReloader,
-    pub hot_reload_rx: Option<Receiver<HotReloadEvent>>,
-
-
     dock_state_shared: Option<Arc<Mutex<DockState<EditorTab>>>>,
 }
 
@@ -198,8 +192,6 @@ impl Editor {
             show_build_window: false,
             last_build_error: None,
             show_build_error_window: false,
-            hot_reloader: HotReloader::new(),
-            hot_reload_rx: None,
             dock_state_shared: None,
         })
     }
diff --git a/eucalyptus-editor/src/editor/scene.rs b/eucalyptus-editor/src/editor/scene.rs
index 29750bb..4be71e3 100644
--- a/eucalyptus-editor/src/editor/scene.rs
+++ b/eucalyptus-editor/src/editor/scene.rs
@@ -112,32 +112,6 @@ impl Scene for Editor {
                 self.signal = Signal::StopPlaying;
             }
 
-            if let Some(rx) = &self.hot_reload_rx {
-                match rx.try_recv() {
-                    Ok(val) => {
-                        match val {
-                            HotReloadEvent::SuccessBuild => {
-                                let world_ptr = self.world.as_mut() as *mut World;
-                                match self.script_manager.reload(world_ptr) {
-                                    Ok(_) => {
-                                        log::info!("Reloaded script");
-                                    }
-                                    Err(e) => {
-                                        log::error!("Failed to reload script: {}", e);   
-                                    }
-                                }
-                            }
-                            HotReloadEvent::FailedBuild(e) => {
-                                log_once::warn_once!("Failed to build: {}", e);
-                            }
-                        }
-                    }
-                    Err(e) => {
-                        log_once::warn_once!("Failed to receive hot reload signal: {}", e);
-                    }
-                }
-            }
-
             let world_ptr = self.world.as_mut() as *mut World;
 
             if let Err(e) = self.script_manager.update_script(