summaryrefslogtreecommitdiffstats
path: root/.azure-pipelines/openssl-build.yml
blob: 8aab7ea0b94193b0b6bb0079ff5dd2601e79d55f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
name: $(SourceTag)_$(Date:yyyyMMdd)$(Rev:.rr)

variables:
  IntDir: '$(Build.BinariesDirectory)'
  OutDir: '$(Build.ArtifactStagingDirectory)'

  # MUST BE SET AT QUEUE TIME
  # SigningCertificate: 'Python Software Foundation'
  # SourcesRepo: 'https://github.com/python/cpython-source-deps'
  # SourceTag: 'openssl-1.1.1k'

jobs:
- job: Build_SSL
  displayName: OpenSSL
  pool:
    name: 'Windows Release'
    #vmImage: windows-latest

  strategy:
    matrix:
      win32:
        Platform: 'win32'
        VCPlatform: 'amd64_x86'
        OpenSSLPlatform: 'VC-WIN32 no-asm'
      amd64:
        Platform: 'amd64'
        VCPlatform: 'amd64'
        OpenSSLPlatform: 'VC-WIN64A-masm'
      arm32:
        Platform: 'arm32'
        VCPlatform: 'amd64_arm'
        OpenSSLPlatform: 'VC-WIN32-ARM'
      arm64:
        Platform: 'arm64'
        VCPlatform: 'amd64_arm64'
        OpenSSLPlatform: 'VC-WIN64-ARM'

  workspace:
    clean: all

  steps:
    - checkout: none

    - template: ./find-tools.yml

    - powershell: |
        git clone $(SourcesRepo) -b $(SourceTag) --depth 1 .
      displayName: 'Check out OpenSSL sources'

    - powershell: |
        $f = gi ms\uplink.c
        $c1 = gc $f
        $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*/)'
        if ($c2 -ne $c1) {
            $c2 | Out-File $f -Encoding ASCII
        } else {
            Write-Host '##warning Failed to patch uplink.c'
        }
      displayName: 'Apply uplink.c patch'

    - script: |
        call "$(vcvarsall)" $(VCPlatform)
        perl "$(Build.SourcesDirectory)\Configure" $(OpenSSLPlatform)
        nmake
      workingDirectory: '$(IntDir)'
      displayName: 'Build OpenSSL'

    - script: |
        call "$(vcvarsall)" $(VCPlatform)
        signtool sign /q /a /n "$(SigningCertificate)" /fd sha256 /tr http://timestamp.digicert.com/ /td sha256 /d "OpenSSL for Python" *.dll
      workingDirectory: '$(IntDir)'
      displayName: 'Sign OpenSSL Build'
      condition: and(succeeded(), variables['SigningCertificate'])

    - task: CopyFiles@2
      displayName: 'Copy built libraries for upload'
      inputs:
        SourceFolder: '$(IntDir)'
        Contents: |
          lib*.dll
          lib*.pdb
          lib*.lib
          include\openssl\*.h
        TargetFolder: '$(OutDir)'

    - task: CopyFiles@2
      displayName: 'Copy header files for upload'
      inputs:
        SourceFolder: '$(Build.SourcesDirectory)'
        Contents: |
          include\openssl\*
        TargetFolder: '$(OutDir)'

    - task: CopyFiles@2
      displayName: 'Copy applink files for upload'
      inputs:
        SourceFolder: '$(Build.SourcesDirectory)\ms'
        Contents: applink.c
        TargetFolder: '$(OutDir)\include'

    - task: CopyFiles@2
      displayName: 'Copy LICENSE for upload'
      inputs:
        SourceFolder: '$(Build.SourcesDirectory)'
        Contents: LICENSE
        TargetFolder: '$(OutDir)'

    - publish: '$(OutDir)'
      artifact: '$(Platform)'
      displayName: 'Publishing $(Platform)'