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: 2 additions & 2 deletions crates/pixi_build_discovery/src/discovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,12 +254,12 @@ impl DiscoveredBackend {
.expect("points to a file")
.to_path_buf(),
project_model: Some(project_model),
configuration: build_system.configuration.map(|config| {
configuration: build_system.config.map(|config| {
config
.deserialize_into()
.expect("Configuration dictionary needs to be serializable to JSON")
}),
target_configuration: build_system.target_configuration.map(|c| {
target_configuration: build_system.target_config.map(|c| {
c.into_iter()
.map(|(selector, config)| {
(
Expand Down
71 changes: 43 additions & 28 deletions crates/pixi_manifest/src/build_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use rattler_conda_types::NamedChannelOrUrl;

use crate::TargetSelector;
use crate::{
TomlError,
TomlError, WithWarnings,
toml::{FromTomlStr, TomlPackageBuild},
};

Expand All @@ -28,10 +28,10 @@ pub struct PackageBuild {
pub source: Option<SourceLocationSpec>,

/// Additional configuration for the build backend.
pub configuration: Option<serde_value::Value>,
pub config: Option<serde_value::Value>,

/// Target-specific configuration for different platforms
pub target_configuration: Option<IndexMap<TargetSelector, serde_value::Value>>,
pub target_config: Option<IndexMap<TargetSelector, serde_value::Value>>,
}

impl PackageBuild {
Expand All @@ -42,8 +42,8 @@ impl PackageBuild {
channels: Some(channels),
additional_dependencies: IndexMap::default(),
source: None,
configuration: None,
target_configuration: None,
config: None,
target_config: None,
}
}
}
Expand All @@ -59,7 +59,7 @@ pub struct BuildBackend {

impl PackageBuild {
/// Parses the specified string as a toml representation of a build system.
pub fn from_toml_str(source: &str) -> Result<Self, TomlError> {
pub fn from_toml_str(source: &str) -> Result<WithWarnings<Self>, TomlError> {
TomlPackageBuild::from_toml_str(source).and_then(TomlPackageBuild::into_build_system)
}
}
Expand All @@ -75,7 +75,7 @@ mod tests {
"#;

let build = PackageBuild::from_toml_str(toml).unwrap();
assert_eq!(build.backend.name.as_source(), "pixi-build-python");
assert_eq!(build.value.backend.name.as_source(), "pixi-build-python");
}

#[test]
Expand All @@ -90,9 +90,12 @@ mod tests {
"#;

let build = PackageBuild::from_toml_str(toml).unwrap();
assert_eq!(build.backend.name.as_source(), "pixi-build-rattler-build");
assert!(build.source.is_some());
assert!(!build.source.unwrap().is_git());
assert_eq!(
build.value.backend.name.as_source(),
"pixi-build-rattler-build"
);
assert!(build.value.source.is_some());
assert!(!build.value.source.unwrap().is_git());
}

#[test]
Expand All @@ -107,9 +110,12 @@ mod tests {
"#;

let build = PackageBuild::from_toml_str(toml).unwrap();
assert_eq!(build.backend.name.as_source(), "pixi-build-rattler-build");
assert!(build.source.is_some());
assert!(build.source.unwrap().is_git());
assert_eq!(
build.value.backend.name.as_source(),
"pixi-build-rattler-build"
);
assert!(build.value.source.is_some());
assert!(build.value.source.unwrap().is_git());
}

#[test]
Expand All @@ -124,9 +130,12 @@ mod tests {
"#;

let build = PackageBuild::from_toml_str(toml).unwrap();
assert_eq!(build.backend.name.as_source(), "pixi-build-rattler-build");
assert!(build.source.is_some());
assert!(!build.source.as_ref().unwrap().is_git());
assert_eq!(
build.value.backend.name.as_source(),
"pixi-build-rattler-build"
);
assert!(build.value.source.is_some());
assert!(!build.value.source.as_ref().unwrap().is_git());
}

#[test]
Expand All @@ -141,11 +150,14 @@ mod tests {
"#;

let build = PackageBuild::from_toml_str(toml).unwrap();
assert_eq!(build.backend.name.as_source(), "pixi-build-rattler-build");
assert!(build.source.is_some());
assert_eq!(
build.value.backend.name.as_source(),
"pixi-build-rattler-build"
);
assert!(build.value.source.is_some());

// Verify it's a path source and contains the relative path
if let Some(source) = &build.source {
if let Some(source) = &build.value.source {
match &source {
pixi_spec::SourceLocationSpec::Path(path_spec) => {
assert_eq!(path_spec.path.as_str(), "../other-source");
Expand All @@ -167,11 +179,14 @@ mod tests {
"#;

let build = PackageBuild::from_toml_str(toml).unwrap();
assert_eq!(build.backend.name.as_source(), "pixi-build-rattler-build");
assert!(build.source.is_some());
assert_eq!(
build.value.backend.name.as_source(),
"pixi-build-rattler-build"
);
assert!(build.value.source.is_some());

// Verify it's a path source and contains the home directory path
if let Some(source) = &build.source {
if let Some(source) = &build.value.source {
match &source {
pixi_spec::SourceLocationSpec::Path(path_spec) => {
assert_eq!(path_spec.path.as_str(), "~/my-source");
Expand All @@ -195,9 +210,9 @@ mod tests {
"#;

let build = PackageBuild::from_toml_str(toml).unwrap();
assert!(build.source.is_some());
assert!(build.value.source.is_some());

if let Some(source) = &build.source {
if let Some(source) = &build.value.source {
match &source {
pixi_spec::SourceLocationSpec::Path(path_spec) => {
// Test that the path spec can resolve relative paths correctly
Expand All @@ -224,9 +239,9 @@ mod tests {
"#;

let build = PackageBuild::from_toml_str(toml).unwrap();
assert!(build.source.is_some());
assert!(build.value.source.is_some());

if let Some(source) = &build.source {
if let Some(source) = &build.value.source {
match &source {
pixi_spec::SourceLocationSpec::Path(path_spec) => {
// Test that absolute paths are returned as-is during resolution
Expand Down Expand Up @@ -261,9 +276,9 @@ mod tests {
);

let build = PackageBuild::from_toml_str(&toml).unwrap();
assert!(build.source.is_some(), "Failed for path: {}", path);
assert!(build.value.source.is_some(), "Failed for path: {}", path);

if let Some(source) = &build.source {
if let Some(source) = &build.value.source {
match &source {
pixi_spec::SourceLocationSpec::Path(path_spec) => {
// Verify the path is preserved correctly
Expand Down
Loading
Loading