post_build.ps1 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. #-------------------------------------------------------------------------------------------------------
  2. # Copyright (C) Microsoft. All rights reserved.
  3. # Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. #-------------------------------------------------------------------------------------------------------
  5. # Post-Build Script
  6. #
  7. # Run this script after the build step to consume the artifacts produced by the build,
  8. # run tests, and process and deploy build logs.
  9. #
  10. # There may be more non-script tasks in the build definition following this script.
  11. # Any final tasks that need to be done at the end of the build are contained in the
  12. # Finalize Build Script, which should be invoked at the very end of the build.
  13. param (
  14. [ValidateSet("x86", "x64", "arm", "*")]
  15. [string]$arch = "*",
  16. [ValidateSet("debug", "release", "test", "codecoverage", "*")]
  17. [string]$flavor = "*",
  18. [ValidateSet("default", "codecoverage", "pogo")]
  19. [string]$subtype = "default",
  20. [string]$srcpath = "",
  21. [string]$buildRoot = "",
  22. [string]$objpath = "",
  23. [Parameter(Mandatory=$True)]
  24. [string]$srcsrvcmdpath,
  25. [string]$bvtcmdpath = "",
  26. [string]$testparams = "",
  27. [string]$repo = "core",
  28. [string]$logFile = "",
  29. # comma separated list of [arch,flavor,arch2,flavor2,...] to build
  30. [string[]]$pogo = @(),
  31. [string]$pogoscript = "",
  32. #
  33. # Skip flags
  34. #
  35. [switch]$skipTests # or set $Env:SKIP_TESTS before invoking build
  36. )
  37. . $PSScriptRoot\pre_post_util.ps1
  38. $srcpath, $buildRoot, $objpath, $_ = `
  39. ComputePaths `
  40. -arch $arch -flavor $flavor -subtype $subtype -OuterScriptRoot $PSScriptRoot `
  41. -srcpath $srcpath -buildRoot $buildRoot -objpath $objpath -binpath $_
  42. $skipTests = $skipTests -or (Test-Path Env:\SKIP_TESTS)
  43. $global:exitcode = 0
  44. if ($arch -eq "*") {
  45. foreach ($arch in ("x86", "x64", "arm")) {
  46. ExecuteCommand "$PSScriptRoot\post_build.ps1 -arch $arch -flavor $flavor -srcpath ""$srcpath"" -buildRoot ""$buildRoot"" -objpath ""$objpath"" -srcsrvcmdpath ""$srcsrvcmdpath"" -bvtcmdpath ""$bvtcmdpath"" -repo ""$repo""" -logFile ""$logFile""
  47. }
  48. } elseif ($flavor -eq "*") {
  49. foreach ($flavor in ("debug", "test", "release")) {
  50. ExecuteCommand "$PSScriptRoot\post_build.ps1 -arch $arch -flavor $flavor -srcpath ""$srcpath"" -buildRoot ""$buildRoot"" -objpath ""$objpath"" -srcsrvcmdpath ""$srcsrvcmdpath"" -bvtcmdpath ""$bvtcmdpath"" -repo ""$repo""" -logFile ""$logFile""
  51. }
  52. } else {
  53. $buildName = ConstructBuildName -arch $arch -flavor $flavor -subtype $subtype
  54. if (($logFile -eq "") -and (Test-Path $buildRoot)) {
  55. $logFile = "${buildRoot}\logs\post_build.${buildName}.log"
  56. if (Test-Path -Path $logFile) {
  57. Remove-Item $logFile -Force
  58. }
  59. }
  60. WriteMessage "======================================================================================"
  61. WriteMessage "Post build script for $arch $flavor"
  62. WriteMessage "======================================================================================"
  63. $bvtcmdpath = UseValueOrDefault $bvtcmdpath "" (Resolve-Path "$PSScriptRoot\..\..\test\runcitests.cmd")
  64. WriteCommonArguments
  65. WriteMessage "BVT Command : $bvtcmdpath"
  66. WriteMessage ""
  67. $srcsrvcmd = ("{0} {1} {2} {3}\bin\{4}\*.pdb" -f $srcsrvcmdpath, $repo, $srcpath, $buildRoot, $buildName)
  68. $prefastlog = ("{0}\logs\PrefastCheck.{1}.log" -f $buildRoot, $buildName)
  69. $prefastcmd = "$PSScriptRoot\check_prefast_error.ps1 -directory $objpath -logFile $prefastlog"
  70. # generate srcsrv
  71. if ((Test-Path $srcsrvcmdpath) -and (Test-Path $srcpath) -and (Test-Path $buildRoot)) {
  72. ExecuteCommand($srcsrvcmd)
  73. }
  74. # do POGO
  75. $doPogo=$False
  76. for ($i=0; $i -lt $pogo.length; $i=$i+2) {
  77. if (($pogo[$i] -eq $arch) -and ($pogo[$i+1] -eq $flavor)) {
  78. $doPogo=$True
  79. }
  80. }
  81. if ($subtype -ne "codecoverage") {
  82. if ($doPogo -and ("$pogoscript" -ne "")) {
  83. WriteMessage "Building pogo for $arch $flavor"
  84. $pogocmd = ("{0} {1} {2}" -f $pogoscript, $arch, $flavor)
  85. ExecuteCommand($pogocmd)
  86. }
  87. # run tests
  88. if (-not $skipTests) {
  89. # marshall environment var for cmd script
  90. $Env:TF_BUILD_BINARIESDIRECTORY = $buildRoot
  91. ExecuteCommand("$bvtcmdpath -$arch$flavor $testparams")
  92. }
  93. }
  94. # check prefast
  95. ExecuteCommand($prefastcmd)
  96. WriteMessage ""
  97. }
  98. exit $global:exitcode