@@ -41,10 +41,23 @@ const configurationOption = new Option("--configuration <configuration>")
41
41
// TODO: Derive default targets
42
42
// This is especially important when driving the build from within a React Native app package.
43
43
44
- const targetOption = new Option (
45
- "--target <target...>" ,
46
- "Targets to build for"
47
- ) . choices ( allTargets ) ;
44
+ const { CMAKE_RN_TARGETS } = process . env ;
45
+
46
+ const defaultTargets = CMAKE_RN_TARGETS ? CMAKE_RN_TARGETS . split ( "," ) : [ ] ;
47
+
48
+ for ( const target of defaultTargets ) {
49
+ assert (
50
+ ( allTargets as string [ ] ) . includes ( target ) ,
51
+ `Unexpected target in CMAKE_RN_TARGETS: ${ target } `
52
+ ) ;
53
+ }
54
+
55
+ const targetOption = new Option ( "--target <target...>" , "Targets to build for" )
56
+ . choices ( allTargets )
57
+ . default (
58
+ defaultTargets ,
59
+ "CMAKE_RN_TARGETS environment variable split by ','"
60
+ ) ;
48
61
49
62
const buildPathOption = new Option (
50
63
"--build <path>" ,
@@ -148,16 +161,19 @@ program = program.action(
148
161
} ) ;
149
162
150
163
// Configure every triplet project
164
+ const targetsSummary = chalk . dim (
165
+ `(${ getTargetsSummary ( targetContexts ) } )`
166
+ ) ;
151
167
await oraPromise (
152
168
Promise . all (
153
169
targetContexts . map ( ( { platform, ...context } ) =>
154
170
configureProject ( platform , context , baseOptions )
155
171
)
156
172
) ,
157
173
{
158
- text : " Configuring projects" ,
174
+ text : ` Configuring projects ${ targetsSummary } ` ,
159
175
isSilent : baseOptions . verbose ,
160
- successText : " Configured projects" ,
176
+ successText : ` Configured projects ${ targetsSummary } ` ,
161
177
failText : ( { message } ) => `Failed to configure projects: ${ message } ` ,
162
178
}
163
179
) ;
@@ -208,6 +224,23 @@ program = program.action(
208
224
}
209
225
) ;
210
226
227
+ function getTargetsSummary (
228
+ targetContexts : { target : string ; platform : Platform } [ ]
229
+ ) {
230
+ const targetsPerPlatform : Record < string , string [ ] > = { } ;
231
+ for ( const { target, platform } of targetContexts ) {
232
+ if ( ! targetsPerPlatform [ platform . id ] ) {
233
+ targetsPerPlatform [ platform . id ] = [ ] ;
234
+ }
235
+ targetsPerPlatform [ platform . id ] . push ( target ) ;
236
+ }
237
+ return Object . entries ( targetsPerPlatform )
238
+ . map ( ( [ platformId , targets ] ) => {
239
+ return `${ platformId } : ${ targets . join ( ", " ) } ` ;
240
+ } )
241
+ . join ( " / " ) ;
242
+ }
243
+
211
244
function getBuildPath ( { build, source } : BaseOpts ) {
212
245
// TODO: Add configuration (debug vs release)
213
246
return path . resolve ( process . cwd ( ) , build || path . join ( source , "build" ) ) ;
0 commit comments