post_build.ps1 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. param (
  6. [ValidateSet("x86", "x64", "arm", "*")]
  7. [string]$arch = "*",
  8. [ValidateSet("debug", "release", "test", "codecoverage", "*")]
  9. [string]$flavor = "*",
  10. [string]$srcpath = "",
  11. [string]$binpath = "",
  12. [string]$objpath = "",
  13. [Parameter(Mandatory=$True)]
  14. [string]$srcsrvcmdpath,
  15. [string]$bvtcmdpath = "",
  16. [string]$repo = "core",
  17. [string]$logFile = "",
  18. # comma separated list of [arch,flavor,arch2,flavor2,...] to build
  19. [string[]]$pogo = @(),
  20. [string]$pogoscript = "",
  21. [switch]$noaction
  22. )
  23. $global:exitcode = 0
  24. if ($arch -eq "*") {
  25. . "$PSScriptRoot\util.ps1"
  26. foreach ($arch in ("x86", "x64", "arm")) {
  27. ExecuteCommand "$PSScriptRoot\post_build.ps1 -arch $arch -flavor $flavor -srcpath ""$srcpath"" -binpath ""$binpath"" -objpath ""$objpath"" -srcsrvcmdpath ""$srcsrvcmdpath"" -bvtcmdpath ""$bvtcmdpath"" -repo ""$repo""" -logFile ""$logFile"";
  28. }
  29. } elseif ($flavor -eq "*") {
  30. . "$PSScriptRoot\util.ps1"
  31. foreach ($flavor in ("debug", "test", "release")) {
  32. ExecuteCommand "$PSScriptRoot\post_build.ps1 -arch $arch -flavor $flavor -srcpath ""$srcpath"" -binpath ""$binpath"" -objpath ""$objpath"" -srcsrvcmdpath ""$srcsrvcmdpath"" -bvtcmdpath ""$bvtcmdpath"" -repo ""$repo""" -logFile ""$logFile"";
  33. }
  34. } else {
  35. $OuterScriptRoot = $PSScriptRoot;
  36. . "$PSScriptRoot\pre_post_util.ps1"
  37. if (($logFile -eq "") -and (Test-Path Env:\TF_BUILD_BINARIESDIRECTORY)) {
  38. $logFile = "${Env:TF_BUILD_BINARIESDIRECTORY}\logs\post_build_${arch}_${flavor}.log"
  39. if (Test-Path -Path $logFile) {
  40. Remove-Item $logFile -Force
  41. }
  42. }
  43. WriteMessage "======================================================================================"
  44. WriteMessage "Post build script for $arch $flavor";
  45. WriteMessage "======================================================================================"
  46. $bvtcmdpath = UseValueOrDefault $bvtcmdpath "" (Resolve-Path "$PSScriptRoot\..\..\test\runcitests.cmd");
  47. WriteCommonArguments;
  48. WriteMessage "BVT Command : $bvtcmdpath"
  49. WriteMessage ""
  50. $srcsrvcmd = ("{0} {1} {2} {3}\bin\{4}_{5}\*.pdb" -f $srcsrvcmdpath, $repo, $srcpath, $binpath, $arch, $flavor);
  51. $pogocmd = ("{0} {1} {2}" -f $pogoscript, $arch, $flavor);
  52. $prefastlog = ("{0}\logs\PrefastCheck_{1}_{2}.log" -f $binpath, $arch, $flavor);
  53. $prefastcmd = "$PSScriptRoot\check_prefast_error.ps1 -directory $objpath -logFile $prefastlog";
  54. # generate srcsrv
  55. if ((Test-Path $srcsrvcmdpath) -and (Test-Path $srcpath) -and (Test-Path $binpath)) {
  56. ExecuteCommand($srcsrvcmd);
  57. }
  58. # do PoGO
  59. $doPogo=$False
  60. for ($i=0; $i -lt $pogo.length; $i=$i+2) {
  61. if (($pogo[$i] -eq $arch) -and ($pogo[$i+1] -eq $flavor)) {
  62. $doPogo=$True
  63. }
  64. }
  65. if ($doPogo) {
  66. WriteMessage "Building pogo for $arch $flavor"
  67. ExecuteCommand($pogocmd);
  68. }
  69. # run test
  70. ExecuteCommand("$bvtcmdpath -$arch$flavor");
  71. # check prefast
  72. ExecuteCommand($prefastcmd);
  73. WriteMessage "";
  74. }
  75. exit $global:exitcode