externcrateglsl_to_spirv;usestd::error::Error;fnmain()->Result<(),Box<Error>>{useglsl_to_spirv::ShaderType;// Tell the build script to only run again if we change our source shadersprintln!("cargo:rerun-if-changed=source_assets/shaders");// Create destination path if necessarystd::fs::create_dir_all("assets/gen/shaders")?;forentryinstd::fs::read_dir("source_assets/shaders")?{letentry=entry?;ifentry.file_type()?.is_file(){letin_path=entry.path();// Support only vertex and fragment shaders currentlyletshader_type=in_path.extension().and_then(|ext|{matchext.to_string_lossy().as_ref(){"vert"=>Some(ShaderType::Vertex),"frag"=>Some(ShaderType::Fragment),_=>None,}});ifletSome(shader_type)=shader_type{usestd::io::Read;letsource=std::fs::read_to_string(&in_path)?;letmutcompiled_file=glsl_to_spirv::compile(&source,shader_type)?;letmutcompiled_bytes=Vec::new();compiled_file.read_to_end(&mutcompiled_bytes)?;letout_path=format!("assets/gen/shaders/{}.spv",in_path.file_name().unwrap().to_string_lossy());std::fs::write(&out_path,&compiled_bytes)?;}}}Ok(())}