From 875876593dd14a2149b3172411f1f30bd69c852a Mon Sep 17 00:00:00 2001 From: InnocentusLime Date: Sun, 11 May 2025 18:57:14 +0300 Subject: [PATCH 1/2] general: remove release profile overrides It is generally a good practice to not have the crate override the compilation parameters and leave the configuration up to the user. --- Cargo.toml | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 77a15f4d..224d837c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -47,15 +47,4 @@ objc = { package = "objc-rs", version = "0.2" } [dev-dependencies] glam = { version = "0.24", features = ["scalar-math"] } -quad-rand = "0.1" - -[profile.release] -lto = true -panic = 'abort' -opt-level = "s" -overflow-checks = false -debug-assertions = false -incremental = false -rpath = false -codegen-units = 1 -strip = true +quad-rand = "0.1" \ No newline at end of file From ff59dd3872f611a04ee6ca4f569ef088bb0fbbe4 Mon Sep 17 00:00:00 2001 From: InnocentusLime Date: Sun, 11 May 2025 20:30:40 +0300 Subject: [PATCH 2/2] general: use standard module naming scheme --- src/graphics/{gl.rs => gl/mod.rs} | 0 src/{graphics.rs => graphics/mod.rs} | 0 src/native/{android.rs => android/mod.rs} | 0 src/native/{apple.rs => apple/mod.rs} | 4 +- .../{extensions.rs => extensions/mod.rs} | 0 .../mod.rs} | 0 src/native/{linux_x11.rs => linux_x11/mod.rs} | 0 src/{native.rs => native/mod.rs} | 242 +++++++++--------- src/native/{wasm.rs => wasm/mod.rs} | 0 src/native/{windows.rs => windows/mod.rs} | 0 10 files changed, 123 insertions(+), 123 deletions(-) rename src/graphics/{gl.rs => gl/mod.rs} (100%) rename src/{graphics.rs => graphics/mod.rs} (100%) rename src/native/{android.rs => android/mod.rs} (100%) rename src/native/{apple.rs => apple/mod.rs} (95%) rename src/native/linux_wayland/{extensions.rs => extensions/mod.rs} (100%) rename src/native/{linux_wayland.rs => linux_wayland/mod.rs} (100%) rename src/native/{linux_x11.rs => linux_x11/mod.rs} (100%) rename src/{native.rs => native/mod.rs} (95%) rename src/native/{wasm.rs => wasm/mod.rs} (100%) rename src/native/{windows.rs => windows/mod.rs} (100%) diff --git a/src/graphics/gl.rs b/src/graphics/gl/mod.rs similarity index 100% rename from src/graphics/gl.rs rename to src/graphics/gl/mod.rs diff --git a/src/graphics.rs b/src/graphics/mod.rs similarity index 100% rename from src/graphics.rs rename to src/graphics/mod.rs diff --git a/src/native/android.rs b/src/native/android/mod.rs similarity index 100% rename from src/native/android.rs rename to src/native/android/mod.rs diff --git a/src/native/apple.rs b/src/native/apple/mod.rs similarity index 95% rename from src/native/apple.rs rename to src/native/apple/mod.rs index 0e1b9b9d..2cfc4730 100644 --- a/src/native/apple.rs +++ b/src/native/apple/mod.rs @@ -1,2 +1,2 @@ -pub mod apple_util; -pub mod frameworks; +pub mod apple_util; +pub mod frameworks; diff --git a/src/native/linux_wayland/extensions.rs b/src/native/linux_wayland/extensions/mod.rs similarity index 100% rename from src/native/linux_wayland/extensions.rs rename to src/native/linux_wayland/extensions/mod.rs diff --git a/src/native/linux_wayland.rs b/src/native/linux_wayland/mod.rs similarity index 100% rename from src/native/linux_wayland.rs rename to src/native/linux_wayland/mod.rs diff --git a/src/native/linux_x11.rs b/src/native/linux_x11/mod.rs similarity index 100% rename from src/native/linux_x11.rs rename to src/native/linux_x11/mod.rs diff --git a/src/native.rs b/src/native/mod.rs similarity index 95% rename from src/native.rs rename to src/native/mod.rs index 88640a55..1847e225 100644 --- a/src/native.rs +++ b/src/native/mod.rs @@ -1,121 +1,121 @@ -#![allow(dead_code)] - -use std::sync::mpsc; - -#[derive(Default)] -pub(crate) struct DroppedFiles { - pub paths: Vec, - pub bytes: Vec>, -} -pub(crate) struct NativeDisplayData { - pub screen_width: i32, - pub screen_height: i32, - pub screen_position: (u32, u32), - pub dpi_scale: f32, - pub high_dpi: bool, - pub quit_requested: bool, - pub quit_ordered: bool, - pub native_requests: mpsc::Sender, - pub clipboard: Box, - pub dropped_files: DroppedFiles, - pub blocking_event_loop: bool, - - #[cfg(target_vendor = "apple")] - pub view: crate::native::apple::frameworks::ObjcId, - #[cfg(target_os = "ios")] - pub view_ctrl: crate::native::apple::frameworks::ObjcId, - #[cfg(target_vendor = "apple")] - pub gfx_api: crate::conf::AppleGfxApi, -} -#[cfg(target_vendor = "apple")] -unsafe impl Send for NativeDisplayData {} -#[cfg(target_vendor = "apple")] -unsafe impl Sync for NativeDisplayData {} - -impl NativeDisplayData { - pub fn new( - screen_width: i32, - screen_height: i32, - native_requests: mpsc::Sender, - clipboard: Box, - ) -> NativeDisplayData { - NativeDisplayData { - screen_width, - screen_height, - screen_position: (0, 0), - dpi_scale: 1., - high_dpi: false, - quit_requested: false, - quit_ordered: false, - native_requests, - clipboard, - dropped_files: Default::default(), - blocking_event_loop: false, - #[cfg(target_vendor = "apple")] - gfx_api: crate::conf::AppleGfxApi::OpenGl, - #[cfg(target_vendor = "apple")] - view: std::ptr::null_mut(), - #[cfg(target_os = "ios")] - view_ctrl: std::ptr::null_mut(), - } - } -} - -#[derive(Debug)] -pub(crate) enum Request { - ScheduleUpdate, - SetCursorGrab(bool), - ShowMouse(bool), - SetMouseCursor(crate::CursorIcon), - SetWindowSize { new_width: u32, new_height: u32 }, - SetWindowPosition { new_x: u32, new_y: u32 }, - SetFullscreen(bool), - ShowKeyboard(bool), -} - -pub trait Clipboard: Send + Sync { - fn get(&mut self) -> Option; - fn set(&mut self, string: &str); -} - -pub mod module; - -#[cfg(target_os = "linux")] -pub mod linux_x11; - -#[cfg(target_os = "linux")] -pub mod linux_wayland; - -#[cfg(target_os = "android")] -pub mod android; - -#[cfg(target_os = "windows")] -pub mod windows; - -#[cfg(target_os = "android")] -pub use android::*; - -#[cfg(target_arch = "wasm32")] -pub mod wasm; - -#[cfg(any(target_os = "macos", target_os = "ios"))] -pub mod apple; - -#[cfg(target_os = "macos")] -pub mod macos; - -#[cfg(target_os = "ios")] -pub mod ios; - -#[cfg(any(target_os = "android", target_os = "linux"))] -pub mod egl; - -// there is no glGetProcAddr on webgl, so its impossible to make "gl" module work -// on macos.. well, there is, but way easier to just statically link to gl -#[cfg(not(target_arch = "wasm32"))] -pub mod gl; - -#[cfg(target_arch = "wasm32")] -pub use wasm::webgl as gl; - -pub mod query_stab; +#![allow(dead_code)] + +use std::sync::mpsc; + +#[derive(Default)] +pub(crate) struct DroppedFiles { + pub paths: Vec, + pub bytes: Vec>, +} +pub(crate) struct NativeDisplayData { + pub screen_width: i32, + pub screen_height: i32, + pub screen_position: (u32, u32), + pub dpi_scale: f32, + pub high_dpi: bool, + pub quit_requested: bool, + pub quit_ordered: bool, + pub native_requests: mpsc::Sender, + pub clipboard: Box, + pub dropped_files: DroppedFiles, + pub blocking_event_loop: bool, + + #[cfg(target_vendor = "apple")] + pub view: crate::native::apple::frameworks::ObjcId, + #[cfg(target_os = "ios")] + pub view_ctrl: crate::native::apple::frameworks::ObjcId, + #[cfg(target_vendor = "apple")] + pub gfx_api: crate::conf::AppleGfxApi, +} +#[cfg(target_vendor = "apple")] +unsafe impl Send for NativeDisplayData {} +#[cfg(target_vendor = "apple")] +unsafe impl Sync for NativeDisplayData {} + +impl NativeDisplayData { + pub fn new( + screen_width: i32, + screen_height: i32, + native_requests: mpsc::Sender, + clipboard: Box, + ) -> NativeDisplayData { + NativeDisplayData { + screen_width, + screen_height, + screen_position: (0, 0), + dpi_scale: 1., + high_dpi: false, + quit_requested: false, + quit_ordered: false, + native_requests, + clipboard, + dropped_files: Default::default(), + blocking_event_loop: false, + #[cfg(target_vendor = "apple")] + gfx_api: crate::conf::AppleGfxApi::OpenGl, + #[cfg(target_vendor = "apple")] + view: std::ptr::null_mut(), + #[cfg(target_os = "ios")] + view_ctrl: std::ptr::null_mut(), + } + } +} + +#[derive(Debug)] +pub(crate) enum Request { + ScheduleUpdate, + SetCursorGrab(bool), + ShowMouse(bool), + SetMouseCursor(crate::CursorIcon), + SetWindowSize { new_width: u32, new_height: u32 }, + SetWindowPosition { new_x: u32, new_y: u32 }, + SetFullscreen(bool), + ShowKeyboard(bool), +} + +pub trait Clipboard: Send + Sync { + fn get(&mut self) -> Option; + fn set(&mut self, string: &str); +} + +pub mod module; + +#[cfg(target_os = "linux")] +pub mod linux_x11; + +#[cfg(target_os = "linux")] +pub mod linux_wayland; + +#[cfg(target_os = "android")] +pub mod android; + +#[cfg(target_os = "windows")] +pub mod windows; + +#[cfg(target_os = "android")] +pub use android::*; + +#[cfg(target_arch = "wasm32")] +pub mod wasm; + +#[cfg(any(target_os = "macos", target_os = "ios"))] +pub mod apple; + +#[cfg(target_os = "macos")] +pub mod macos; + +#[cfg(target_os = "ios")] +pub mod ios; + +#[cfg(any(target_os = "android", target_os = "linux"))] +pub mod egl; + +// there is no glGetProcAddr on webgl, so its impossible to make "gl" module work +// on macos.. well, there is, but way easier to just statically link to gl +#[cfg(not(target_arch = "wasm32"))] +pub mod gl; + +#[cfg(target_arch = "wasm32")] +pub use wasm::webgl as gl; + +pub mod query_stab; \ No newline at end of file diff --git a/src/native/wasm.rs b/src/native/wasm/mod.rs similarity index 100% rename from src/native/wasm.rs rename to src/native/wasm/mod.rs diff --git a/src/native/windows.rs b/src/native/windows/mod.rs similarity index 100% rename from src/native/windows.rs rename to src/native/windows/mod.rs