diff --git a/src/config/identifier.rs b/src/config/identifier.rs index 759217b..2f2344c 100644 --- a/src/config/identifier.rs +++ b/src/config/identifier.rs @@ -174,6 +174,10 @@ impl FromStr for ConfigIdent { } } +// The `Deserialize` implementation for `ConfigIdent` must be manually +// implemented, because it must go through validation. The `Serialize` +// implementation can be derived because `ConfigIdent` serializes as a regular +// string. impl<'de> Deserialize<'de> for ConfigIdent { fn deserialize(deserializer: D) -> Result where diff --git a/src/config/imp.rs b/src/config/imp.rs index a4208dc..d020b87 100644 --- a/src/config/imp.rs +++ b/src/config/imp.rs @@ -12,7 +12,7 @@ use std::path::Path; use thiserror::Error; use topological_sort::TopologicalSort; -use super::PackageName; +use super::{PackageName, PresetName}; /// Describes a set of packages to act upon. /// @@ -106,6 +106,10 @@ pub struct Config { /// Packages to be built and installed. #[serde(default, rename = "package")] pub packages: BTreeMap, + + /// Target configuration. + #[serde(default)] + pub target: TargetConfig, } impl Config { @@ -134,6 +138,14 @@ impl Config { } } +/// Configuration for targets, including preset configuration. +#[derive(Clone, Deserialize, Debug, Default)] +pub struct TargetConfig { + /// Preset configuration for targets. + #[serde(default, rename = "preset")] + pub presets: BTreeMap, +} + /// Errors which may be returned when parsing the server configuration. #[derive(Error, Debug)] pub enum ParseError { @@ -187,6 +199,7 @@ mod test { (pkg_a_name.clone(), pkg_a.clone()), (pkg_b_name.clone(), pkg_b.clone()), ]), + target: TargetConfig::default(), }; let mut order = cfg.packages_to_build(&TargetMap::default()).build_order(); @@ -228,6 +241,7 @@ mod test { (pkg_a_name.clone(), pkg_a.clone()), (pkg_b_name.clone(), pkg_b.clone()), ]), + target: TargetConfig::default(), }; let mut order = cfg.packages_to_build(&TargetMap::default()).build_order(); @@ -253,6 +267,7 @@ mod test { let cfg = Config { packages: BTreeMap::from([(pkg_a_name.clone(), pkg_a.clone())]), + target: TargetConfig::default(), }; let mut order = cfg.packages_to_build(&TargetMap::default()).build_order();