@@ -4,10 +4,9 @@ use std::io::Write;
44use std:: path:: { Path , PathBuf } ;
55use std:: process:: Command ;
66
7- use cross:: shell:: MessageInfo ;
87use cross:: { docker, CommandExt , ToUtf8 } ;
8+ use cross:: { docker:: ImagePlatform , shell:: MessageInfo } ;
99
10- use cross:: docker:: ImagePlatform ;
1110use once_cell:: sync:: { Lazy , OnceCell } ;
1211use serde:: Deserialize ;
1312
@@ -47,9 +46,9 @@ pub struct CiTarget {
4746 /// if `true` publish the generated binaries for cross
4847 #[ serde( default ) ]
4948 pub deploy : Option < bool > ,
50- /// the platform to build this image for, defaults to `["linux/amd64"]` , takes multiple
49+ /// the platform to build this image for, defaults to whatever is needed , takes multiple
5150 #[ serde( skip_serializing_if = "Option::is_none" ) ]
52- platforms : Option < Vec < ImagePlatform > > ,
51+ pub platforms : Option < Vec < ImagePlatform > > ,
5352 /// if `true` signal that this target requires `-Zbuild-std`
5453 #[ serde( skip_serializing_if = "Option::is_none" ) ]
5554 pub build_std : Option < bool > ,
@@ -83,6 +82,8 @@ impl CiTarget {
8382 crate :: ImageTarget {
8483 name : self . target . clone ( ) ,
8584 sub : self . sub . clone ( ) ,
85+ // XXX: This does not align with platforms() by design, as we want to be able to know if the field was set or not.
86+ platform : self . platforms . clone ( ) ,
8687 }
8788 }
8889
@@ -163,6 +164,7 @@ pub fn pull_image(
163164pub struct ImageTarget {
164165 pub name : String ,
165166 pub sub : Option < String > ,
167+ pub platform : Option < Vec < ImagePlatform > > ,
166168}
167169
168170impl ImageTarget {
@@ -236,13 +238,15 @@ impl std::str::FromStr for ImageTarget {
236238 return Ok ( ImageTarget {
237239 name : target. to_string ( ) ,
238240 sub : Some ( sub. to_string ( ) ) ,
241+ platform : None ,
239242 } ) ;
240243 }
241244 }
242245
243246 Ok ( ImageTarget {
244247 name : s. to_string ( ) ,
245248 sub : None ,
249+ platform : None ,
246250 } )
247251 }
248252}
@@ -383,27 +387,31 @@ mod tests {
383387 ImageTarget {
384388 name: "x86_64-unknown-linux-gnu" . to_owned( ) ,
385389 sub: None ,
390+ platform: None ,
386391 } ,
387392 "x86_64-unknown-linux-gnu" . parse( ) . unwrap( )
388393 ) ;
389394 assert_eq ! (
390395 ImageTarget {
391396 name: "x86_64-unknown-linux-gnu" . to_owned( ) ,
392397 sub: Some ( "centos" . to_owned( ) ) ,
398+ platform: None ,
393399 } ,
394400 "x86_64-unknown-linux-gnu.centos" . parse( ) . unwrap( )
395401 ) ;
396402 assert_eq ! (
397403 ImageTarget {
398404 name: "thumbv8m.main-none-eabihf" . to_owned( ) ,
399405 sub: None ,
406+ platform: None ,
400407 } ,
401408 "thumbv8m.main-none-eabihf" . parse( ) . unwrap( )
402409 ) ;
403410 assert_eq ! (
404411 ImageTarget {
405412 name: "thumbv8m.main-unknown-linux-gnueabihf" . to_owned( ) ,
406413 sub: Some ( "alpine" . to_owned( ) ) ,
414+ platform: None ,
407415 } ,
408416 "thumbv8m.main-unknown-linux-gnueabihf.alpine"
409417 . parse( )
0 commit comments