diff --git a/rspirv-linker/src/lib.rs b/rspirv-linker/src/lib.rs index 047ffda419..0f19a4e231 100644 --- a/rspirv-linker/src/lib.rs +++ b/rspirv-linker/src/lib.rs @@ -24,9 +24,9 @@ pub enum LinkerError { Unknown, } -type Result = std::result::Result; +pub type Result = std::result::Result; -fn load(bytes: &[u8]) -> rspirv::dr::Module { +pub fn load(bytes: &[u8]) -> rspirv::dr::Module { let mut loader = rspirv::dr::Loader::new(); rspirv::binary::parse_bytes(&bytes, &mut loader).unwrap(); let module = loader.module(); @@ -838,21 +838,3 @@ pub fn link(inputs: &mut [&mut rspirv::dr::Module], opts: &Options) -> Result Result<()> { - let body1 = include_bytes!("../test/1/body_1.spv"); - let body2 = include_bytes!("../test/1/body_2.spv"); - - let mut body1 = load(&body1[..]); - let mut body2 = load(&body2[..]); - - let opts = Options { - lib: false, - partial: false, - }; - - let output = link(&mut [&mut body1, &mut body2], &opts)?; - println!("{}\n\n", output.disassemble()); - - Ok(()) -} diff --git a/rspirv-linker/src/main.rs b/rspirv-linker/src/main.rs new file mode 100644 index 0000000000..c3afe8dcc5 --- /dev/null +++ b/rspirv-linker/src/main.rs @@ -0,0 +1,20 @@ +use rspirv_linker::*; +use rspirv::binary::Disassemble; + +fn main() -> Result<()> { + let body1 = include_bytes!("../test/1/body_1.spv"); + let body2 = include_bytes!("../test/1/body_2.spv"); + + let mut body1 = crate::load(&body1[..]); + let mut body2 = crate::load(&body2[..]); + + let opts = Options { + lib: false, + partial: false, + }; + + let output = link(&mut [&mut body1, &mut body2], &opts)?; + println!("{}\n\n", output.disassemble()); + + Ok(()) +}