Skip to content

Commit 81fd953

Browse files
committed
Use prebuilt LibreSSL binaries on Windows
1 parent 4df7266 commit 81fd953

File tree

5 files changed

+42
-71
lines changed

5 files changed

+42
-71
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
$version = "3.9.1"
2+
3+
$arch = [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture
4+
if ($arch -ieq "X64") { $zipArch = "x64" }
5+
elseif ($arch -ieq "Arm64") { $zipArch = "ARM64" }
6+
else { throw "Unsupported architecture: $arch" }
7+
8+
$zipName = "libressl_v${version}_windows_${zipArch}.zip"
9+
$url = "https://github.com/libressl/portable/releases/download/v${version}/${zipName}"
10+
11+
$tempDir = Join-Path $env:TEMP "libressl"
12+
if (-not (Test-Path $tempDir)) { New-Item -ItemType Directory -Path $tempDir | Out-Null }
13+
14+
Invoke-WebRequest $url -OutFile "$tempDir\$zipName"
15+
Expand-Archive -Force -Path "$tempDir\$zipName" -DestinationPath "$tempDir\libressl"
16+
17+
$repoRoot = Split-Path $PSScriptRoot
18+
Copy-Item -Force "$tempDir\libressl\lib\ssl.lib" "$repoRoot\ssl.lib"
19+
Copy-Item -Force "$tempDir\libressl\lib\crypto.lib" "$repoRoot\crypto.lib"
20+
Copy-Item -Force "$tempDir\libressl\lib\tls.lib" "$repoRoot\tls.lib"

.github/workflows/breakage-against-windows-ponyc-latest.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,18 @@ jobs:
2020
Invoke-WebRequest https://dl.cloudsmith.io/public/ponylang/releases/raw/versions/latest/corral-x86-64-pc-windows-msvc.zip -OutFile C:\corral.zip;
2121
Expand-Archive -Force -Path C:\corral.zip -DestinationPath C:\ponyc;
2222
$env:PATH = 'C:\ponyc\bin;' + $env:PATH;
23-
- name: cache SSL libs
24-
id: restore-libs
23+
- name: Cache LibreSSL libs
24+
id: cache-libressl
2525
uses: actions/cache@v5.0.3
2626
with:
2727
path: |
2828
ssl.lib
2929
crypto.lib
3030
tls.lib
31-
key: rootlibs-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('make.ps1') }}
32-
- name: build SSL libs
33-
if: steps.restore-libs.outputs.cache-hit != 'true'
34-
run: .\make.ps1 -Command libs 2>&1;
31+
key: libressl-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('.ci-scripts/windows-install-libressl.ps1') }}
32+
- name: Install LibreSSL
33+
if: steps.cache-libressl.outputs.cache-hit != 'true'
34+
run: .ci-scripts\windows-install-libressl.ps1
3535
- name: Test
3636
run: |
3737
$env:PATH = 'C:\ponyc\bin;' + $env:PATH;

.github/workflows/pr.yml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,18 +69,18 @@ jobs:
6969
Invoke-WebRequest https://dl.cloudsmith.io/public/ponylang/releases/raw/versions/latest/corral-x86-64-pc-windows-msvc.zip -OutFile C:\corral.zip;
7070
Expand-Archive -Force -Path C:\corral.zip -DestinationPath C:\ponyc;
7171
$env:PATH = 'C:\ponyc\bin;' + $env:PATH;
72-
- name: cache SSL libs
73-
id: restore-libs
72+
- name: Cache LibreSSL libs
73+
id: cache-libressl
7474
uses: actions/cache@v5.0.3
7575
with:
7676
path: |
7777
ssl.lib
7878
crypto.lib
7979
tls.lib
80-
key: rootlibs-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('make.ps1') }}
81-
- name: build SSL libs
82-
if: steps.restore-libs.outputs.cache-hit != 'true'
83-
run: .\make.ps1 -Command libs 2>&1;
80+
key: libressl-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('.ci-scripts/windows-install-libressl.ps1') }}
81+
- name: Install LibreSSL
82+
if: steps.cache-libressl.outputs.cache-hit != 'true'
83+
run: .ci-scripts\windows-install-libressl.ps1
8484
- name: Test
8585
run: |
8686
$env:PATH = 'C:\ponyc\bin;' + $env:PATH;
@@ -98,18 +98,18 @@ jobs:
9898
Invoke-WebRequest https://dl.cloudsmith.io/public/ponylang/releases/raw/versions/latest/corral-arm64-pc-windows-msvc.zip -OutFile C:\corral.zip;
9999
Expand-Archive -Force -Path C:\corral.zip -DestinationPath C:\ponyc;
100100
$env:PATH = 'C:\ponyc\bin;' + $env:PATH;
101-
- name: cache SSL libs
102-
id: restore-libs
101+
- name: Cache LibreSSL libs
102+
id: cache-libressl
103103
uses: actions/cache@v5.0.3
104104
with:
105105
path: |
106106
ssl.lib
107107
crypto.lib
108108
tls.lib
109-
key: rootlibs-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('make.ps1') }}
110-
- name: build SSL libs
111-
if: steps.restore-libs.outputs.cache-hit != 'true'
112-
run: .\make.ps1 -Command libs 2>&1;
109+
key: libressl-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('.ci-scripts/windows-install-libressl.ps1') }}
110+
- name: Install LibreSSL
111+
if: steps.cache-libressl.outputs.cache-hit != 'true'
112+
run: .ci-scripts\windows-install-libressl.ps1
113113
- name: Test
114114
run: |
115115
$env:PATH = 'C:\ponyc\bin;' + $env:PATH;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## Use prebuilt LibreSSL binaries on Windows
2+
3+
The `libs` command has been removed from `make.ps1`. CI now downloads prebuilt LibreSSL static libraries directly from the [LibreSSL GitHub releases](https://github.com/libressl/portable/releases) instead of building from source. Windows users who were using `make.ps1 -Command libs` to build LibreSSL locally can download prebuilt binaries from the same location. Prebuilt binaries are available for x86-64 and ARM64.

make.ps1

Lines changed: 1 addition & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ else
5353
throw "Invalid -Config path '$Config'; must be one of (Debug, Release)."
5454
}
5555

