diff --git a/.github/fixtures/win7-openssl-cache/Cargo.lock b/.github/fixtures/win7-openssl-cache/Cargo.lock new file mode 100644 index 0000000000..6090d35511 --- /dev/null +++ b/.github/fixtures/win7-openssl-cache/Cargo.lock @@ -0,0 +1,72 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "cc" +version = "1.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54413ede23c2daf518f35156dfde027feb2374004d63bd497f983c8db9c0e313" +dependencies = [ + "find-msvc-tools", + "shlex", +] + +[[package]] +name = "find-msvc-tools" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef25905e51abafe4dcea6c15fec58c57b601cdbd0ee53d22ea1d3016c587d39b" + +[[package]] +name = "libc" +version = "0.2.189" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3eaf3ede3fee6db1a4c2ee091bf8a8b4dccdc6d17f656fb07896ee72867612f2" + +[[package]] +name = "openssl-src" +version = "300.6.1+3.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46eb8fb9fb3b61ce1c0f8a026c4c1a0714d3a9e138e7fbde78753ce2babc3846" +dependencies = [ + "cc", +] + +[[package]] +name = "openssl-sys" +version = "0.9.117" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b47e7e6bb2c38cd930d25a23b40fa52e068c10e85f3e03a7f5ba5aaca5713695" +dependencies = [ + "cc", + "libc", + "openssl-src", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "pkg-config" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6b464fbc74e149a392436b17d523f769e057cb6877f6a5c4618bc6f11800548" + +[[package]] +name = "shlex" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba" + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + +[[package]] +name = "win7-openssl-cache" +version = "0.0.0" +dependencies = [ + "openssl-sys", +] diff --git a/.github/fixtures/win7-openssl-cache/Cargo.toml b/.github/fixtures/win7-openssl-cache/Cargo.toml new file mode 100644 index 0000000000..c3447532fe --- /dev/null +++ b/.github/fixtures/win7-openssl-cache/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "win7-openssl-cache" +version = "0.0.0" +edition = "2021" +publish = false + +[dependencies] +openssl-sys = { version = "=0.9.117", features = ["vendored"] } + +[workspace] diff --git a/.github/fixtures/win7-openssl-cache/src/main.rs b/.github/fixtures/win7-openssl-cache/src/main.rs new file mode 100644 index 0000000000..d6e233ce88 --- /dev/null +++ b/.github/fixtures/win7-openssl-cache/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + let _ = unsafe { openssl_sys::OpenSSL_version_num() }; +} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b9ae0a9e74..1ecabc2819 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -444,6 +444,62 @@ jobs: "AWS_LC_SYS_STATIC=1" >> $env:GITHUB_ENV "AWS-LC cache hit: ${{ steps.aws-lc-cache.outputs.cache-hit }}" >> $env:GITHUB_STEP_SUMMARY + - name: Restore prebuilt Win7 OpenSSL + id: openssl-cache + uses: actions/cache@v4 + with: + path: ${{ runner.temp }}/win7-openssl-install + key: win7-openssl-v1-${{ runner.os }}-${{ env.WIN7_NIGHTLY_TOOLCHAIN }}-${{ hashFiles('Cargo.lock', '.github/fixtures/win7-openssl-cache/Cargo.lock') }} + + - name: Build Win7 OpenSSL cache + if: steps.openssl-cache.outputs.cache-hit != 'true' + shell: pwsh + run: | + $timer = [System.Diagnostics.Stopwatch]::StartNew() + $targetRoot = Join-Path $env:RUNNER_TEMP "win7-openssl-build" + $installRoot = Join-Path $env:RUNNER_TEMP "win7-openssl-install" + cargo build --locked --release ` + --manifest-path .github/fixtures/win7-openssl-cache/Cargo.toml ` + --target x86_64-win7-windows-msvc ` + -Z build-std=std,panic_abort + if ($LASTEXITCODE -ne 0) { + exit $LASTEXITCODE + } + $install = Get-ChildItem $targetRoot -Directory -Recurse -Filter install | + Where-Object { $_.FullName -like "*openssl-build*" } | + Select-Object -First 1 + if (!$install) { + Write-Error "OpenSSL did not create an install directory." + exit 1 + } + New-Item -ItemType Directory -Path $installRoot -Force | Out-Null + Copy-Item -Path (Join-Path $install.FullName "*") -Destination $installRoot -Recurse -Force + $timer.Stop() + "OpenSSL cache build: $([math]::Round($timer.Elapsed.TotalSeconds, 1)) seconds" >> $env:GITHUB_STEP_SUMMARY + env: + CARGO_TARGET_DIR: ${{ runner.temp }}/win7-openssl-build + + - name: Configure prebuilt Win7 OpenSSL + shell: pwsh + run: | + $installRoot = Join-Path $env:RUNNER_TEMP "win7-openssl-install" + if (!(Test-Path (Join-Path $installRoot "include/openssl/ssl.h"))) { + Write-Error "The OpenSSL cache does not contain ssl.h." + exit 1 + } + if (!(Get-ChildItem (Join-Path $installRoot "lib") -Filter "*ssl*.lib")) { + Write-Error "The OpenSSL cache does not contain an SSL library." + exit 1 + } + if (!(Get-ChildItem (Join-Path $installRoot "lib") -Filter "*crypto*.lib")) { + Write-Error "The OpenSSL cache does not contain a crypto library." + exit 1 + } + "OPENSSL_DIR=$installRoot" >> $env:GITHUB_ENV + "OPENSSL_NO_VENDOR=1" >> $env:GITHUB_ENV + "OPENSSL_STATIC=1" >> $env:GITHUB_ENV + "OpenSSL cache hit: ${{ steps.openssl-cache.outputs.cache-hit }}" >> $env:GITHUB_STEP_SUMMARY + - name: Prepare Win7-compatible WebView2 loader shell: pwsh run: ./.github/scripts/prepare-webview2-win7-loader.ps1