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: 'libffi-3.4.2'
11
12jobs:
13- job: Build_LibFFI
14  displayName: LibFFI
15  pool:
16    vmImage: windows-latest
17
18  workspace:
19    clean: all
20
21  steps:
22    - checkout: none
23
24    - template: ./find-tools.yml
25
26    - powershell: |
27       mkdir -Force "$(IntDir)\script"
28       iwr "https://github.com/python/cpython/raw/main/PCbuild/prepare_libffi.bat" `
29           -outfile "$(IntDir)\script\prepare_libffi.bat"
30      displayName: 'Download build script'
31
32    - powershell: |
33        git clone $(SourcesRepo) -b $(SourceTag) --depth 1 -c core.autocrlf=false -c core.eol=lf .
34      displayName: 'Check out LibFFI sources'
35
36    - script: 'prepare_libffi.bat --install-cygwin'
37      workingDirectory: '$(IntDir)\script'
38      displayName: 'Install Cygwin and build'
39      env:
40        VCVARSALL: '$(vcvarsall)'
41        LIBFFI_SOURCE: '$(Build.SourcesDirectory)'
42        LIBFFI_OUT: '$(OutDir)'
43
44    - powershell: |
45       if ((gci *\*.dll).Count -lt 4) {
46           Write-Error "Did not generate enough DLL files"
47       }
48       if ((gci *\Include\ffi.h).Count -lt 4) {
49           Write-Error "Did not generate enough include files"
50       }
51      failOnStderr: true
52      workingDirectory: '$(OutDir)'
53      displayName: 'Verify files were created'
54
55    - publish: '$(OutDir)'
56      artifact: 'unsigned'
57      displayName: 'Publish unsigned build'
58
59- job: Sign_LibFFI
60  displayName: Sign LibFFI
61  dependsOn: Build_LibFFI
62  pool:
63    name: 'Windows Release'
64
65  workspace:
66    clean: all
67
68  steps:
69    - checkout: none
70    - download: current
71      artifact: unsigned
72
73    - template: ./find-tools.yml
74
75    - powershell: |
76        signtool sign /q /a `
77            /n "Python Software Foundation" `
78            /fd sha256 `
79            /tr http://timestamp.digicert.com/ /td sha256 `
80            /d "LibFFI for Python" `
81            (gci "$(Pipeline.Workspace)\unsigned\*.dll" -r)
82      displayName: 'Sign files'
83
84    - publish: '$(Pipeline.Workspace)\unsigned'
85      artifact: 'libffi'
86      displayName: 'Publish libffi'
87