1name: $(SourceTag)_$(Date:yyyyMMdd)$(Rev:.rr)
2
3variables:
4  IntDir: '$(Build.BinariesDirectory)'
5  OutDir: '$(Build.ArtifactStagingDirectory)'
6
7  # MUST BE SET AT QUEUE TIME
8  # SigningCertificate: 'Python Software Foundation'
9  # SourcesRepo: 'https://github.com/python/cpython-source-deps'
10  # SourceTag: 'openssl-1.1.1k'
11
12jobs:
13- job: Build_SSL
14  displayName: OpenSSL
15  pool:
16    name: 'Windows Release'
17    #vmImage: windows-latest
18
19  strategy:
20    matrix:
21      win32:
22        Platform: 'win32'
23        VCPlatform: 'amd64_x86'
24        OpenSSLPlatform: 'VC-WIN32 no-asm'
25      amd64:
26        Platform: 'amd64'
27        VCPlatform: 'amd64'
28        OpenSSLPlatform: 'VC-WIN64A-masm'
29      arm32:
30        Platform: 'arm32'
31        VCPlatform: 'amd64_arm'
32        OpenSSLPlatform: 'VC-WIN32-ARM'
33      arm64:
34        Platform: 'arm64'
35        VCPlatform: 'amd64_arm64'
36        OpenSSLPlatform: 'VC-WIN64-ARM'
37
38  workspace:
39    clean: all
40
41  steps:
42    - checkout: none
43
44    - template: ./find-tools.yml
45
46    - powershell: |
47        git clone $(SourcesRepo) -b $(SourceTag) --depth 1 .
48      displayName: 'Check out OpenSSL sources'
49
50    - powershell: |
51        $f = gi ms\uplink.c
52        $c1 = gc $f
53        $c2 = $c1 -replace '\(\(h = GetModuleHandle\(NULL\)\) == NULL\)', '((h = GetModuleHandleA("_ssl.pyd")) == NULL) if ((h = GetModuleHandleA("_ssl_d.pyd")) == NULL) if ((h = GetModuleHandle(NULL)) == NULL /*patched*/)'
54        if ($c2 -ne $c1) {
55            $c2 | Out-File $f -Encoding ASCII
56        } else {
57            Write-Host '##warning Failed to patch uplink.c'
58        }
59      displayName: 'Apply uplink.c patch'
60
61    - script: |
62        call "$(vcvarsall)" $(VCPlatform)
63        perl "$(Build.SourcesDirectory)\Configure" $(OpenSSLPlatform)
64        nmake
65      workingDirectory: '$(IntDir)'
66      displayName: 'Build OpenSSL'
67
68    - script: |
69        call "$(vcvarsall)" $(VCPlatform)
70        signtool sign /q /a /n "$(SigningCertificate)" /fd sha256 /tr http://timestamp.digicert.com/ /td sha256 /d "OpenSSL for Python" *.dll
71      workingDirectory: '$(IntDir)'
72      displayName: 'Sign OpenSSL Build'
73      condition: and(succeeded(), variables['SigningCertificate'])
74
75    - task: CopyFiles@2
76      displayName: 'Copy built libraries for upload'
77      inputs:
78        SourceFolder: '$(IntDir)'
79        Contents: |
80          lib*.dll
81          lib*.pdb
82          lib*.lib
83          include\openssl\*.h
84        TargetFolder: '$(OutDir)'
85
86    - task: CopyFiles@2
87      displayName: 'Copy header files for upload'
88      inputs:
89        SourceFolder: '$(Build.SourcesDirectory)'
90        Contents: |
91          include\openssl\*
92        TargetFolder: '$(OutDir)'
93
94    - task: CopyFiles@2
95      displayName: 'Copy applink files for upload'
96      inputs:
97        SourceFolder: '$(Build.SourcesDirectory)\ms'
98        Contents: applink.c
99        TargetFolder: '$(OutDir)\include'
100
101    - task: CopyFiles@2
102      displayName: 'Copy LICENSE for upload'
103      inputs:
104        SourceFolder: '$(Build.SourcesDirectory)'
105        Contents: LICENSE
106        TargetFolder: '$(OutDir)'
107
108    - publish: '$(OutDir)'
109      artifact: '$(Platform)'
110      displayName: 'Publishing $(Platform)'
111