diff --git a/.azdo/ci.yml b/.azdo/ci.yml index 624b9b5129d..04c2c64640f 100644 --- a/.azdo/ci.yml +++ b/.azdo/ci.yml @@ -11,8 +11,36 @@ pr: - latestw_all stages: +- stage: BuildDependencies + displayName: Build Dependencies + jobs: + - job: InstallDeps_x64 + displayName: Install vcpkg Dependencies (x64) + pool: + name: PS-PowerShell-x64 + demands: + - ImageOverride -equals PSMMS2022-OpenSSH-Secure + steps: + - template: ./templates/install-vcpkg-dependencies.yml + parameters: + triplet: x64-custom + artifactSuffix: x64 + + - job: InstallDeps_x86 + displayName: Install vcpkg Dependencies (x86) + pool: + name: PS-PowerShell-x64 + demands: + - ImageOverride -equals PSMMS2022-OpenSSH-Secure + steps: + - template: ./templates/install-vcpkg-dependencies.yml + parameters: + triplet: x86-custom + artifactSuffix: x86 + - stage: Build displayName: Build Win32-OpenSSH + dependsOn: BuildDependencies jobs: - job: BuildPkg_x64 displayName: Build Package (x64) @@ -26,6 +54,7 @@ stages: nativeHostArch: x64 buildOutputDir: x64 artifactSuffix: x64 + dependenciesArtifactName: vcpkg-dependencies-x64 includeConfig: true - job: BuildPkg_x86 @@ -40,6 +69,7 @@ stages: nativeHostArch: x86 buildOutputDir: Win32 artifactSuffix: x86 + dependenciesArtifactName: vcpkg-dependencies-x86 - stage: Test displayName: Test Win32-OpenSSH diff --git a/.azdo/templates/build-win32-openssh-job.yml b/.azdo/templates/build-win32-openssh-job.yml index 21c10db14f2..016a7dd21be 100644 --- a/.azdo/templates/build-win32-openssh-job.yml +++ b/.azdo/templates/build-win32-openssh-job.yml @@ -5,36 +5,27 @@ parameters: type: string - name: artifactSuffix type: string +- name: dependenciesArtifactName + type: string - name: includeConfig type: boolean default: false steps: - pwsh: | - # Compare LibreSSL versions in vcpkg.json and add-resource-file.patch - $vcpkgObj = Get-Content "$(Build.SourcesDirectory)/contrib/win32/openssh/vcpkg.json" | ConvertFrom-Json - $libresslVersionJson = $vcpkgObj | Select-Object -ExpandProperty overrides | Where-Object { $_.name -eq 'libressl' } | Select-Object -ExpandProperty version - - # resource file version needs to be trimmed (e.g. 4.0.0.0 to 4.0.0) - $patchContent = Get-Content "$(Build.SourcesDirectory)/contrib/win32/openssh/vcpkg_overlay_ports/libressl/add-version-file.patch" - $libresslVersionPatch = ($patchContent -join "`n" | Select-String -Pattern '"FileVersion",\s*"(\d+\.\d+\.\d+\.\d+)"' -AllMatches).Matches | ForEach-Object { $_.Groups[1].Value } - $libresslVersionPatchParts = $libresslVersionPatch -split '\.' - $libresslVersionPatchShort = ($libresslVersionPatchParts[0..2] -join '.') - - if ($libresslVersionJson -ne $libresslVersionPatchShort) { - Write-Error "LibreSSL version mismatch: vcpkg.json has $libresslVersionJson, patch file has $libresslVersionPatch" - exit 1 - } else { - Write-Verbose -Verbose "LibreSSL versions match: $libresslVersionJson" - } - displayName: 'Verify version info' - -- pwsh: |- + $ErrorActionPreference = 'Stop' git clone https://github.com/microsoft/vcpkg cd vcpkg & ./bootstrap-vcpkg.bat & ./vcpkg.exe integrate install - displayName: Install vcpkg + displayName: Install and bootstrap vcpkg + +- task: DownloadPipelineArtifact@2 + displayName: 'Download vcpkg dependencies (${{ parameters.dependenciesArtifactName }})' + inputs: + buildType: current + artifactName: ${{ parameters.dependenciesArtifactName }} + targetPath: '$(Build.SourcesDirectory)/contrib/win32/openssh/vcpkg_installed' - pwsh: | $nativeArch = '${{ parameters.nativeHostArch }}' diff --git a/.azdo/templates/install-vcpkg-dependencies.yml b/.azdo/templates/install-vcpkg-dependencies.yml new file mode 100644 index 00000000000..d9360b6e0e2 --- /dev/null +++ b/.azdo/templates/install-vcpkg-dependencies.yml @@ -0,0 +1,66 @@ +parameters: +- name: triplet + type: string +- name: artifactSuffix + type: string + +steps: +- pwsh: | + # Compare LibreSSL versions in vcpkg.json and add-resource-file.patch + $vcpkgObj = Get-Content "$(Build.SourcesDirectory)/contrib/win32/openssh/vcpkg.json" | ConvertFrom-Json + $libresslVersionJson = $vcpkgObj | Select-Object -ExpandProperty overrides | Where-Object { $_.name -eq 'libressl' } | Select-Object -ExpandProperty version + + # resource file version needs to be trimmed (e.g. 4.0.0.0 to 4.0.0) + $patchContent = Get-Content "$(Build.SourcesDirectory)/contrib/win32/openssh/vcpkg_overlay_ports/libressl/add-version-file.patch" + $libresslVersionPatch = ($patchContent -join "`n" | Select-String -Pattern '"FileVersion",\s*"(\d+\.\d+\.\d+\.\d+)"' -AllMatches).Matches | ForEach-Object { $_.Groups[1].Value } + $libresslVersionPatchParts = $libresslVersionPatch -split '\.' + $libresslVersionPatchShort = ($libresslVersionPatchParts[0..2] -join '.') + + if ($libresslVersionJson -ne $libresslVersionPatchShort) { + Write-Error "LibreSSL version mismatch: vcpkg.json has $libresslVersionJson, patch file has $libresslVersionPatch" + exit 1 + } else { + Write-Verbose -Verbose "LibreSSL versions match: $libresslVersionJson" + } + displayName: 'Verify version info' + +- pwsh: | + $ErrorActionPreference = 'Stop' + git clone https://github.com/microsoft/vcpkg + cd vcpkg + & ./bootstrap-vcpkg.bat + & ./vcpkg.exe integrate install + displayName: Install and bootstrap vcpkg + +- pwsh: | + $triplet = '${{ parameters.triplet }}' + Write-Verbose -Verbose "Installing vcpkg dependencies for triplet: $triplet" + + Push-Location "$(Build.SourcesDirectory)/contrib/win32/openssh" + try { + & "$(Build.SourcesDirectory)/vcpkg/vcpkg.exe" install --triplet $triplet --overlay-triplets=.\vcpkg_triplets --overlay-ports=.\vcpkg_overlay_ports + if ($LASTEXITCODE -ne 0) { + throw "vcpkg install failed with exit code $LASTEXITCODE" + } + } finally { + Pop-Location + } + displayName: Install vcpkg dependencies (${{ parameters.triplet }}) + +- pwsh: | + $artifactSuffix = '${{ parameters.artifactSuffix }}' + $vcpkgInstalledPath = "$(Build.SourcesDirectory)/contrib/win32/openssh/vcpkg_installed" + + if (Test-Path -Path $vcpkgInstalledPath) { + Write-Verbose -Verbose "vcpkg_installed directory contents:" + Get-ChildItem -Path $vcpkgInstalledPath -Recurse -Depth 2 | Select-Object -First 50 + + # Upload vcpkg dependencies artifact + Write-Verbose -Verbose -Message "Uploading vcpkg dependencies artifact" + $artifactName = "vcpkg-dependencies-$artifactSuffix" + Write-Host "##vso[artifact.upload containerfolder=$artifactName;artifactname=$artifactName;]$vcpkgInstalledPath" + } else { + Write-Error "vcpkg_installed directory not found at: $vcpkgInstalledPath" + exit 1 + } + displayName: Upload vcpkg dependencies (${{ parameters.artifactSuffix }})