Skip to content

Commit

Permalink
Finish move
Browse files Browse the repository at this point in the history
  • Loading branch information
thedocruby committed Nov 3, 2023
1 parent 853ecfa commit 9940b3b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 17 deletions.
19 changes: 2 additions & 17 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use spirv_builder::{SpirvBuilder, MetadataPrintout};

use std::env;
use std::error::Error;
use std::path::PathBuf;
Expand All @@ -23,13 +21,13 @@ fn main() -> Result<(), Box<dyn Error>> {
&& dir.ends_with(profile)
&& dir.pop();
assert!(ok);
// NOTE(eddyb) this needs to be distinct from the `--target-dir` value that
// NOTE (eddyb) this needs to be distinct from the `--target-dir` value that
// `spirv-builder` generates in a similar way from `$OUT_DIR` and `$PROFILE`,
// otherwise repeated `cargo build`s will cause build script reruns and the
// rebuilding of `rustc_codegen_spirv` (likely due to common proc macro deps).
let dir = dir.join("gravylib-builder");
let status = std::process::Command::new("cargo")
.args([
.args([ // TODO: Find a better way to do this
"run",
"--release",
"-p",
Expand All @@ -49,18 +47,5 @@ fn main() -> Result<(), Box<dyn Error>> {
}
}

// Internal shader-like dependencies, built alongside `gravylib`
SpirvBuilder::new("gravylib-helpers", "spirv-unknown-vulkan1.1")
.print_metadata(MetadataPrintout::Full)
.build()?;

// External shaders, should be built alongside the dependent crate
// Built alongside `gravylib` because it's needed for the tests/examples
// TODO: Look into a way to build this only when needed (i.e when running tests/examples)
// TODO: This is kinda boilerplate... Can we abstract this for devs with `gravylib_macros`?
SpirvBuilder::new("examples/shaders", "spirv-unknown-vulkan1.1")
.print_metadata(MetadataPrintout::Full)
.build()?;

Ok(())
}
6 changes: 6 additions & 0 deletions gravylib-builder/src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ use gravylib_builder::*;
use std::error::Error;

fn main() -> Result<(), Box<dyn Error>> {
// Internal shader-like dependencies, built alongside `gravylib`
build_shader("../gravylib-helpers")?;

// External shaders, should be built alongside the dependent crate
// Built alongside `gravylib` because it's needed for the tests/examples
// TODO: Look into a way to build this only when needed (i.e when running tests/examples)
build_shader("../examples/shaders")?;

Ok(())
}
1 change: 1 addition & 0 deletions gravylib-builder/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use std::error::Error;
// use std::fs;
use std::path::Path;

// TODO: Find a way to make this part of the public API (look into Path/PathBuf spec, and how to use it with `gravylib-macros``)
pub fn build_shader(path_to_crate: &str, /*codegen_names: bool*/) -> Result<(), Box<dyn Error>> {
let builder_dir = &Path::new(env!("CARGO_MANIFEST_DIR"));
let path_to_crate = builder_dir.join(path_to_crate);
Expand Down

0 comments on commit 9940b3b

Please sign in to comment.