@@ -375,6 +375,37 @@ $IsCrossCompiling = $HostArchName -ne $BuildArchName
375
375
376
376
$TimingData = New-Object System.Collections.Generic.List[System.Object ]
377
377
378
+ function Add-TimingData {
379
+ param
380
+ (
381
+ [Parameter (Mandatory )]
382
+ [string ] $Arch ,
383
+ [Parameter (Mandatory )]
384
+ [Platform ] $Platform ,
385
+ [Parameter (Mandatory )]
386
+ [string ] $BuildStep ,
387
+ [Parameter (Mandatory )]
388
+ [System.TimeSpan ] $ElapsedTime
389
+ )
390
+
391
+ $TimingData.Add ([PSCustomObject ]@ {
392
+ Arch = $Arch
393
+ Platform = $Platform
394
+ " Build Step" = $BuildStep
395
+ " Elapsed Time" = $ElapsedTime.ToString ()
396
+ })
397
+ }
398
+
399
+ function Write-Summary {
400
+ Write-Host " Summary:" - ForegroundColor Cyan
401
+
402
+ # Sort timing data by elapsed time (descending)
403
+ $TimingData `
404
+ | Select-Object " Build Step" , Platform, Arch, " Elapsed Time" `
405
+ | Sort-Object - Descending - Property " Elapsed Time" `
406
+ | Format-Table - AutoSize
407
+ }
408
+
378
409
function Get-AndroidNDK {
379
410
$NDK = $KnownNDKs [$AndroidNDKVersion ]
380
411
if (-not $NDK ) { throw " Unsupported Android NDK version" }
@@ -447,8 +478,29 @@ $WindowsSDKArchs = @($WindowsSDKs | ForEach-Object {
447
478
})
448
479
449
480
# Build functions
450
- function Invoke-BuildStep ([string ]$Name ) {
481
+ function Invoke-BuildStep ([string ] $Name ) {
482
+ if ($Summary ) {
483
+ # TODO: Replace hacky introspection of $Args with Platform object.
484
+ $BuildStepPlatform = " Windows"
485
+ $BuildStepArch = " (n/a)"
486
+ $Stopwatch = [Diagnostics.Stopwatch ]::StartNew()
487
+ foreach ($Arg in $Args ) {
488
+ switch ($Arg.GetType ().Name) {
489
+ " Hashtable" {
490
+ if ($Arg.ContainsKey (" LLVMName" )) { $BuildStepArch = $Arg [" LLVMName" ] }
491
+ }
492
+ " string" {
493
+ if ($Arg -eq " Windows" -or $Arg -eq " Android" ) { $BuildStepPlatform = $Arg }
494
+ }
495
+ }
496
+ }
497
+ }
498
+
451
499
& $Name @Args
500
+
501
+ if ($Summary ) {
502
+ Add-TimingData $BuildStepArch $BuildStepPlatform ($Name -replace " Build-" , " " ) $Stopwatch.Elapsed
503
+ }
452
504
if ($Name.Replace (" Build-" , " " ) -eq $BuildTo ) {
453
505
exit 0
454
506
}
@@ -721,6 +773,7 @@ function Invoke-VsDevShell($Arch) {
721
773
}
722
774
723
775
function Get-Dependencies {
776
+ Write-Host " [$ ( [DateTime ]::Now.ToString(" yyyy-MM-dd HH:mm:ss" )) ] Fetch-Dependencies ..." - ForegroundColor Cyan
724
777
$ProgressPreference = " SilentlyContinue"
725
778
726
779
$WebClient = New-Object Net.WebClient
@@ -936,12 +989,7 @@ function Get-Dependencies {
936
989
Write-Host " "
937
990
}
938
991
if ($Summary ) {
939
- $TimingData.Add ([PSCustomObject ]@ {
940
- Arch = $BuildArch.LLVMName
941
- Platform = ' Windows'
942
- Checkout = ' Get-Dependencies'
943
- " Elapsed Time" = $Stopwatch.Elapsed.ToString ()
944
- })
992
+ Add-TimingData $BuildArch.LLVMName " Windows" " Get-Dependencies" $Stopwatch.Elapsed
945
993
}
946
994
}
947
995
@@ -1387,15 +1435,6 @@ function Build-CMakeProject {
1387
1435
Write-Host - ForegroundColor Cyan " [$ ( [DateTime ]::Now.ToString(" yyyy-MM-dd HH:mm:ss" )) ] Finished building '$Src ' to '$Bin ' in $ ( $Stopwatch.Elapsed ) "
1388
1436
Write-Host " "
1389
1437
}
1390
-
1391
- if ($Summary ) {
1392
- $TimingData.Add ([PSCustomObject ]@ {
1393
- Arch = $Arch.LLVMName
1394
- Platform = $Platform
1395
- Checkout = $Src.Replace ($SourceCache , ' ' )
1396
- " Elapsed Time" = $Stopwatch.Elapsed.ToString ()
1397
- })
1398
- }
1399
1438
}
1400
1439
1401
1440
enum SPMBuildAction {
@@ -1481,12 +1520,7 @@ function Build-SPMProject {
1481
1520
}
1482
1521
1483
1522
if ($Summary ) {
1484
- $TimingData.Add ([PSCustomObject ]@ {
1485
- Arch = $Arch.LLVMName
1486
- Checkout = $Src.Replace ($SourceCache , ' ' )
1487
- Platform = " Windows"
1488
- " Elapsed Time" = $Stopwatch.Elapsed.ToString ()
1489
- })
1523
+ Add-TimingData $BuildArch.LLVMName " Windows" $Src.Replace ($SourceCache , ' ' ) $Stopwatch.Elapsed
1490
1524
}
1491
1525
}
1492
1526
@@ -3318,6 +3352,6 @@ if (-not $IsCrossCompiling) {
3318
3352
exit 1
3319
3353
} finally {
3320
3354
if ($Summary ) {
3321
- $TimingData | Select-Object Platform , Arch , Checkout , " Elapsed Time " | Sort-Object - Descending - Property " Elapsed Time " | Format-Table - AutoSize
3355
+ Write-Summary
3322
3356
}
3323
3357
}
0 commit comments