Skip to main content

setup_shader_crate_build

Function setup_shader_crate_build 

Source
pub fn setup_shader_crate_build()
Expand description

Standard build.rs setup that every shader crate should run.

Does three things:

  1. Emits cargo::metadata=manifest_dir=<path> so that host crates consuming this shader crate via KhalBuilder::from_dependency discover the shader sources both in-workspace and from crates.io-fetched copies.
  2. Declares the target_arch_is_gpu cfg via cargo::rustc-check-cfg so #[cfg(target_arch_is_gpu)] / #[cfg(not(target_arch_is_gpu))] don’t trip the unexpected_cfgs lint.
  3. Sets target_arch_is_gpu when compiling for any GPU target (SPIR-V, NVPTX). The host CPU build sees it unset.

Call from build.rs:

khal_std::build_script::setup_shader_crate_build();

The shader crate must list khal-std as a [build-dependencies] entry (in addition to its regular [dependencies] use).