1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
//! Build-script helpers for shader crates.
//!
//! Host-only module (gated out of GPU-target builds). Intended to be called
//! from a shader crate's `build.rs` — see [`setup_shader_crate_build`].
/// 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`:
///
/// ```no_run
/// 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).