2323 */
2424
2525const cp = require ( "child_process" ) ;
26- const path = require ( ' path' ) ;
26+ const path = require ( " path" ) ;
2727const fs = require ( "fs" ) ;
2828
2929const Tool = require ( "./lib/Tool" ) ;
3030const Checkout = require ( "./lib/Git/Checkout" ) ;
3131const Paths = require ( "./lib/Paths" ) ;
3232const Components = require ( "./lib/Components" ) ;
3333const Config = require ( "./lib/Config" ) ;
34- const Installer = require ( "./lib/Installer" )
35- const Settings = require ( "./lib/Settings" )
34+ const Installer = require ( "./lib/Installer" ) ;
35+ const Settings = require ( "./lib/Settings" ) ;
3636const NDK = require ( "./lib/NDK" ) ;
37- const TestAutomation = require ( "./Tests/TestAutomation" )
37+ const TestAutomation = require ( "./Tests/TestAutomation" ) ;
3838
3939const LLVMBuilder = require ( "./lib/Builders/LLVMBuilder" ) ;
4040const SwiftStdLibBuilder = require ( "./lib/Builders/SwiftStdLibBuilder" ) ;
@@ -57,8 +57,8 @@ const SwiftCryptoBuilder = require("./lib/Builders/SwiftCryptoBuilder");
5757
5858module . exports = class Automation extends Tool {
5959 run ( ) {
60- this . verifyXcodeAndExitIfNeeded ( )
61- this . verifyNDKAndExitIfNeeded ( )
60+ this . verifyXcodeAndExitIfNeeded ( ) ;
61+ this . verifyNDKAndExitIfNeeded ( ) ;
6262 var args = process . argv . slice ( 2 ) ;
6363 var action = args [ 0 ] ;
6464 if ( ! action ) {
@@ -80,27 +80,27 @@ module.exports = class Automation extends Tool {
8080 } else if ( action == "checkout" ) {
8181 new Checkout ( ) . checkout ( ) ;
8282 } else if ( action == "build" ) {
83- this . build ( )
83+ this . build ( ) ;
8484 } else if ( action == "clean" ) {
85- this . clean ( )
85+ this . clean ( ) ;
8686 } else if ( action == "status" ) {
87- this . status ( )
87+ this . status ( ) ;
8888 } else if ( action == "verify" ) {
89- this . verify ( )
89+ this . verify ( ) ;
9090 } else if ( action == "bootstrap" ) {
91- this . bootstrap ( )
91+ this . bootstrap ( ) ;
9292 } else if ( action == "archive" ) {
93- this . archive ( )
93+ this . archive ( ) ;
9494 } else if ( action == "test" ) {
95- this . test ( )
95+ this . test ( ) ;
9696 } else if ( action == "install" ) {
97- this . install ( )
97+ this . install ( ) ;
9898 } else if ( action == "assets" ) {
99- this . assets ( )
99+ this . assets ( ) ;
100100 } else if ( action == "stage2" ) {
101- this . stage2 ( )
101+ this . stage2 ( ) ;
102102 } else if ( action == "stage3" ) {
103- this . stage3 ( )
103+ this . stage3 ( ) ;
104104 } else {
105105 this . usage ( ) ;
106106 }
@@ -117,7 +117,7 @@ module.exports = class Automation extends Tool {
117117 } else if ( component == "foundation" ) {
118118 this . archs . forEach ( ( item ) => new FoundationBuilder ( item ) . runAction ( action ) ) ;
119119 } else if ( component == "icu" ) {
120- new ICUHostBuilder ( ) . runAction ( action )
120+ new ICUHostBuilder ( ) . runAction ( action ) ;
121121 this . archs . forEach ( ( item ) => new ICUBuilder ( item ) . runAction ( action ) ) ;
122122 } else if ( component == "swift" ) {
123123 new SwiftBuilder ( ) . runAction ( action ) ;
@@ -151,126 +151,128 @@ module.exports = class Automation extends Tool {
151151
152152 /** @private */
153153 build ( ) {
154- this . stage1 ( )
155- this . stage2 ( )
156- this . stage3 ( )
154+ this . stage1 ( ) ;
155+ this . stage2 ( ) ;
156+ this . stage3 ( ) ;
157157 }
158158
159159 /** @private */
160160 stage1 ( ) {
161- this . runComponentAction ( "llvm" , "make" )
162- this . runComponentAction ( "icu" , "make" )
163- this . runComponentAction ( "xml" , "make" )
164- this . runComponentAction ( "ssl" , "make" )
165- this . runComponentAction ( "curl" , "make" )
161+ this . runComponentAction ( "llvm" , "make" ) ;
162+ this . runComponentAction ( "icu" , "make" ) ;
163+ this . runComponentAction ( "xml" , "make" ) ;
164+ this . runComponentAction ( "ssl" , "make" ) ;
165+ this . runComponentAction ( "curl" , "make" ) ;
166166 }
167167
168168 /** @private */
169169 stage2 ( ) {
170- this . runComponentAction ( "cmark" , "make" )
171- this . runComponentAction ( "yams" , "make" )
172- this . runComponentAction ( "sap" , "make" )
173- this . runComponentAction ( "tsc" , "make" )
174- this . runComponentAction ( "llb" , "make" )
175- this . runComponentAction ( "sd" , "make" )
176- this . runComponentAction ( "sc" , "make" )
177- this . runComponentAction ( "spm" , "make" )
170+ this . runComponentAction ( "cmark" , "make" ) ;
171+ this . runComponentAction ( "yams" , "make" ) ;
172+ this . runComponentAction ( "sap" , "make" ) ;
173+ this . runComponentAction ( "tsc" , "make" ) ;
174+ this . runComponentAction ( "llb" , "make" ) ;
175+ this . runComponentAction ( "sd" , "make" ) ;
176+ this . runComponentAction ( "sc" , "make" ) ;
177+ this . runComponentAction ( "spm" , "make" ) ;
178178 }
179179
180180 /** @private */
181181 stage3 ( ) {
182- this . runComponentAction ( "swift" , "make" )
183- this . runComponentAction ( "stdlib" , "make" )
184- this . runComponentAction ( "dispatch" , "make" )
185- this . runComponentAction ( "foundation" , "make" )
182+ this . runComponentAction ( "swift" , "make" ) ;
183+ this . runComponentAction ( "stdlib" , "make" ) ;
184+ this . runComponentAction ( "dispatch" , "make" ) ;
185+ this . runComponentAction ( "foundation" , "make" ) ;
186186 }
187187
188188 /** @private */
189189 clean ( ) {
190- this . runComponentAction ( "llvm" , "clean" )
191- this . runComponentAction ( "cmark" , "clean" )
192- this . runComponentAction ( "icu" , "clean" )
193- this . runComponentAction ( "xml" , "clean" )
194- this . runComponentAction ( "ssl" , "clean" )
195- this . runComponentAction ( "curl" , "clean" )
196- this . runComponentAction ( "swift" , "clean" )
197- this . runComponentAction ( "stdlib" , "clean" )
198- this . runComponentAction ( "dispatch" , "clean" )
199- this . runComponentAction ( "foundation" , "clean" )
200- this . runComponentAction ( "tsc" , "clean" )
201- this . runComponentAction ( "llb" , "clean" )
202- this . runComponentAction ( "spm" , "clean" )
203- this . runComponentAction ( "sd" , "clean" )
204- this . runComponentAction ( "sap" , "clean" )
205- this . runComponentAction ( "yams" , "clean" )
190+ this . runComponentAction ( "llvm" , "clean" ) ;
191+ this . runComponentAction ( "cmark" , "clean" ) ;
192+ this . runComponentAction ( "icu" , "clean" ) ;
193+ this . runComponentAction ( "xml" , "clean" ) ;
194+ this . runComponentAction ( "ssl" , "clean" ) ;
195+ this . runComponentAction ( "curl" , "clean" ) ;
196+ this . runComponentAction ( "swift" , "clean" ) ;
197+ this . runComponentAction ( "stdlib" , "clean" ) ;
198+ this . runComponentAction ( "dispatch" , "clean" ) ;
199+ this . runComponentAction ( "foundation" , "clean" ) ;
200+ this . runComponentAction ( "tsc" , "clean" ) ;
201+ this . runComponentAction ( "llb" , "clean" ) ;
202+ this . runComponentAction ( "spm" , "clean" ) ;
203+ this . runComponentAction ( "sd" , "clean" ) ;
204+ this . runComponentAction ( "sap" , "clean" ) ;
205+ this . runComponentAction ( "yams" , "clean" ) ;
206206 }
207207
208208 /** @private */
209209 status ( ) {
210- var paths = [ ]
211- paths . push ( Paths . sourcesDirPath ( Components . llvm ) )
212- paths . push ( Paths . sourcesDirPath ( Components . cmark ) )
213- paths . push ( Paths . sourcesDirPath ( Components . icu ) )
214- paths . push ( Paths . sourcesDirPath ( Components . xml ) )
215- paths . push ( Paths . sourcesDirPath ( Components . ssl ) )
216- paths . push ( Paths . sourcesDirPath ( Components . curl ) )
217- paths . push ( Paths . sourcesDirPath ( Components . swift ) )
218- paths . push ( Paths . sourcesDirPath ( Components . dispatch ) )
219- paths . push ( Paths . sourcesDirPath ( Components . foundation ) )
220- paths . push ( Paths . sourcesDirPath ( Components . tsc ) )
221- paths . push ( Paths . sourcesDirPath ( Components . llb ) )
222- paths . push ( Paths . sourcesDirPath ( Components . spm ) )
223- paths . forEach ( ( path ) => this . execute ( `cd "${ path } " && git status` ) )
210+ var paths = [ ] ;
211+ paths . push ( Paths . sourcesDirPath ( Components . llvm ) ) ;
212+ paths . push ( Paths . sourcesDirPath ( Components . cmark ) ) ;
213+ paths . push ( Paths . sourcesDirPath ( Components . icu ) ) ;
214+ paths . push ( Paths . sourcesDirPath ( Components . xml ) ) ;
215+ paths . push ( Paths . sourcesDirPath ( Components . ssl ) ) ;
216+ paths . push ( Paths . sourcesDirPath ( Components . curl ) ) ;
217+ paths . push ( Paths . sourcesDirPath ( Components . swift ) ) ;
218+ paths . push ( Paths . sourcesDirPath ( Components . dispatch ) ) ;
219+ paths . push ( Paths . sourcesDirPath ( Components . foundation ) ) ;
220+ paths . push ( Paths . sourcesDirPath ( Components . tsc ) ) ;
221+ paths . push ( Paths . sourcesDirPath ( Components . llb ) ) ;
222+ paths . push ( Paths . sourcesDirPath ( Components . spm ) ) ;
223+ paths . forEach ( ( path ) => this . execute ( `cd "${ path } " && git status` ) ) ;
224224 }
225225
226226 /** @private */
227227 verify ( ) {
228- this . runComponentAction ( "icu" , "verify" )
229- this . runComponentAction ( "xml" , "verify" )
230- this . runComponentAction ( "ssl" , "verify" )
231- this . runComponentAction ( "curl" , "verify" )
232- this . runComponentAction ( "stdlib" , "verify" )
233- this . runComponentAction ( "dispatch" , "verify" )
234- this . runComponentAction ( "foundation" , "verify" )
228+ this . runComponentAction ( "icu" , "verify" ) ;
229+ this . runComponentAction ( "xml" , "verify" ) ;
230+ this . runComponentAction ( "ssl" , "verify" ) ;
231+ this . runComponentAction ( "curl" , "verify" ) ;
232+ this . runComponentAction ( "stdlib" , "verify" ) ;
233+ this . runComponentAction ( "dispatch" , "verify" ) ;
234+ this . runComponentAction ( "foundation" , "verify" ) ;
235235 }
236236
237237 /** @private */
238238 bootstrap ( ) {
239- this . runSimpleAction ( "checkout" )
240- this . build ( )
241- this . install ( )
242- this . archive ( )
243- console . log ( "" )
244- this . print ( "\" Swift Toolchain for Android\ " build is completed." , 33 )
245- this . print ( `It can be found in "${ Config . toolChainBuildOutput } ".` , 33 )
246- console . log ( "" )
239+ this . runSimpleAction ( "checkout" ) ;
240+ this . build ( ) ;
241+ this . install ( ) ;
242+ this . archive ( ) ;
243+ console . log ( "" ) ;
244+ this . print ( '" Swift Toolchain for Android" build is completed.' , 33 ) ;
245+ this . print ( `It can be found in "${ Config . toolChainBuildOutput } ".` , 33 ) ;
246+ console . log ( "" ) ;
247247 }
248248
249249 /** @private */
250250 install ( ) {
251- new Installer ( ) . install ( )
251+ new Installer ( ) . install ( ) ;
252252 }
253253
254254 /** @private */
255255 assets ( ) {
256- new Installer ( ) . copyAssets ( )
256+ new Installer ( ) . copyAssets ( ) ;
257257 }
258258
259259 /** @private */
260260 archive ( ) {
261- this . print ( `Compressing "${ Config . toolChainBuildOutput } "` , 32 )
262- var baseName = path . basename ( Config . toolChainBuildOutput )
263- var extName = 'tar.gz'
264- var fileName = `${ baseName } .${ extName } `
265- this . execute ( `cd "${ path . dirname ( Config . toolChainBuildOutput ) } " && tar -czf ${ fileName } --options='compression-level=9' ${ baseName } ` )
266- this . print ( `Archive saved to "${ Config . toolChainBuildOutput } .${ extName } "` , 36 )
261+ this . print ( `Compressing "${ Config . toolChainBuildOutput } "` , 32 ) ;
262+ var baseName = path . basename ( Config . toolChainBuildOutput ) ;
263+ var extName = "tar.gz" ;
264+ var fileName = `${ baseName } .${ extName } ` ;
265+ this . execute (
266+ `cd "${ path . dirname ( Config . toolChainBuildOutput ) } " && tar -czf ${ fileName } --options='compression-level=9' ${ baseName } `
267+ ) ;
268+ this . print ( `Archive saved to "${ Config . toolChainBuildOutput } .${ extName } "` , 36 ) ;
267269 }
268270
269271 /** @private */
270272 test ( ) {
271- const tests = new TestAutomation ( )
272- tests . build ( )
273- tests . clean ( )
273+ const tests = new TestAutomation ( ) ;
274+ tests . build ( ) ;
275+ tests . clean ( ) ;
274276 }
275277
276278 /** @private */
@@ -306,29 +308,41 @@ module.exports = class Automation extends Tool {
306308
307309 this . print ( "To clean only certain component:" , 32 ) ;
308310 this . print ( " $ node main.js llvm:clean\n" , 36 ) ;
311+
312+ this . print ( "Advanced:\n" , 33 ) ;
313+ this . print ( "To see which commands will be executed for build without running build:" , 32 ) ;
314+ this . print ( " $ node main.js build --dry-run\n" , 36 ) ;
315+
316+ this . print ( "To fetch updates from git repositories of the dependencies:" , 32 ) ;
317+ this . print ( " $ node main.js fetch\n" , 36 ) ;
318+
319+ this . print ( "To see is there are any local changes in git repositories of the dependencies:" , 32 ) ;
320+ this . print ( " $ node main.js status\n" , 36 ) ;
309321 }
310322
311323 /** @private */
312324 verifyXcodeAndExitIfNeeded ( ) {
313- var xcodeVersion = cp . execSync ( "xcodebuild -version" ) . toString ( ) . trim ( )
314- let version = xcodeVersion . split ( "\n" ) . filter ( ( comp ) => comp . includes ( "Xcode" ) ) [ 0 ]
315- if ( ! version . includes ( 12 ) ) {
316- this . print ( "Please use Xcode 12 ." , 31 )
317- this . print ( "Your Xcode version seems too old or too new:" , 36 )
318- this . print ( xcodeVersion , 32 )
319- process . exit ( 1 )
325+ var xcodeVersion = cp . execSync ( "xcodebuild -version" ) . toString ( ) . trim ( ) ;
326+ let version = xcodeVersion . split ( "\n" ) . filter ( ( comp ) => comp . includes ( "Xcode" ) ) [ 0 ] ;
327+ if ( ! version . includes ( 13 ) ) {
328+ this . print ( "Please use Xcode 13 ." , 31 ) ;
329+ this . print ( "Your Xcode version seems too old or too new:" , 36 ) ;
330+ this . print ( xcodeVersion , 32 ) ;
331+ process . exit ( 1 ) ;
320332 }
321333 }
322334
323335 /** @private */
324336 verifyNDKAndExitIfNeeded ( ) {
325- var ndkDir = Settings . ndkDir
326- var toolchainPath = new NDK ( ) . toolchainPath
327- if ( ! fs . existsSync ( toolchainPath ) ) {
328- this . logError ( `! Please create symbolic link "${ ndkDir } " which points to Android NDK installation version ${ Settings . ndkVersion } .` )
329- this . logMessage ( `Usually Android NDK installation can be found at "~/Library/Android/sdk/ndk".` )
330- this . logMessage ( `Refer to files "Readme.md" and "NDK_VERSION" for details.` )
331- process . exit ( 1 )
337+ var ndkDir = Settings . ndkDir ;
338+ var toolchainPath = new NDK ( ) . toolchainPath ;
339+ if ( ! fs . existsSync ( toolchainPath ) ) {
340+ this . logError (
341+ `! Please create symbolic link "${ ndkDir } " which points to Android NDK installation version ${ Settings . ndkVersion } .`
342+ ) ;
343+ this . logMessage ( `Usually Android NDK installation can be found at "~/Library/Android/sdk/ndk".` ) ;
344+ this . logMessage ( `Refer to files "Readme.md" and "NDK_VERSION" for details.` ) ;
345+ process . exit ( 1 ) ;
332346 }
333347 }
334348} ;
0 commit comments