fix up the builder so that this works as a nix expression

This commit is contained in:
2022-07-05 22:58:32 -07:00
parent 5b99d30cda
commit de7da0540d
5 changed files with 111 additions and 40 deletions

View File

@@ -37,7 +37,7 @@ fn main() -> Result<(), Box<dyn Error>> {
println!("target_dir: {:?}", target_dir);
println!("manifest_path: {:?}", manifest_path);
let status = std::process::Command::new("cargo")
let output = std::process::Command::new("cargo")
.args([
"run",
"--release",
@@ -47,14 +47,11 @@ fn main() -> Result<(), Box<dyn Error>> {
.arg("--target-dir")
.arg(target_dir)
.stderr(std::process::Stdio::inherit())
.stdout(std::process::Stdio::inherit())
.status()?;
if !status.success() {
if let Some(code) = status.code() {
std::process::exit(code);
} else {
std::process::exit(1);
}
}
.output()?;
let stdout = String::from_utf8(output.stdout)?;
let mod_path = stdout.trim_end().rsplit("\n").next().expect("spirv module path");
println!("stdout: {}", stdout);
println!("cargo:rustc-env=SPIRV_MODULE_PATH={}", mod_path);
Ok(())
}

View File

@@ -3,6 +3,6 @@
pub fn spirv_module() -> &'static [u8] {
// we specifically include the bytes into this binary, for ease of packaging (v.s. attempting
// to locate the compiled result at runtime).
include_bytes!("../../../target/spirv-builder/spirv-unknown-vulkan1.1/release/deps/spirv_backend.spv.dir/module")
include_bytes!(std::env!("SPIRV_MODULE_PATH"))
}