@@ -17,6 +17,8 @@ pub struct TargetMatrix {
1717 pub merge_group : Option < String > ,
1818 #[ clap( subcommand) ]
1919 pub subcommand : Option < TargetMatrixSub > ,
20+ #[ clap( long) ]
21+ pub for_build : bool ,
2022}
2123
2224#[ derive( Parser , Debug ) ]
@@ -91,6 +93,7 @@ impl TargetMatrix {
9193 weekly: false ,
9294 merge_group: Some ( _) | None ,
9395 subcommand: None ,
96+ for_build: false | true ,
9497 }
9598 ) || is_default_try
9699 {
@@ -99,26 +102,49 @@ impl TargetMatrix {
99102
100103 app. filter ( & mut matrix) ;
101104
102- let matrix = matrix
103- . iter ( )
104- . map ( |target| TargetMatrixElement {
105- pretty : target. to_image_target ( ) . alt ( ) ,
106- platforms : target. platforms ( ) ,
107- target : & target. target ,
108- sub : target. sub . as_deref ( ) ,
109- os : & target. os ,
110- run : target. run . map ( |b| b as u8 ) ,
111- deploy : target. deploy . map ( |b| b as u8 ) ,
112- build_std : target. build_std . map ( |b| b as u8 ) ,
113- cpp : target. cpp . map ( |b| b as u8 ) ,
114- dylib : target. dylib . map ( |b| b as u8 ) ,
115- runners : target. runners . as_deref ( ) ,
116- std : target. std . map ( |b| b as u8 ) ,
117- verbose : app. verbose ,
118- } )
119- . collect :: < Vec < _ > > ( ) ;
105+ let json = if self . for_build {
106+ let matrix = matrix
107+ . iter ( )
108+ . flat_map ( |target| target. platforms ( ) . iter ( ) . map ( move |platform| ( target, platform) ) )
109+ . map ( |( target, platform) | TargetMatrixElementForBuild {
110+ pretty : target. to_image_target ( ) . alt ( ) ,
111+ platform : platform. to_string ( ) ,
112+ target : & target. target ,
113+ sub : target. sub . as_deref ( ) ,
114+ os : & target. os ,
115+ run : target. run . map ( |b| b as u8 ) ,
116+ deploy : target. deploy . map ( |b| b as u8 ) ,
117+ build_std : target. build_std . map ( |b| b as u8 ) ,
118+ cpp : target. cpp . map ( |b| b as u8 ) ,
119+ dylib : target. dylib . map ( |b| b as u8 ) ,
120+ runners : target. runners . as_deref ( ) ,
121+ std : target. std . map ( |b| b as u8 ) ,
122+ verbose : app. verbose ,
123+ } )
124+ . collect :: < Vec < _ > > ( ) ;
125+ serde_json:: to_string ( & matrix) ?
126+ } else {
127+ let matrix = matrix
128+ . iter ( )
129+ . map ( |target| TargetMatrixElement {
130+ pretty : target. to_image_target ( ) . alt ( ) ,
131+ platforms : target. platforms ( ) ,
132+ target : & target. target ,
133+ sub : target. sub . as_deref ( ) ,
134+ os : & target. os ,
135+ run : target. run . map ( |b| b as u8 ) ,
136+ deploy : target. deploy . map ( |b| b as u8 ) ,
137+ build_std : target. build_std . map ( |b| b as u8 ) ,
138+ cpp : target. cpp . map ( |b| b as u8 ) ,
139+ dylib : target. dylib . map ( |b| b as u8 ) ,
140+ runners : target. runners . as_deref ( ) ,
141+ std : target. std . map ( |b| b as u8 ) ,
142+ verbose : app. verbose ,
143+ } )
144+ . collect :: < Vec < _ > > ( ) ;
145+ serde_json:: to_string ( & matrix) ?
146+ } ;
120147
121- let json = serde_json:: to_string ( & matrix) ?;
122148 gha_output ( "matrix" , & json) ?;
123149 let tests = serde_json:: to_string ( & app. tests ( ) ?) ?;
124150 gha_output ( "tests" , & tests) ?;
@@ -265,6 +291,31 @@ struct TargetMatrixElement<'a> {
265291 std : Option < u8 > ,
266292 verbose : bool ,
267293}
294+ #[ derive( Serialize ) ]
295+ #[ serde( rename_all = "kebab-case" ) ]
296+ struct TargetMatrixElementForBuild < ' a > {
297+ pretty : String ,
298+ platform : String ,
299+ target : & ' a str ,
300+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
301+ sub : Option < & ' a str > ,
302+ os : & ' a str ,
303+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
304+ run : Option < u8 > ,
305+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
306+ deploy : Option < u8 > ,
307+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
308+ build_std : Option < u8 > ,
309+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
310+ cpp : Option < u8 > ,
311+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
312+ dylib : Option < u8 > ,
313+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
314+ runners : Option < & ' a str > ,
315+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
316+ std : Option < u8 > ,
317+ verbose : bool ,
318+ }
268319
269320#[ derive( Parser , Debug , PartialEq , Eq ) ]
270321#[ clap( no_binary_name = true ) ]
0 commit comments