@@ -26,6 +26,7 @@ use pixi_build_types::{
26
26
use pixi_config:: get_cache_dir;
27
27
pub use pixi_glob:: { GlobHashCache , GlobHashError } ;
28
28
use pixi_glob:: { GlobHashKey , GlobModificationTime , GlobModificationTimeError } ;
29
+ use pixi_manifest:: Targets ;
29
30
use pixi_record:: { InputHash , PinnedPathSpec , PinnedSourceSpec , SourceRecord } ;
30
31
use pixi_spec:: SourceSpec ;
31
32
use rattler_conda_types:: {
@@ -54,7 +55,7 @@ pub struct BuildContext {
54
55
cache_dir : PathBuf ,
55
56
work_dir : PathBuf ,
56
57
tool_context : Arc < ToolContext > ,
57
- variant_config : Option < HashMap < String , Vec < String > > > ,
58
+ variant_config : Targets < Option < HashMap < String , Vec < String > > > > ,
58
59
}
59
60
60
61
#[ derive( Debug , Error , Diagnostic ) ]
@@ -117,7 +118,7 @@ impl BuildContext {
117
118
cache_dir : PathBuf ,
118
119
dot_pixi_dir : PathBuf ,
119
120
channel_config : ChannelConfig ,
120
- variant_config : Option < HashMap < String , Vec < String > > > ,
121
+ variant_config : Targets < Option < HashMap < String , Vec < String > > > > ,
121
122
tool_context : Arc < ToolContext > ,
122
123
) -> Result < Self , std:: io:: Error > {
123
124
Ok ( Self {
@@ -133,16 +134,18 @@ impl BuildContext {
133
134
}
134
135
135
136
pub fn from_project ( project : & crate :: project:: Project ) -> miette:: Result < Self > {
137
+ let variant = project
138
+ . manifest ( )
139
+ . workspace
140
+ . workspace
141
+ . build_variants
142
+ . clone ( ) ;
143
+
136
144
Self :: new (
137
145
get_cache_dir ( ) ?,
138
146
project. pixi_dir ( ) ,
139
147
project. channel_config ( ) ,
140
- project
141
- . manifest ( )
142
- . workspace
143
- . workspace
144
- . build_variants
145
- . clone ( ) ,
148
+ variant,
146
149
Arc :: new ( ToolContext :: default ( ) ) ,
147
150
)
148
151
. into_diagnostic ( )
@@ -163,6 +166,22 @@ impl BuildContext {
163
166
}
164
167
}
165
168
169
+ fn resolve_variant ( & self , platform : Platform ) -> HashMap < String , Vec < String > > {
170
+ let mut result = HashMap :: new ( ) ;
171
+ for item in self . variant_config . resolve ( Some ( platform) ) {
172
+ if let Some ( variants) = item {
173
+ result. extend ( variants. clone ( ) ) ;
174
+ }
175
+ }
176
+ tracing:: info!(
177
+ "resolved variant configuration for {}: {:?}" ,
178
+ platform,
179
+ result
180
+ ) ;
181
+
182
+ result
183
+ }
184
+
166
185
/// Extracts the metadata for a package from the given source specification.
167
186
#[ allow( clippy:: too_many_arguments) ]
168
187
pub async fn extract_source_metadata (
@@ -319,7 +338,7 @@ impl BuildContext {
319
338
}
320
339
. key ( ) ,
321
340
) ,
322
- variant_configuration : self . variant_config . clone ( ) ,
341
+ variant_configuration : Some ( self . resolve_variant ( host_platform ) ) ,
323
342
} ,
324
343
build_reporter. as_conda_build_reporter ( ) ,
325
344
)
@@ -558,7 +577,7 @@ impl BuildContext {
558
577
}
559
578
. key ( ) ,
560
579
) ,
561
- variant_configuration : self . variant_config . clone ( ) ,
580
+ variant_configuration : Some ( self . resolve_variant ( host_platform ) ) ,
562
581
} ,
563
582
metadata_reporter. as_conda_metadata_reporter ( ) . clone ( ) ,
564
583
)
0 commit comments