Skip to content

Commit

Permalink
use variant config when discovering and building outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfv committed Dec 3, 2024
1 parent cf0aa74 commit f20b0a1
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 19 deletions.
28 changes: 14 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ impl Protocol for RattlerBuildBackend {
.channel_base_urls
.unwrap_or_else(|| vec![Url::from_str("https://prefix.dev/conda-forge").unwrap()]);

let discovered_outputs = rattler_build_tool.discover_outputs()?;
let discovered_outputs =
rattler_build_tool.discover_outputs(&params.variant_configuration)?;

let host_vpkgs = params
.host_platform
Expand Down Expand Up @@ -294,7 +295,8 @@ impl Protocol for RattlerBuildBackend {
params.work_directory.clone(),
);

let discovered_outputs = rattler_build_tool.discover_outputs()?;
let discovered_outputs =
rattler_build_tool.discover_outputs(&params.variant_configuration)?;

let outputs = rattler_build_tool.get_outputs(
&discovered_outputs,
Expand Down
2 changes: 2 additions & 0 deletions crates/pixi-build/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ async fn get_conda_metadata(
base_url: channel_config.channel_alias,
},
work_directory: tempdir.path().to_path_buf(),
variant_configuration: None,
})
.await
}
Expand Down Expand Up @@ -170,6 +171,7 @@ async fn build(factory: impl ProtocolFactory, manifest_path: &Path) -> miette::R
},
outputs: None,
work_directory: work_dir.path().to_path_buf(),
variant_configuration: None,
})
.await?;

Expand Down
18 changes: 15 additions & 3 deletions crates/pixi-build/src/tools.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
use std::{collections::BTreeMap, path::PathBuf};
use std::{
collections::{BTreeMap, HashMap},
path::PathBuf,
};

use chrono::Utc;
use indexmap::IndexSet;
Expand Down Expand Up @@ -83,7 +86,10 @@ impl RattlerBuild {
}

/// Discover the outputs from the recipe.
pub fn discover_outputs(&self) -> miette::Result<IndexSet<DiscoveredOutput>> {
pub fn discover_outputs(
&self,
variant_config_input: &Option<HashMap<String, Vec<String>>>,
) -> miette::Result<IndexSet<DiscoveredOutput>> {
// First find all outputs from the recipe
let outputs = find_outputs_from_src(&self.raw_recipe)?;

Expand All @@ -102,9 +108,15 @@ impl RattlerBuild {

let variant_configs = variant_configs.unwrap_or_default();

let variant_config =
let mut variant_config =
VariantConfig::from_files(&variant_configs, &self.selector_config).into_diagnostic()?;

if let Some(variant_config_input) = variant_config_input {
for (k, v) in variant_config_input.iter() {
variant_config.variants.insert(k.into(), v.clone());
}
}

variant_config
.find_variants(&outputs, &self.raw_recipe, &self.selector_config)
.into_diagnostic()
Expand Down

0 comments on commit f20b0a1

Please sign in to comment.