pub struct Shadow {
pub f: File,
pub map: BTreeMap<ShadowConst, ConstVal>,
pub std_env: BTreeMap<String, String>,
pub deny_const: BTreeSet<ShadowConst>,
pub out_path: String,
pub build_pattern: BuildPattern,
}Expand description
shadow-rs configuration.
This struct encapsulates the configuration for the shadow-rs build process. It allows for fine-grained control over
various aspects of the build, including file output, build constants, environment variables, deny lists, and build patterns.
While it is possible to construct a Shadow instance manually, it is highly recommended to use the ShadowBuilder builder pattern structure
provided by shadow-rs. The builder pattern simplifies the setup process and ensures that all necessary configurations are properly set up,
allowing you to customize multiple aspects simultaneously, such as using a denylist and a hook function at the same time.
§Fields
f: The file thatshadow-rswrites build information to. This file will contain serialized build constants and other metadata.map: A map of build constant identifiers to their correspondingConstVal. These are the values that will be written into the file.std_env: A map of environment variables obtained throughstd::env::vars. These variables can influence the build process.deny_const: A set of build constant identifiers that should be excluded from the build process. This can be populated viaShadowBuilder::deny_const.out_path: The path where the generated files will be placed. This is usually derived from theOUT_DIRenvironment variable but can be customized viaShadowBuilder::out_path.build_pattern: Determines the strategy for triggering package rebuilds (Lazy,RealTime, orCustom). This affects when Cargo will rerun the build script and can be configured viaShadowBuilder::build_pattern.
§Example
use std::collections::BTreeSet;
use shadow_rs::{ShadowBuilder, BuildPattern, CARGO_TREE, CARGO_METADATA};
ShadowBuilder::builder()
.build_pattern(BuildPattern::RealTime)
.deny_const(BTreeSet::from([CARGO_TREE, CARGO_METADATA]))
.build().unwrap();Fields§
§f: FileThe file that shadow-rs writes build information to.
This file will contain all the necessary information about the build, including serialized build constants and other metadata.
map: BTreeMap<ShadowConst, ConstVal>The values of build constants to be written.
This is a mapping from ShadowConst identifiers to their corresponding ConstVal objects. Each entry in this map represents a build constant that will be included in the final build.
std_env: BTreeMap<String, String>Build environment variables, obtained through std::env::vars.
These environment variables can affect the build process and are captured here for consistency and reproducibility.
deny_const: BTreeSet<ShadowConst>Constants in the deny list, passed through ShadowBuilder::deny_const.
This set contains build constant identifiers that should be excluded from the build process. By specifying these, you can prevent certain constants from being written into the build file.
out_path: StringThe output path where generated files will be placed.
This specifies the directory where the build script will write its output. It’s typically set using the OUT_DIR environment variable but can be customized using ShadowBuilder::out_path.
build_pattern: BuildPatternDetermines the strategy for triggering package rebuilds.
This field sets the pattern for how often the package should be rebuilt. Options include Lazy, RealTime, and Custom, each with its own implications on the build frequency and conditions under which a rebuild is triggered.
It can be configured using ShadowBuilder::build_pattern.