@@ -13,7 +13,7 @@ import {
1313 allTargets ,
1414 findPlatformForTarget ,
1515 platformHasTarget ,
16- platforms ,
16+ platforms
1717} from "./platforms.js" ;
1818import { getWeakNodeApiVariables } from "./weak-node-api.js" ;
1919
@@ -24,12 +24,12 @@ EventEmitter.defaultMaxListeners = 100;
2424
2525const verboseOption = new Option (
2626 "--verbose" ,
27- "Print more output during the build" ,
27+ "Print more output during the build"
2828) . default ( process . env . CI === "true" ) ;
2929
3030const sourcePathOption = new Option (
3131 "--source <path>" ,
32- "Specify the source directory containing a CMakeLists.txt file" ,
32+ "Specify the source directory containing a CMakeLists.txt file"
3333) . default ( process . cwd ( ) ) ;
3434
3535// TODO: Add "MinSizeRel" and "RelWithDebInfo"
@@ -47,40 +47,40 @@ const defaultTargets = CMAKE_RN_TARGETS ? CMAKE_RN_TARGETS.split(",") : [];
4747for ( const target of defaultTargets ) {
4848 assert (
4949 ( allTargets as string [ ] ) . includes ( target ) ,
50- `Unexpected target in CMAKE_RN_TARGETS: ${ target } ` ,
50+ `Unexpected target in CMAKE_RN_TARGETS: ${ target } `
5151 ) ;
5252}
5353
5454const targetOption = new Option ( "--target <target...>" , "Targets to build for" )
5555 . choices ( allTargets )
5656 . default (
5757 defaultTargets ,
58- "CMAKE_RN_TARGETS environment variable split by ','" ,
58+ "CMAKE_RN_TARGETS environment variable split by ','"
5959 ) ;
6060
6161const buildPathOption = new Option (
6262 "--build <path>" ,
63- "Specify the build directory to store the configured CMake project" ,
63+ "Specify the build directory to store the configured CMake project"
6464) ;
6565
6666const cleanOption = new Option (
6767 "--clean" ,
68- "Delete the build directory before configuring the project" ,
68+ "Delete the build directory before configuring the project"
6969) ;
7070
7171const outPathOption = new Option (
7272 "--out <path>" ,
73- "Specify the output directory to store the final build artifacts" ,
73+ "Specify the output directory to store the final build artifacts"
7474) . default ( false , "./{build}/{configuration}" ) ;
7575
7676const noAutoLinkOption = new Option (
7777 "--no-auto-link" ,
78- "Don't mark the output as auto-linkable by react-native-node-api" ,
78+ "Don't mark the output as auto-linkable by react-native-node-api"
7979) ;
8080
8181const noWeakNodeApiLinkageOption = new Option (
8282 "--no-weak-node-api-linkage" ,
83- "Don't pass the path of the weak-node-api library from react-native-node-api" ,
83+ "Don't pass the path of the weak-node-api library from react-native-node-api"
8484) ;
8585
8686let program = new Command ( "cmake-rn" )
@@ -98,7 +98,7 @@ let program = new Command("cmake-rn")
9898for ( const platform of platforms ) {
9999 const allOption = new Option (
100100 `--${ platform . id } ` ,
101- `Enable all ${ platform . name } triplets` ,
101+ `Enable all ${ platform . name } triplets`
102102 ) ;
103103 program = program . addOption ( allOption ) ;
104104 program = platform . amendCommand ( program ) ;
@@ -132,13 +132,13 @@ program = program.action(
132132 }
133133 if ( targets . size === 0 ) {
134134 throw new Error (
135- "Found no default targets: Install some platform specific build tools" ,
135+ "Found no default targets: Install some platform specific build tools"
136136 ) ;
137137 } else {
138138 console . error (
139139 chalk . yellowBright ( "ℹ" ) ,
140140 "Using default targets" ,
141- chalk . dim ( `(${ [ ...targets ] . join ( ", " ) } )` ) ,
141+ chalk . dim ( `(${ [ ...targets ] . join ( ", " ) } )` )
142142 ) ;
143143 }
144144 }
@@ -155,26 +155,26 @@ program = program.action(
155155 platform,
156156 buildPath : targetBuildPath ,
157157 outputPath : path . join ( targetBuildPath , "out" ) ,
158- options : baseOptions ,
158+ options : baseOptions
159159 } ;
160160 } ) ;
161161
162162 // Configure every triplet project
163163 const targetsSummary = chalk . dim (
164- `(${ getTargetsSummary ( targetContexts ) } )` ,
164+ `(${ getTargetsSummary ( targetContexts ) } )`
165165 ) ;
166166 await oraPromise (
167167 Promise . all (
168168 targetContexts . map ( ( { platform, ...context } ) =>
169- configureProject ( platform , context , baseOptions ) ,
170- ) ,
169+ configureProject ( platform , context , baseOptions )
170+ )
171171 ) ,
172172 {
173173 text : `Configuring projects ${ targetsSummary } ` ,
174174 isSilent : baseOptions . verbose ,
175175 successText : `Configured projects ${ targetsSummary } ` ,
176- failText : ( { message } ) => `Failed to configure projects: ${ message } ` ,
177- } ,
176+ failText : ( { message } ) => `Failed to configure projects: ${ message } `
177+ }
178178 ) ;
179179
180180 // Build every triplet project
@@ -185,33 +185,33 @@ program = program.action(
185185 // This is important, since we might rename the output files
186186 await fs . promises . rm ( context . outputPath , {
187187 recursive : true ,
188- force : true ,
188+ force : true
189189 } ) ;
190190 await buildProject ( platform , context , baseOptions ) ;
191- } ) ,
191+ } )
192192 ) ,
193193 {
194194 text : "Building projects" ,
195195 isSilent : baseOptions . verbose ,
196196 successText : "Built projects" ,
197- failText : ( { message } ) => `Failed to build projects: ${ message } ` ,
198- } ,
197+ failText : ( { message } ) => `Failed to build projects: ${ message } `
198+ }
199199 ) ;
200200
201201 // Perform post-build steps for each platform in sequence
202202 for ( const platform of platforms ) {
203203 const relevantTargets = targetContexts . filter ( ( { target } ) =>
204- platformHasTarget ( platform , target ) ,
204+ platformHasTarget ( platform , target )
205205 ) ;
206206 if ( relevantTargets . length === 0 ) {
207207 continue ;
208208 }
209209 await platform . postBuild (
210210 {
211211 outputPath : baseOptions . out || baseOptions . source ,
212- targets : relevantTargets ,
212+ targets : relevantTargets
213213 } ,
214- baseOptions ,
214+ baseOptions
215215 ) ;
216216 }
217217 } catch ( error ) {
@@ -220,11 +220,11 @@ program = program.action(
220220 }
221221 throw error ;
222222 }
223- } ,
223+ }
224224) ;
225225
226226function getTargetsSummary (
227- targetContexts : { target : string ; platform : Platform } [ ] ,
227+ targetContexts : { target : string ; platform : Platform } [ ]
228228) {
229229 const targetsPerPlatform : Record < string , string [ ] > = { } ;
230230 for ( const { target, platform } of targetContexts ) {
@@ -256,7 +256,7 @@ function getTargetBuildPath(buildPath: string, target: unknown) {
256256async function configureProject < T extends string > (
257257 platform : Platform < T [ ] , Record < string , unknown > > ,
258258 context : TargetContext < T > ,
259- options : BaseOpts ,
259+ options : BaseOpts
260260) {
261261 const { target, buildPath, outputPath } = context ;
262262 const { verbose, source, weakNodeApiLinkage } = options ;
@@ -269,7 +269,7 @@ async function configureProject<T extends string>(
269269
270270 const declarations = {
271271 ...nodeApiVariables ,
272- CMAKE_LIBRARY_OUTPUT_DIRECTORY : outputPath ,
272+ CMAKE_LIBRARY_OUTPUT_DIRECTORY : outputPath
273273 } ;
274274
275275 await spawn (
@@ -280,19 +280,19 @@ async function configureProject<T extends string>(
280280 "-B" ,
281281 buildPath ,
282282 ...platform . configureArgs ( context , options ) ,
283- ...toDeclarationArguments ( declarations ) ,
283+ ...toDeclarationArguments ( declarations )
284284 ] ,
285285 {
286286 outputMode : verbose ? "inherit" : "buffered" ,
287- outputPrefix : verbose ? chalk . dim ( `[${ target } ] ` ) : undefined ,
288- } ,
287+ outputPrefix : verbose ? chalk . dim ( `[${ target } ] ` ) : undefined
288+ }
289289 ) ;
290290}
291291
292292async function buildProject < T extends string > (
293293 platform : Platform < T [ ] , Record < string , unknown > > ,
294294 context : TargetContext < T > ,
295- options : BaseOpts ,
295+ options : BaseOpts
296296) {
297297 const { target, buildPath } = context ;
298298 const { verbose, configuration } = options ;
@@ -304,19 +304,19 @@ async function buildProject<T extends string>(
304304 "--config" ,
305305 configuration ,
306306 "--" ,
307- ...platform . buildArgs ( context , options ) ,
307+ ...platform . buildArgs ( context , options )
308308 ] ,
309309 {
310310 outputMode : verbose ? "inherit" : "buffered" ,
311- outputPrefix : verbose ? chalk . dim ( `[${ target } ] ` ) : undefined ,
312- } ,
311+ outputPrefix : verbose ? chalk . dim ( `[${ target } ] ` ) : undefined
312+ }
313313 ) ;
314314}
315315
316316function toDeclarationArguments ( declarations : Record < string , string > ) {
317317 return Object . entries ( declarations ) . flatMap ( ( [ key , value ] ) => [
318318 "-D" ,
319- `${ key } =${ value } ` ,
319+ `${ key } =${ value } `
320320 ] ) ;
321321}
322322
0 commit comments