1parameters:
2  ShouldPGO: false
3
4steps:
5- template: ./checkout.yml
6
7- powershell: |
8    $d = (.\PCbuild\build.bat -V) | %{ if($_ -match '\s+(\w+):\s*(.+)\s*$') { @{$Matches[1] = $Matches[2];} }};
9    Write-Host "##vso[task.setvariable variable=VersionText]$($d.PythonVersion)"
10    Write-Host "##vso[task.setvariable variable=VersionNumber]$($d.PythonVersionNumber)"
11    Write-Host "##vso[task.setvariable variable=VersionHex]$($d.PythonVersionHex)"
12    Write-Host "##vso[task.setvariable variable=VersionUnique]$($d.PythonVersionUnique)"
13    Write-Host "##vso[build.addbuildtag]$($d.PythonVersion)"
14    Write-Host "##vso[build.addbuildtag]$($d.PythonVersion)-$(Name)"
15  displayName: 'Extract version numbers'
16
17- ${{ if eq(parameters.ShouldPGO, 'false') }}:
18  - powershell: |
19      $env:SigningCertificate = $null
20      .\PCbuild\build.bat -v -p $(Platform) -c $(Configuration)
21    displayName: 'Run build'
22    env:
23      IncludeUwp: true
24      Py_OutDir: '$(Build.BinariesDirectory)\bin'
25
26- ${{ if eq(parameters.ShouldPGO, 'true') }}:
27  - powershell: |
28      $env:SigningCertificate = $null
29      .\PCbuild\build.bat -v -p $(Platform) --pgo
30    displayName: 'Run build with PGO'
31    env:
32      IncludeUwp: true
33      Py_OutDir: '$(Build.BinariesDirectory)\bin'
34
35- powershell: |
36    $kitroot = (gp 'HKLM:\SOFTWARE\Microsoft\Windows Kits\Installed Roots\').KitsRoot10
37    $tool = (gci -r "$kitroot\Bin\*\x64\signtool.exe" | sort FullName -Desc | select -First 1)
38    if (-not $tool) {
39      throw "SDK is not available"
40    }
41    Write-Host "##vso[task.prependpath]$($tool.Directory)"
42  displayName: 'Add WinSDK tools to path'
43
44- powershell: |
45    $env:SigningCertificate = $null
46    $(_HostPython) PC\layout -vv -b "$(Build.BinariesDirectory)\bin" -t "$(Build.BinariesDirectory)\catalog" --catalog "${env:CAT}.cdf" --preset-default --arch $(Arch)
47    makecat "${env:CAT}.cdf"
48    del "${env:CAT}.cdf"
49    if (-not (Test-Path "${env:CAT}.cat")) {
50      throw "Failed to build catalog file"
51    }
52  displayName: 'Generate catalog'
53  env:
54    CAT: $(Build.BinariesDirectory)\bin\$(Arch)\python
55    PYTHON_HEXVERSION: $(VersionHex)
56
57- task: PublishPipelineArtifact@0
58  displayName: 'Publish binaries'
59  condition: and(succeeded(), not(and(eq(variables['Configuration'], 'Release'), variables['SigningCertificate'])))
60  inputs:
61    targetPath: '$(Build.BinariesDirectory)\bin\$(Arch)'
62    artifactName: bin_$(Name)
63
64- task: PublishPipelineArtifact@0
65  displayName: 'Publish binaries for signing'
66  condition: and(succeeded(), and(eq(variables['Configuration'], 'Release'), variables['SigningCertificate']))
67  inputs:
68    targetPath: '$(Build.BinariesDirectory)\bin\$(Arch)'
69    artifactName: unsigned_bin_$(Name)
70
71- task: CopyFiles@2
72  displayName: 'Layout Artifact: symbols'
73  inputs:
74    sourceFolder: $(Build.BinariesDirectory)\bin\$(Arch)
75    targetFolder: $(Build.ArtifactStagingDirectory)\symbols\$(Name)
76    flatten: true
77    contents: |
78      **\*.pdb
79
80- task: PublishBuildArtifacts@1
81  displayName: 'Publish Artifact: symbols'
82  inputs:
83    PathToPublish: '$(Build.ArtifactStagingDirectory)\symbols'
84    ArtifactName: symbols
85