Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4/n] add configuration for target presets #72

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/config/identifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<D>(deserializer: D) -> Result<ConfigIdent, D::Error>
where
Expand Down
17 changes: 16 additions & 1 deletion src/config/imp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand Down Expand Up @@ -106,6 +106,10 @@ pub struct Config {
/// Packages to be built and installed.
#[serde(default, rename = "package")]
pub packages: BTreeMap<PackageName, Package>,

/// Target configuration.
#[serde(default)]
pub target: TargetConfig,
}

impl Config {
Expand Down Expand Up @@ -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<PresetName, TargetMap>,
}

/// Errors which may be returned when parsing the server configuration.
#[derive(Error, Debug)]
pub enum ParseError {
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand Down
Loading