Load an initial module
This commit is contained in:
4
src/entry/main.rs
Normal file
4
src/entry/main.rs
Normal file
@ -0,0 +1,4 @@
|
||||
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
3
src/entry/mod.rs
Normal file
3
src/entry/mod.rs
Normal file
@ -0,0 +1,3 @@
|
||||
mod main;
|
||||
pub mod parser;
|
||||
|
12
src/entry/parser.rs
Normal file
12
src/entry/parser.rs
Normal file
@ -0,0 +1,12 @@
|
||||
use anyhow::{anyhow, Result};
|
||||
|
||||
pub fn build_entrypoint(module: &str, session: &slang::Session) -> Result<String>{
|
||||
let module = session.load_module(module)?;
|
||||
let entry_point_count = module.get_defined_entry_point_count();
|
||||
|
||||
if entry_point_count != 1 {
|
||||
return Err(anyhow!("Did not have expected entry point count"));
|
||||
}
|
||||
|
||||
Ok("".to_owned())
|
||||
}
|
4
src/lib.rs
Normal file
4
src/lib.rs
Normal file
@ -0,0 +1,4 @@
|
||||
pub mod entry;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
23
src/tests/entry.rs
Normal file
23
src/tests/entry.rs
Normal file
@ -0,0 +1,23 @@
|
||||
use std::path::{PathBuf};
|
||||
|
||||
#[test]
|
||||
fn compute_hello_world() {
|
||||
let global_session = slang::GlobalSession::new().expect("Failed to create global session");
|
||||
|
||||
let target_desc = slang::TargetDescBuilder::new()
|
||||
.format(slang::CompileTarget::Spirv)
|
||||
.profile(global_session.find_profile("spirv_1_2"));
|
||||
|
||||
let search_path = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("resources/test-entry");
|
||||
if !search_path.exists() {
|
||||
return;
|
||||
}
|
||||
|
||||
let search_path_bytes = unsafe { std::mem::transmute::<_, *const i8>(search_path.as_os_str().as_encoded_bytes().as_ptr()) };
|
||||
let session_desc = slang::SessionDescBuilder::new()
|
||||
.targets(&[*target_desc])
|
||||
.search_paths(&[search_path_bytes]);
|
||||
|
||||
let session = global_session.create_session(&session_desc).expect("Failed to create session");
|
||||
let _entry = crate::entry::parser::build_entrypoint("compute_hello-world.slang", &session).expect("Failed to build entry");
|
||||
}
|
1
src/tests/mod.rs
Normal file
1
src/tests/mod.rs
Normal file
@ -0,0 +1 @@
|
||||
pub mod entry;
|
Reference in New Issue
Block a user