Skip to content

Commit

Permalink
shaders: Fix dependency on shader directory. (#570)
Browse files Browse the repository at this point in the history
The dependency on the `shader` directory was incorrect (wrong path), so
cargo was rebuilding this library on every invocation of `cargo build`.

Also moved it earlier just to separate it out from the code that did the
build and writing of the generated `shaders.rs` file.

Fixes #569.
  • Loading branch information
waywardmonkeys authored May 7, 2024
1 parent 30562ce commit 9aee6c8
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion crates/shaders/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ fn main() {
let out_dir = env::var_os("OUT_DIR").unwrap();
let dest_path = Path::new(&out_dir).join("shaders.rs");

println!("cargo:rerun-if-changed=../../shader");

// The shaders are defined under the workspace root and not in this crate so we need to locate
// them somehow. Cargo doesn't define an environment variable that points at the root workspace
// directory. In hermetic build environments that don't support relative paths (such as Bazel)
Expand All @@ -35,7 +37,6 @@ fn main() {
write_types(&mut buf, &shaders).unwrap();
write_shaders(&mut buf, &shaders).unwrap();
std::fs::write(dest_path, &buf).unwrap();
println!("cargo:rerun-if-changed=../shader");
}

fn write_types(buf: &mut String, shaders: &[(String, ShaderInfo)]) -> Result<(), std::fmt::Error> {
Expand Down

0 comments on commit 9aee6c8

Please sign in to comment.