@@ -17,6 +17,8 @@ pub struct TargetMatrix {
17
17
pub merge_group : Option < String > ,
18
18
#[ clap( subcommand) ]
19
19
pub subcommand : Option < TargetMatrixSub > ,
20
+ #[ clap( long) ]
21
+ pub for_build : bool ,
20
22
}
21
23
22
24
#[ derive( Parser , Debug ) ]
@@ -91,6 +93,7 @@ impl TargetMatrix {
91
93
weekly: false ,
92
94
merge_group: Some ( _) | None ,
93
95
subcommand: None ,
96
+ for_build: false | true ,
94
97
}
95
98
) || is_default_try
96
99
{
@@ -99,26 +102,54 @@ impl TargetMatrix {
99
102
100
103
app. filter ( & mut matrix) ;
101
104
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
+ } ;
120
152
121
- let json = serde_json:: to_string ( & matrix) ?;
122
153
gha_output ( "matrix" , & json) ?;
123
154
let tests = serde_json:: to_string ( & app. tests ( ) ?) ?;
124
155
gha_output ( "tests" , & tests) ?;
@@ -265,6 +296,31 @@ struct TargetMatrixElement<'a> {
265
296
std : Option < u8 > ,
266
297
verbose : bool ,
267
298
}
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
+ }
268
324
269
325
#[ derive( Parser , Debug , PartialEq , Eq ) ]
270
326
#[ clap( no_binary_name = true ) ]
0 commit comments