post_build.ps1 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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]$repo = "core",
  27. [string]$logFile = "",
  28. # comma separated list of [arch,flavor,arch2,flavor2,...] to build
  29. [string[]]$pogo = @(),
  30. [string]$pogoscript = "",
  31. #
  32. # Skip flags
  33. #
  34. [switch]$skipTests # or set $Env:SKIP_TESTS before invoking build
  35. )
  36. . $PSScriptRoot\pre_post_util.ps1
  37. $srcpath, $buildRoot, $objpath, $_ = `
  38. ComputePaths `
  39. -arch $arch -flavor $flavor -subtype $subtype -OuterScriptRoot $PSScriptRoot `
  40. -srcpath $srcpath -buildRoot $buildRoot -objpath $objpath -binpath $_
  41. $skipTests = $skipTests -or (Test-Path Env:\SKIP_TESTS)
  42. $global:exitcode = 0
  43. if ($arch -eq "*") {
  44. foreach ($arch in ("x86", "x64", "arm")) {
  45. ExecuteCommand "$PSScriptRoot\post_build.ps1 -arch $arch -flavor $flavor -srcpath ""$srcpath"" -buildRoot ""$buildRoot"" -objpath ""$objpath"" -srcsrvcmdpath ""$srcsrvcmdpath"" -bvtcmdpath ""$bvtcmdpath"" -repo ""$repo""" -logFile ""$logFile""
  46. }
  47. } elseif ($flavor -eq "*") {
  48. foreach ($flavor in ("debug", "test", "release")) {
  49. ExecuteCommand "$PSScriptRoot\post_build.ps1 -arch $arch -flavor $flavor -srcpath ""$srcpath"" -buildRoot ""$buildRoot"" -objpath ""$objpath"" -srcsrvcmdpath ""$srcsrvcmdpath"" -bvtcmdpath ""$bvtcmdpath"" -repo ""$repo""" -logFile ""$logFile""
  50. }
  51. } else {
  52. $buildName = ConstructBuildName -arch $arch -flavor $flavor -subtype $subtype
  53. if (($logFile -eq "") -and (Test-Path Env:\TF_BUILD_BINARIESDIRECTORY)) {
  54. $logFile = "${Env:TF_BUILD_BINARIESDIRECTORY}\logs\post_build.${buildName}.log"
  55. if (Test-Path -Path $logFile) {
  56. Remove-Item $logFile -Force
  57. }
  58. }
  59. WriteMessage "======================================================================================"
  60. WriteMessage "Post build script for $arch $flavor"
  61. WriteMessage "======================================================================================"
  62. $bvtcmdpath = UseValueOrDefault $bvtcmdpath "" (Resolve-Path "$PSScriptRoot\..\..\test\runcitests.cmd")
  63. WriteCommonArguments
  64. WriteMessage "BVT Command : $bvtcmdpath"
  65. WriteMessage ""
  66. $srcsrvcmd = ("{0} {1} {2} {3}\bin\{4}\*.pdb" -f $srcsrvcmdpath, $repo, $srcpath, $buildRoot, $buildName)
  67. $prefastlog = ("{0}\logs\PrefastCheck.{1}.log" -f $buildRoot, $buildName)
  68. $prefastcmd = "$PSScriptRoot\check_prefast_error.ps1 -directory $objpath -logFile $prefastlog"
  69. # generate srcsrv
  70. if ((Test-Path $srcsrvcmdpath) -and (Test-Path $srcpath) -and (Test-Path $buildRoot)) {
  71. ExecuteCommand($srcsrvcmd)
  72. }
  73. # do POGO
  74. $doPogo=$False
  75. for ($i=0; $i -lt $pogo.length; $i=$i+2) {
  76. if (($pogo[$i] -eq $arch) -and ($pogo[$i+1] -eq $flavor)) {
  77. $doPogo=$True
  78. }
  79. }
  80. if ($subtype -ne "codecoverage") {
  81. if ($doPogo -and ("$pogoscript" -ne "")) {
  82. WriteMessage "Building pogo for $arch $flavor"
  83. $pogocmd = ("{0} {1} {2}" -f $pogoscript, $arch, $flavor)
  84. ExecuteCommand($pogocmd)
  85. }
  86. # run tests
  87. if (-not $skipTests) {
  88. ExecuteCommand("$bvtcmdpath -$arch$flavor")
  89. }
  90. }
  91. # check prefast
  92. ExecuteCommand($prefastcmd)
  93. WriteMessage ""
  94. }
  95. exit $global:exitcode