@@ -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,54 @@ 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| {
109+ target
110+ . platforms ( )
111+ . iter ( )
112+ . map ( move |platform| ( target, platform) )
113+ } )
114+ . map ( |( target, platform) | TargetMatrixElementForBuild {
115+ pretty : target. to_image_target ( ) . alt ( ) ,
116+ platform : platform. to_string ( ) ,
117+ target : & target. target ,
118+ sub : target. sub . as_deref ( ) ,
119+ os : & target. os ,
120+ run : target. run . map ( |b| b as u8 ) ,
121+ deploy : target. deploy . map ( |b| b as u8 ) ,
122+ build_std : target. build_std . map ( |b| b as u8 ) ,
123+ cpp : target. cpp . map ( |b| b as u8 ) ,
124+ dylib : target. dylib . map ( |b| b as u8 ) ,
125+ runners : target. runners . as_deref ( ) ,
126+ std : target. std . map ( |b| b as u8 ) ,
127+ verbose : app. verbose ,
128+ } )
129+ . collect :: < Vec < _ > > ( ) ;
130+ serde_json:: to_string ( & matrix) ?
131+ } else {
132+ let matrix = matrix
133+ . iter ( )
134+ . map ( |target| TargetMatrixElement {
135+ pretty : target. to_image_target ( ) . alt ( ) ,
136+ platforms : target. platforms ( ) ,
137+ target : & target. target ,
138+ sub : target. sub . as_deref ( ) ,
139+ os : & target. os ,
140+ run : target. run . map ( |b| b as u8 ) ,
141+ deploy : target. deploy . map ( |b| b as u8 ) ,
142+ build_std : target. build_std . map ( |b| b as u8 ) ,
143+ cpp : target. cpp . map ( |b| b as u8 ) ,
144+ dylib : target. dylib . map ( |b| b as u8 ) ,
145+ runners : target. runners . as_deref ( ) ,
146+ std : target. std . map ( |b| b as u8 ) ,
147+ verbose : app. verbose ,
148+ } )
149+ . collect :: < Vec < _ > > ( ) ;
150+ serde_json:: to_string ( & matrix) ?
151+ } ;
120152
121- let json = serde_json:: to_string ( & matrix) ?;
122153 gha_output ( "matrix" , & json) ?;
123154 let tests = serde_json:: to_string ( & app. tests ( ) ?) ?;
124155 gha_output ( "tests" , & tests) ?;
@@ -265,6 +296,31 @@ struct TargetMatrixElement<'a> {
265296 std : Option < u8 > ,
266297 verbose : bool ,
267298}
299+ #[ derive( Serialize ) ]
300+ #[ serde( rename_all = "kebab-case" ) ]
301+ struct TargetMatrixElementForBuild < ' a > {
302+ pretty : String ,
303+ platform : String ,
304+ target : & ' a str ,
305+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
306+ sub : Option < & ' a str > ,
307+ os : & ' a str ,
308+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
309+ run : Option < u8 > ,
310+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
311+ deploy : Option < u8 > ,
312+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
313+ build_std : Option < u8 > ,
314+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
315+ cpp : Option < u8 > ,
316+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
317+ dylib : Option < u8 > ,
318+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
319+ runners : Option < & ' a str > ,
320+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
321+ std : Option < u8 > ,
322+ verbose : bool ,
323+ }
268324
269325#[ derive( Parser , Debug , PartialEq , Eq ) ]
270326#[ clap( no_binary_name = true ) ]
0 commit comments