56-
$libsDir = Join-Path -Path $rootDir -ChildPath "build/libs"
57-
5856
if (($Version -eq "") -and (Test-Path -Path "$rootDir\VERSION"))
5957
{
6058
$Version = (Get-Content "$rootDir\VERSION") + "-" + (& git 'rev-parse' '--short' '--verify' 'HEAD^')
@@ -88,45 +86,6 @@ if (($Command -ne "clean") -and (Test-Path -Path "$rootDir\VERSION"))
8886
}
8987
}
9088

91-
function BuildLibs
92-
{
93-
# When upgrading, change $libreSsl, $libreSslLib, and the copied libs below
94-
$libreSsl = "libressl-3.9.1"
95-
96-
if (-not ((Test-Path "$rootDir/crypto.lib") -and (Test-Path "$rootDir/ssl.lib")))
97-
{
98-
$libreSslSrc = Join-Path -Path $libsDir -ChildPath $libreSsl
99-
100-
if (-not (Test-Path $libreSslSrc))
101-
{
102-
$libreSslTgz = "$libreSsl.tar.gz"
103-
$libreSslTgzTgt = Join-Path -Path $libsDir -ChildPath $libreSslTgz
104-
if (-not (Test-Path $libreSslTgzTgt)) { Invoke-WebRequest -TimeoutSec 300 -Uri "https://cdn.openbsd.org/pub/OpenBSD/LibreSSL/$libreSslTgz" -OutFile $libreSslTgzTgt }
105-
tar -xvzf "$libreSslTgzTgt" -C "$libsDir"
106-
if ($LastExitCode -ne 0) { throw "Error downloading and extracting $libreSslTgz" }
107-
}
108-
109-
$libreSslLib = Join-Path -Path $libsDir -ChildPath "lib/ssl-53.lib"
110-
111-
if (-not (Test-Path $libreSslLib))
112-
{
113-
Push-Location $libreSslSrc
114-
(Get-Content "$libreSslSrc\CMakeLists.txt").replace('add_definitions(-Dinline=__inline)', "add_definitions(-Dinline=__inline)`nadd_definitions(-DPATH_MAX=255)") | Set-Content "$libreSslSrc\CMakeLists.txt"
115-
if ($Arch -ieq 'arm64') { $cmakeArch = 'ARM64' } else { $cmakeArch = 'x64' }
116-
cmake.exe $libreSslSrc -Thost=x64 -A $cmakeArch -DCMAKE_INSTALL_PREFIX="$libsDir" -DCMAKE_BUILD_TYPE="Release"
117-
if ($LastExitCode -ne 0) { Pop-Location; throw "Error configuring $libreSsl" }
118-
cmake.exe --build . --target install --config Release
119-
if ($LastExitCode -ne 0) { Pop-Location; throw "Error building $libreSsl" }
120-
Pop-Location
121-
}
122-
123-
# copy to the root dir (i.e. PONYPATH) for linking
124-
Copy-Item -Force -Path "$libsDir/lib/ssl.lib" -Destination "$rootDir/ssl.lib"
125-
Copy-Item -Force -Path "$libsDir/lib/crypto.lib" -Destination "$rootDir/crypto.lib"
126-
Copy-Item -Force -Path "$libsDir/lib/tls.lib" -Destination "$rootDir/tls.lib"
127-
}
128-
}
129-
13089
function BuildTarget
13190
{
13291
$binaryFile = Join-Path -Path $buildDir -ChildPath "$target.exe"
@@ -278,19 +237,8 @@ switch ($Command.ToLower())
278237
break
279238
}
280239

281-
"libs"
282-
{
283-
if (-not (Test-Path $libsDir))
284-
{
285-
mkdir "$libsDir"
286-
}
287-
288-
BuildLibs
289-
break
290-
}
291-
292240
default
293241
{
294-
throw "Unknown command '$Command'; must be one of (libs, build, test, install, package, clean, distclean)."
242+
throw "Unknown command '$Command'; must be one of (build, test, install, package, clean, distclean)."
295243
}
296244
}

0 commit comments

Comments
 (0)