Skip to content
2 changes: 1 addition & 1 deletion crates/pixi-build-backend/src/generated_recipe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
/// options.
///
///
/// An instance of this trait is used by the [`IntermediateBackend`]

Check failure on line 33 in crates/pixi-build-backend/src/generated_recipe.rs

View workflow job for this annotation

GitHub Actions / Check intra-doc links

unresolved link to `IntermediateBackend`
/// in order to generate the recipe.
pub trait GenerateRecipe {
type Config: BackendConfig;
Expand Down Expand Up @@ -89,7 +89,7 @@
}

pub trait BackendConfig: DeserializeOwned + Clone {
/// At least debug dir should be provided by the backend config
/// Debug dir provided by the backend config
fn debug_dir(&self) -> Option<&Path>;

/// Merge this configuration with a target-specific configuration.
Expand Down
93 changes: 90 additions & 3 deletions crates/pixi-build-backend/src/intermediate_backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ use crate::{
utils::TemporaryRenderedRecipe,
};

use fs_err::tokio as tokio_fs;

#[derive(Debug, Default, Deserialize)]
#[serde(rename_all = "kebab-case")]
pub struct IntermediateBackendConfig {
Expand Down Expand Up @@ -395,6 +397,27 @@ where
},
);

let directories = output_directory(
if number_of_outputs == 1 {
OneOrMultipleOutputs::Single(discovered_output.name.clone())
} else {
OneOrMultipleOutputs::OneOfMany(discovered_output.name.clone())
},
params.work_directory.clone(),
&named_source.path,
);
// Save intermediate recipe in the debug dir
let debug_path = directories.work_dir.join("intermediate_recipe.yaml");
tokio_fs::create_dir_all(&directories.work_dir)
.await
.into_diagnostic()?;
tokio_fs::write(
&debug_path,
generated_recipe.recipe.to_yaml_pretty().into_diagnostic()?,
)
.await
.into_diagnostic()?;

let mut output = Output {
recipe,
build_configuration: BuildConfiguration {
Expand Down Expand Up @@ -727,6 +750,28 @@ where
},
);

let directories = output_directory(
if number_of_outputs == 1 {
OneOrMultipleOutputs::Single(discovered_output.name.clone())
} else {
OneOrMultipleOutputs::OneOfMany(discovered_output.name.clone())
},
params.work_directory.clone(),
&named_source.path,
);

// Save intermediate recipe in the debug dir
let debug_path = directories.work_dir.join("intermediate_recipe.yaml");
tokio_fs::create_dir_all(&directories.work_dir)
.await
.into_diagnostic()?;
tokio_fs::write(
&debug_path,
generated_recipe.recipe.to_yaml_pretty().into_diagnostic()?,
)
.await
.into_diagnostic()?;

let mut output = Output {
recipe,
build_configuration: BuildConfiguration {
Expand Down Expand Up @@ -849,7 +894,7 @@ where
let variants = BTreeMap::from_iter(itertools::chain!(recipe_variants, param_variants));

// Construct the intermediate recipe
let recipe = self.generate_recipe.generate_recipe(
let generated_recipe = self.generate_recipe.generate_recipe(
&self.project_model,
&config,
self.source_dir.clone(),
Expand All @@ -865,7 +910,13 @@ where
let recipe_path = self.source_dir.join(&self.manifest_rel_path);
let named_source = Source {
name: self.manifest_rel_path.display().to_string(),
code: Arc::from(recipe.recipe.to_yaml_pretty().into_diagnostic()?.as_str()),
code: Arc::from(
generated_recipe
.recipe
.to_yaml_pretty()
.into_diagnostic()?
.as_str(),
),
path: recipe_path.clone(),
};

Expand Down Expand Up @@ -914,6 +965,8 @@ where

let mut subpackages = HashMap::new();
let mut outputs = Vec::new();

let num_of_outputs = discovered_outputs.len();
for discovered_output in discovered_outputs {
let variant = discovered_output.used_vars;
let hash = HashInfo::from_variant(&variant, &discovered_output.noarch_type);
Expand Down Expand Up @@ -945,6 +998,28 @@ where

let build_number = recipe.build().number;

let directories = output_directory(
if num_of_outputs == 1 {
OneOrMultipleOutputs::Single(discovered_output.name.clone())
} else {
OneOrMultipleOutputs::OneOfMany(discovered_output.name.clone())
},
params.work_directory.clone(),
&named_source.path,
);

// Save intermediate recipe in the debug dir
let debug_path = directories.work_dir.join("intermediate_recipe.yaml");
tokio_fs::create_dir_all(&directories.work_dir)
.await
.into_diagnostic()?;
tokio_fs::write(
&debug_path,
generated_recipe.recipe.to_yaml_pretty().into_diagnostic()?,
)
.await
.into_diagnostic()?;

subpackages.insert(
recipe.package().name().clone(),
PackageIdentifier {
Expand Down Expand Up @@ -1055,7 +1130,7 @@ where

Ok(CondaOutputsResult {
outputs,
input_globs: recipe.metadata_input_globs,
input_globs: generated_recipe.metadata_input_globs,
})
}

Expand Down Expand Up @@ -1146,6 +1221,18 @@ where
recipe_path,
);

// Save intermediate recipe in the debug dir
let debug_path = directories.work_dir.join("intermediate_recipe.yaml");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this recipe still change? If not, why not call this recipe.yaml?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After thinking (Initially, I didn't agree with renaming), I think we can name it recipe.yaml

tokio_fs::create_dir_all(&directories.work_dir)
.await
.into_diagnostic()?;
tokio_fs::write(
&debug_path,
recipe.recipe.to_yaml_pretty().into_diagnostic()?,
)
.await
.into_diagnostic()?;

let tool_config = Configuration::builder()
.with_opt_cache_dir(self.cache_dir.clone())
.with_logging_output_handler(self.logging_output_handler.clone())
Expand Down
Loading