Skip to main content

Crate concinnity_toolchain

Crate concinnity_toolchain 

Source
Expand description

Shared build-script support for the workspace.

Besides the Metal shader precompilation in metal_shaders and the source hashing in source_hash, two responsibilities, both previously copy-pasted between the runtime crate’s build script and the editor crate’s build script (and missing entirely from the example binaries, which is why they failed to link against the runtime’s DLSS code on Windows):

  1. Resolve the rendering backend once and emit it as a single cfg (backend_metal / backend_dx / backend_vk) the source gates on.

  2. Detect the optional graphics SDKs and emit the cfgs the renderer gates on (agility_sdk_configured, ffx_sdk_bundled, xess_sdk_bundled, ngx_sdk_bundled, dxc_bundled). For a package that produces final binaries this also copies the runtime DLLs next to the .exe and links the NGX import lib; for a package that produces only an rlib and its own test binaries just the NGX link is needed. Which of the two, and where the binaries land, is read off the calling package by targets – a build script declares nothing about its own target list.

The public entry points emit cargo:: directives on stdout, which Cargo attributes to the build script of whichever package called in. That is what lets an example binary’s build script pick up the same NGX link and DLL bundling the CLI’s does, without duplicating any of this logic.

This file is the thin environment-reading layer: it snapshots everything the setup needs from the process environment into an SdkEnv and prints the directives. The probe/copy/directive logic itself lives in the sdks module, which never touches the environment or stdout.

Structs§

SlangArtifact
One program to precompile: the name the renderer looks it up by, the assembled source text, the entry point, and what slangc should emit.
SlangLibSpec
One single-source shader library to precompile to a metallib: the .slang file under the slang shader directory, the entry points linked into the library, and the #defines that select its variant. name is the key the renderer’s lookup uses (distinct from file when one source yields several variant libraries).
SlangShaders
The single-source half of the precompile: where the .slang files live, the shared declarations spliced into the ones carrying a marker, and one spec per metallib variant. Grouped because they always travel together, and because the splice table has to match the renderer’s slang_source::assemble exactly – the two produce the same text or the content-addressed cache serves one path’s bytes to the other.

Enums§

Backend
The graphics backend a build targets.

Functions§

backend_from_cargo
Resolve the backend from the Cargo-provided environment, emitting nothing. For a package that needs the backend only to pick its SDK setup and never gates its own source on one, so has no reason to carry the cfg.
emit_backend_cfg
Resolve the backend from the Cargo-provided environment and emit the rustc-cfg for it, returning the choice so the caller can branch.
emit_check_cfgs
Declare every cfg the renderer source gates on so --check-cfg does not warn. A package only needs this if its own source references one of these cfgs.
hash_sources
Hash the Rust sources under roots, and emit the rerun directives that re-run the calling build script when any of them change. Each root is either a directory tree (every .rs under it participates) or a single file.
precompile_metal_shaders
Precompile every eligible .metal under shaders_dir, plus every .slang spec in slang, into OUT_DIR and generate engine_metallibs.rs there. fragments pairs a source marker with the file under shaders_dir that replaces it, matching the substitution the renderer applies when it compiles the same shader from source. Panics if the Metal toolchain is present but a shader fails to compile: a broken shader must fail the build, not surface at renderer init.
precompile_slang_artifacts
Compile every artifact into OUT_DIR and generate generated beside it: a fn <lookup>(name: &str) -> Option<(u64, &'static [u8])> mapping each name to the digest of the source it was built from and its embedded bytes.
setup_graphics_sdks
Set up the optional graphics SDKs for the given backend. On a non-Windows target (or the Metal backend) this is a no-op: none of these SDKs apply.
watch_shader_dir
Emit a rerun directive per shader file, so an edit to any of them recompiles the artifacts rather than replaying stale bytes.