Skip to content

Commit

Permalink
build: remove fs_extra
Browse files Browse the repository at this point in the history
  • Loading branch information
Snowiiii committed Jul 27, 2024
1 parent cb5218a commit a50e437
Show file tree
Hide file tree
Showing 13 changed files with 50 additions and 34 deletions.
8 changes: 0 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion crates/vent-assets/src/model/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
1 change: 0 additions & 1 deletion crates/vent-assets/src/model/optimizer.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use vent_rendering::vertex::Vertex3D;


#[allow(dead_code)]
pub fn optimize_vertices(_vertices: Vec<Vertex3D>) -> Vec<Vertex3D> {
Vec::new()
Expand Down
4 changes: 1 addition & 3 deletions crates/vent-rendering/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
use std::{
os::raw::c_void,
};
use std::os::raw::c_void;

use ash::vk;
use buffer::VulkanBuffer;
Expand Down
4 changes: 0 additions & 4 deletions crates/vent-runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
22 changes: 17 additions & 5 deletions crates/vent-runtime/build.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -15,15 +12,30 @@ 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, &copy_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");
compile_shaders(&get_shader_source_dir_path());
}
}

fn copy_dir_all(src: impl AsRef<Path>, dst: impl AsRef<Path>) -> 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::<bool>().unwrap_or(false))
Expand Down
4 changes: 3 additions & 1 deletion crates/vent-runtime/src/render/d3/light_renderer.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down
3 changes: 2 additions & 1 deletion crates/vent-runtime/src/render/d3/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down
7 changes: 6 additions & 1 deletion crates/vent-runtime/src/render/d3/skybox_renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
2 changes: 0 additions & 2 deletions crates/vent-ui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,3 @@ ab_glyph = { version = "0.2.28" }
# cosmic-text = "0.12"
image = "0.25"

[build-dependencies]
fs_extra = "1.3.0"
22 changes: 17 additions & 5 deletions crates/vent-ui/build.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -15,15 +12,30 @@ 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, &copy_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");
compile_shaders(&get_shader_source_dir_path());
}
}

fn copy_dir_all(src: impl AsRef<Path>, dst: impl AsRef<Path>) -> 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::<bool>().unwrap_or(false))
Expand Down
1 change: 0 additions & 1 deletion crates/vent-ui/src/font/ab_glyph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion crates/vent-ui/src/font/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit a50e437

Please sign in to comment.