@@ -2,7 +2,7 @@ use std::sync::Arc;
22
33use ordermap:: OrderMap ;
44use pixi_build_types:: {
5- BinaryPackageSpecV1 , PackageSpecV1 , SourcePackageSpecV1 , TargetV1 , TargetsV1 ,
5+ BinaryPackageSpecV1 , PackageSpecV1 , SourcePackageSpecV1 , TargetSelectorV1 , TargetV1 , TargetsV1 ,
66 procedures:: conda_build_v1:: {
77 CondaBuildV1Dependency , CondaBuildV1DependencySource , CondaBuildV1Prefix ,
88 CondaBuildV1RunExports ,
@@ -36,6 +36,33 @@ pub fn from_source_matchspec_into_package_spec(
3636 . ok_or_else ( || miette:: miette!( "Only file, http/https and git are supported for now" ) )
3737}
3838
39+ #[ derive( Debug , Clone ) ]
40+ pub enum PlatformKind {
41+ Build ,
42+ Host ,
43+ Target ,
44+ }
45+
46+ impl std:: fmt:: Display for PlatformKind {
47+ fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
48+ match self {
49+ PlatformKind :: Build => write ! ( f, "build" ) ,
50+ PlatformKind :: Host => write ! ( f, "host" ) ,
51+ PlatformKind :: Target => write ! ( f, "target" ) ,
52+ }
53+ }
54+ }
55+
56+ pub fn to_rattler_build_selector (
57+ selector : & TargetSelectorV1 ,
58+ platform_kind : PlatformKind ,
59+ ) -> String {
60+ match selector {
61+ TargetSelectorV1 :: Platform ( p) => format ! ( "{platform_kind}_platform == '{p}'" ) ,
62+ _ => selector. to_string ( ) ,
63+ }
64+ }
65+
3966pub fn from_targets_v1_to_conditional_requirements ( targets : & TargetsV1 ) -> ConditionalRequirements {
4067 let mut build_items = ConditionalList :: new ( ) ;
4168 let mut host_items = ConditionalList :: new ( ) ;
@@ -86,7 +113,7 @@ pub fn from_targets_v1_to_conditional_requirements(targets: &TargetsV1) -> Condi
86113 . map ( |spec| spec. 1 )
87114 . map ( |spec| {
88115 Conditional {
89- condition : selector . to_string ( ) ,
116+ condition : to_rattler_build_selector ( selector , PlatformKind :: Build ) ,
90117 then : ListOrItem ( vec ! [ spec] ) ,
91118 else_value : ListOrItem :: default ( ) ,
92119 }
@@ -100,7 +127,7 @@ pub fn from_targets_v1_to_conditional_requirements(targets: &TargetsV1) -> Condi
100127 . map ( |spec| spec. 1 )
101128 . map ( |spec| {
102129 Conditional {
103- condition : selector . to_string ( ) ,
130+ condition : to_rattler_build_selector ( selector , PlatformKind :: Host ) ,
104131 then : ListOrItem ( vec ! [ spec] ) ,
105132 else_value : ListOrItem :: default ( ) ,
106133 }
@@ -114,7 +141,7 @@ pub fn from_targets_v1_to_conditional_requirements(targets: &TargetsV1) -> Condi
114141 . map ( |spec| spec. 1 )
115142 . map ( |spec| {
116143 Conditional {
117- condition : selector . to_string ( ) ,
144+ condition : to_rattler_build_selector ( selector , PlatformKind :: Target ) ,
118145 then : ListOrItem ( vec ! [ spec] ) ,
119146 else_value : ListOrItem :: default ( ) ,
120147 }
0 commit comments