Skip to content
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: 1 addition & 3 deletions crates/pixi_build_backend/src/common/variants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@ use miette::IntoDiagnostic;
use rattler_build_jinja::Variable;
use rattler_build_types::NormalizedKey;
use rattler_build_variant_config::VariantConfig;
use rattler_conda_types::Platform;

use crate::ProjectModel;

/// Return variants for the given project model
pub fn compute_variants<P: ProjectModel>(
project_model: &P,
input_variant_configuration: Option<BTreeMap<NormalizedKey, Vec<Variable>>>,
host_platform: Platform,
) -> miette::Result<Vec<BTreeMap<NormalizedKey, Variable>>> {
// Create a variant config from the variant configuration in the parameters.
let variant_config = VariantConfig {
Expand All @@ -23,7 +21,7 @@ pub fn compute_variants<P: ProjectModel>(
};

// Determine the variant keys that are used in the recipe.
let used_variants = project_model.used_variants(Some(host_platform));
let used_variants = project_model.used_variants();

// Determine the combinations of the used variants.
variant_config
Expand Down
23 changes: 14 additions & 9 deletions crates/pixi_build_backend/src/generated_recipe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ use serde::de::DeserializeOwned;
use thiserror::Error;
use url::Url;

use crate::specs_conversion::from_targets_v1_to_conditional_requirements;
use crate::specs_conversion::{
SelectorConversionError, from_targets_v1_to_conditional_requirements,
};

#[derive(Debug, Clone, Default)]
pub struct PythonParams {
Expand Down Expand Up @@ -151,6 +153,9 @@ pub enum GenerateRecipeError<MetadataProviderError: Diagnostic + 'static> {
#[source]
MetadataProviderError,
),
#[error(transparent)]
#[diagnostic(transparent)]
InvalidSelectorExpression(#[from] SelectorConversionError),
}

#[derive(Clone)]
Expand Down Expand Up @@ -247,7 +252,7 @@ impl GeneratedRecipe {
);

let requirements =
from_targets_v1_to_conditional_requirements(&model.targets.unwrap_or_default());
from_targets_v1_to_conditional_requirements(&model.targets.unwrap_or_default())?;

macro_rules! derive_value {
($ident:ident) => {
Expand Down Expand Up @@ -373,7 +378,7 @@ impl MetadataProvider for DefaultMetadataProvider {
mod tests {
use ordermap::OrderMap;
use pixi_build_types::{
BinaryPackageSpec, PackageSpec, SourcePackageName, Target, TargetSelector, Targets,
BinaryPackageSpec, ConditionalExpression, PackageSpec, SourcePackageName, Target, Targets,
};
use rattler_conda_types::{Flag, PackageName};

Expand Down Expand Up @@ -408,7 +413,7 @@ mod tests {
extra_dependencies: Some(extras_with_gtest()),
..Target::default()
}),
targets: None,
conditional: None,
}),
..ProjectModel::default()
};
Expand All @@ -425,13 +430,13 @@ mod tests {
);
}

/// Per-target extras must be wrapped in a `Conditional` block in the
/// Conditional extras must be wrapped in a `Conditional` block in the
/// generated recipe rather than landing as a bare entry.
#[test]
fn generated_recipe_declares_per_target_extras() {
let mut platform_targets = OrderMap::new();
platform_targets.insert(
TargetSelector::Win,
let mut conditional_targets = OrderMap::new();
conditional_targets.insert(
ConditionalExpression::new("win"),
Target {
extra_dependencies: Some(extras_with_gtest()),
..Target::default()
Expand All @@ -443,7 +448,7 @@ mod tests {
version: Some("0.1.0".parse().unwrap()),
targets: Some(Targets {
default_target: None,
targets: Some(platform_targets),
conditional: Some(conditional_targets),
}),
..ProjectModel::default()
};
Expand Down
Loading
Loading