27 lines
978 B
Rust
27 lines
978 B
Rust
use cargo_gpu_install::install::Install;
|
|
use cargo_gpu_install::spirv_builder::{ShaderPanicStrategy, SpirvMetadata};
|
|
use std::path::PathBuf;
|
|
|
|
pub fn main() -> anyhow::Result<()> {
|
|
let manifest_dir = env!("CARGO_MANIFEST_DIR");
|
|
let crate_path = [manifest_dir, "..", "enkou-shaders"]
|
|
.iter()
|
|
.copied()
|
|
.collect::<PathBuf>();
|
|
|
|
let mut install = Install::from_shader_crate(crate_path.clone());
|
|
install.build_script = true;
|
|
install.auto_install_rust_toolchain = true;
|
|
let install = install.run()?;
|
|
|
|
let mut builder = install.to_spirv_builder(crate_path, "spirv-unknown-vulkan1.3");
|
|
builder.build_script.defaults = true;
|
|
builder.shader_panic_strategy = ShaderPanicStrategy::SilentExit;
|
|
builder.spirv_metadata = SpirvMetadata::Full;
|
|
|
|
let compile_result = builder.build()?;
|
|
let spv_path = compile_result.module.unwrap_single();
|
|
println!("cargo::rustc-env=SHADER_SPV_PATH={}", spv_path.display());
|
|
Ok(())
|
|
}
|