From a50e4379f91c160628c6afeaf919b8c164e11f13 Mon Sep 17 00:00:00 2001 From: Snowiiii Date: Sun, 28 Jul 2024 00:08:12 +0200 Subject: [PATCH] build: remove fs_extra --- Cargo.lock | 8 ------- crates/vent-assets/src/model/loader.rs | 3 ++- crates/vent-assets/src/model/optimizer.rs | 1 - crates/vent-rendering/src/lib.rs | 4 +--- crates/vent-runtime/Cargo.toml | 4 ---- crates/vent-runtime/build.rs | 22 ++++++++++++++----- .../src/render/d3/light_renderer.rs | 4 +++- crates/vent-runtime/src/render/d3/mod.rs | 3 ++- .../src/render/d3/skybox_renderer.rs | 7 +++++- crates/vent-ui/Cargo.toml | 2 -- crates/vent-ui/build.rs | 22 ++++++++++++++----- crates/vent-ui/src/font/ab_glyph.rs | 1 - crates/vent-ui/src/font/mod.rs | 3 ++- 13 files changed, 50 insertions(+), 34 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e82232d..aa56642 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -672,12 +672,6 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aa9a19cbb55df58761df49b23516a86d432839add4af60fc256da840f66ed35b" -[[package]] -name = "fs_extra" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c" - [[package]] name = "getrandom" version = "0.2.15" @@ -2068,7 +2062,6 @@ dependencies = [ "ash", "chrono", "downcast-rs", - "fs_extra", "image", "log", "ndk", @@ -2095,7 +2088,6 @@ version = "0.1.0" dependencies = [ "ab_glyph", "ash", - "fs_extra", "image", "log", "vent-math", diff --git a/crates/vent-assets/src/model/loader.rs b/crates/vent-assets/src/model/loader.rs index 2a60337..eebc6a6 100644 --- a/crates/vent-assets/src/model/loader.rs +++ b/crates/vent-assets/src/model/loader.rs @@ -5,7 +5,8 @@ use ash::{ vk::{self, PipelineShaderStageCreateInfo}, }; use vent_rendering::{ - image::VulkanImage, instance::VulkanInstance, mesh::Mesh3D, vertex::Vertex3D, MaterialPipelineInfo, DEFAULT_TEXTURE_FILTER + image::VulkanImage, instance::VulkanInstance, mesh::Mesh3D, vertex::Vertex3D, + MaterialPipelineInfo, DEFAULT_TEXTURE_FILTER, }; use crate::{Material, Model3D, ModelPipeline}; diff --git a/crates/vent-assets/src/model/optimizer.rs b/crates/vent-assets/src/model/optimizer.rs index f6269da..556c711 100644 --- a/crates/vent-assets/src/model/optimizer.rs +++ b/crates/vent-assets/src/model/optimizer.rs @@ -1,6 +1,5 @@ use vent_rendering::vertex::Vertex3D; - #[allow(dead_code)] pub fn optimize_vertices(_vertices: Vec) -> Vec { Vec::new() diff --git a/crates/vent-rendering/src/lib.rs b/crates/vent-rendering/src/lib.rs index 81d7146..a9e3b42 100644 --- a/crates/vent-rendering/src/lib.rs +++ b/crates/vent-rendering/src/lib.rs @@ -1,6 +1,4 @@ -use std::{ - os::raw::c_void, -}; +use std::os::raw::c_void; use ash::vk; use buffer::VulkanBuffer; diff --git a/crates/vent-runtime/Cargo.toml b/crates/vent-runtime/Cargo.toml index c4fcc9d..535806c 100644 --- a/crates/vent-runtime/Cargo.toml +++ b/crates/vent-runtime/Cargo.toml @@ -35,7 +35,3 @@ downcast-rs = "1.2.0" android_logger = "0.14" android-activity = { version = "0.6", features = [ "game-activity" ] } ndk = "0.9.0" - - -[build-dependencies] -fs_extra = "1.3.0" diff --git a/crates/vent-runtime/build.rs b/crates/vent-runtime/build.rs index 242b387..d8547c7 100644 --- a/crates/vent-runtime/build.rs +++ b/crates/vent-runtime/build.rs @@ -1,8 +1,5 @@ use std::{env, fs::DirEntry, io::Result}; -use fs_extra::copy_items; -use fs_extra::dir::CopyOptions; - use std::{ env::var, fs, @@ -15,8 +12,7 @@ fn main() { println!("cargo:rerun-if-changed=assets/*"); let out_dir = env::var("OUT_DIR").expect("Var: OUT_DIR Not found!"); - let copy_options = CopyOptions::new().overwrite(true); - copy_items(&["assets/"], out_dir, ©_options).expect("Failed to copy to resource Folder"); + copy_dir_all("assets/", out_dir).expect("Failed to copy to resource Folder"); if !should_skip_shader_compilation() { println!("Compiling shaders"); @@ -24,6 +20,22 @@ fn main() { } } +fn copy_dir_all(src: impl AsRef, dst: impl AsRef) -> Result<()> { + let src = src.as_ref(); + let dst = dst.as_ref(); + fs::create_dir_all(dst)?; + for entry in fs::read_dir(src)? { + let entry = entry?; + let ty = entry.file_type()?; + if ty.is_dir() { + copy_dir_all(entry.path(), dst.join(entry.file_name()))?; + } else { + fs::copy(entry.path(), dst.join(entry.file_name()))?; + } + } + Ok(()) +} + fn should_skip_shader_compilation() -> bool { var("SKIP_SHADER_COMPILATION") .map(|var| var.parse::().unwrap_or(false)) diff --git a/crates/vent-runtime/src/render/d3/light_renderer.rs b/crates/vent-runtime/src/render/d3/light_renderer.rs index 396f855..de3d461 100644 --- a/crates/vent-runtime/src/render/d3/light_renderer.rs +++ b/crates/vent-runtime/src/render/d3/light_renderer.rs @@ -1,6 +1,8 @@ use ash::vk; use vent_math::vec::vec3::Vec3; -use vent_rendering::{instance::VulkanInstance, mesh::Mesh3D, pipeline::VulkanPipeline, vertex::Vertex3D}; +use vent_rendering::{ + instance::VulkanInstance, mesh::Mesh3D, pipeline::VulkanPipeline, vertex::Vertex3D, +}; #[allow(dead_code)] #[repr(C)] diff --git a/crates/vent-runtime/src/render/d3/mod.rs b/crates/vent-runtime/src/render/d3/mod.rs index 2b7c6ed..6c26dc2 100644 --- a/crates/vent-runtime/src/render/d3/mod.rs +++ b/crates/vent-runtime/src/render/d3/mod.rs @@ -10,7 +10,8 @@ use vent_math::{ vec::{vec3::Vec3, vec4::Vec4}, }; use vent_rendering::{ - any_as_u8_slice, buffer::VulkanBuffer, image::SkyBoxImages, instance::VulkanInstance, mesh::Mesh3D, vertex::VertexPos3D + any_as_u8_slice, buffer::VulkanBuffer, image::SkyBoxImages, instance::VulkanInstance, + mesh::Mesh3D, vertex::VertexPos3D, }; use super::{ diff --git a/crates/vent-runtime/src/render/d3/skybox_renderer.rs b/crates/vent-runtime/src/render/d3/skybox_renderer.rs index 57eec13..de23712 100644 --- a/crates/vent-runtime/src/render/d3/skybox_renderer.rs +++ b/crates/vent-runtime/src/render/d3/skybox_renderer.rs @@ -4,7 +4,12 @@ use ash::vk; use image::GenericImageView; use vent_math::scalar::mat4::Mat4; use vent_rendering::{ - any_as_u8_slice, image::{SkyBoxImages, VulkanImage}, instance::VulkanInstance, mesh::Mesh3D, pipeline::VulkanPipeline, vertex::VertexPos3D + any_as_u8_slice, + image::{SkyBoxImages, VulkanImage}, + instance::VulkanInstance, + mesh::Mesh3D, + pipeline::VulkanPipeline, + vertex::VertexPos3D, }; use crate::render::{camera::Camera3D, d3::create_simple_cube}; diff --git a/crates/vent-ui/Cargo.toml b/crates/vent-ui/Cargo.toml index f46497c..d8545d9 100644 --- a/crates/vent-ui/Cargo.toml +++ b/crates/vent-ui/Cargo.toml @@ -14,5 +14,3 @@ ab_glyph = { version = "0.2.28" } # cosmic-text = "0.12" image = "0.25" -[build-dependencies] -fs_extra = "1.3.0" diff --git a/crates/vent-ui/build.rs b/crates/vent-ui/build.rs index 242b387..d8547c7 100644 --- a/crates/vent-ui/build.rs +++ b/crates/vent-ui/build.rs @@ -1,8 +1,5 @@ use std::{env, fs::DirEntry, io::Result}; -use fs_extra::copy_items; -use fs_extra::dir::CopyOptions; - use std::{ env::var, fs, @@ -15,8 +12,7 @@ fn main() { println!("cargo:rerun-if-changed=assets/*"); let out_dir = env::var("OUT_DIR").expect("Var: OUT_DIR Not found!"); - let copy_options = CopyOptions::new().overwrite(true); - copy_items(&["assets/"], out_dir, ©_options).expect("Failed to copy to resource Folder"); + copy_dir_all("assets/", out_dir).expect("Failed to copy to resource Folder"); if !should_skip_shader_compilation() { println!("Compiling shaders"); @@ -24,6 +20,22 @@ fn main() { } } +fn copy_dir_all(src: impl AsRef, dst: impl AsRef) -> Result<()> { + let src = src.as_ref(); + let dst = dst.as_ref(); + fs::create_dir_all(dst)?; + for entry in fs::read_dir(src)? { + let entry = entry?; + let ty = entry.file_type()?; + if ty.is_dir() { + copy_dir_all(entry.path(), dst.join(entry.file_name()))?; + } else { + fs::copy(entry.path(), dst.join(entry.file_name()))?; + } + } + Ok(()) +} + fn should_skip_shader_compilation() -> bool { var("SKIP_SHADER_COMPILATION") .map(|var| var.parse::().unwrap_or(false)) diff --git a/crates/vent-ui/src/font/ab_glyph.rs b/crates/vent-ui/src/font/ab_glyph.rs index b3f8776..90628f4 100644 --- a/crates/vent-ui/src/font/ab_glyph.rs +++ b/crates/vent-ui/src/font/ab_glyph.rs @@ -126,7 +126,6 @@ impl AbGlyphLoader { // height: all_px_bounds.height() as u32, // }; - // TODO: No mipmaps let dimensions = image.dimensions(); let mut texture = VulkanImage::from_image(instance, DynamicImage::ImageRgba8(image), false, None, None); diff --git a/crates/vent-ui/src/font/mod.rs b/crates/vent-ui/src/font/mod.rs index 686a991..e4f9912 100644 --- a/crates/vent-ui/src/font/mod.rs +++ b/crates/vent-ui/src/font/mod.rs @@ -49,7 +49,8 @@ impl Font { let characters = &self.characters; - if !self.buffer_cache.contains_key(&text) { // Todo, Support changing colors for same text + if !self.buffer_cache.contains_key(&text) { + // Todo, Support changing colors for same text let mut batched_vertices = Vec::new(); // Loop through each character in the text let mut current_x = x;