@@ -375,6 +375,37 @@ $IsCrossCompiling = $HostArchName -ne $BuildArchName
375375
376376$TimingData = New-Object System.Collections.Generic.List[System.Object ]
377377
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+
378409function Get-AndroidNDK {
379410 $NDK = $KnownNDKs [$AndroidNDKVersion ]
380411 if (-not $NDK ) { throw " Unsupported Android NDK version" }
@@ -447,8 +478,29 @@ $WindowsSDKArchs = @($WindowsSDKs | ForEach-Object {
447478})
448479
449480# 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+
451499 & $Name @Args
500+
501+ if ($Summary ) {
502+ Add-TimingData $BuildStepArch $BuildStepPlatform ($Name -replace " Build-" , " " ) $Stopwatch.Elapsed
503+ }
452504 if ($Name.Replace (" Build-" , " " ) -eq $BuildTo ) {
453505 exit 0
454506 }
@@ -721,6 +773,7 @@ function Invoke-VsDevShell($Arch) {
721773}
722774
723775function Get-Dependencies {
776+ Write-Host " [$ ( [DateTime ]::Now.ToString(" yyyy-MM-dd HH:mm:ss" )) ] Fetch-Dependencies ..." - ForegroundColor Cyan
724777 $ProgressPreference = " SilentlyContinue"
725778
726779 $WebClient = New-Object Net.WebClient
@@ -936,12 +989,7 @@ function Get-Dependencies {
936989 Write-Host " "
937990 }
938991 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
945993 }
946994}
947995
@@ -1387,15 +1435,6 @@ function Build-CMakeProject {
13871435 Write-Host - ForegroundColor Cyan " [$ ( [DateTime ]::Now.ToString(" yyyy-MM-dd HH:mm:ss" )) ] Finished building '$Src ' to '$Bin ' in $ ( $Stopwatch.Elapsed ) "
13881436 Write-Host " "
13891437 }
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- }
13991438}
14001439
14011440enum SPMBuildAction {
@@ -1481,12 +1520,7 @@ function Build-SPMProject {
14811520 }
14821521
14831522 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
14901524 }
14911525}
14921526
@@ -3318,6 +3352,6 @@ if (-not $IsCrossCompiling) {
33183352 exit 1
33193353} finally {
33203354 if ($Summary ) {
3321- $TimingData | Select-Object Platform , Arch , Checkout , " Elapsed Time " | Sort-Object - Descending - Property " Elapsed Time " | Format-Table - AutoSize
3355+ Write-Summary
33223356 }
33233357}
0 commit comments