forked from PowerShell/openssh-portable
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Zlib Library For Compression Support
- Added an empty project with a script to dynamically download zlib source and compile it into a static library. - Updated other projects to link with new zlib library. - Removed zlib preprocessor workarounds and function stubs now that real library is in place.
- Loading branch information
1 parent
54b0ce9
commit 023b9a4
Showing
30 changed files
with
801 additions
and
454 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
param | ||
( | ||
[string]$ZLibUrl = 'https://zlib.net/zlib1211.zip', | ||
[string]$SourceDirectory = $null, | ||
[string]$TargetLibrary = $null | ||
) | ||
|
||
Set-StrictMode -Version 2.0 | ||
|
||
# Exit immediately if compiled zip file already exist | ||
If (-not [string]::IsNullOrEmpty($TargetLibrary)) | ||
{ | ||
If (Test-Path -LiteralPath $TargetLibrary) | ||
{ | ||
Exit 0 | ||
} | ||
} | ||
|
||
# Workaround that $PSScriptRoot is not support on ps version 2 | ||
If ($PSVersiontable.PSVersion.Major -le 2) | ||
{ | ||
$PSScriptRoot = Split-Path -Parent $MyInvocation.MyCommand.Path | ||
} | ||
|
||
# Allow broad arrange of TLS protocols to do download | ||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 -bor ` | ||
[Net.SecurityProtocolType]::Tls11 -bor ` | ||
[Net.SecurityProtocolType]::Tls | ||
|
||
# Download Zlib to local directory | ||
$ZlibZipLocalPath = Join-Path ([System.IO.Path]::GetTempPath()) 'Zlib.zip' | ||
Invoke-WebRequest -Uri $ZLibUrl -OutFile $ZlibZipLocalPath | ||
|
||
|
||
# Set the project directory | ||
If ([string]::IsNullOrEmpty($SourceDirectory)) | ||
{ | ||
$SourceDirectory = Join-Path $PSScriptRoot 'zlib' | ||
} | ||
|
||
# Ensure the destination directory exists | ||
New-Item -ItemType Directory $SourceDirectory -ErrorAction SilentlyContinue | Out-Null | ||
|
||
# Expand the zip file | ||
$ZlibTempDir = Join-Path ([System.IO.Path]::GetTempPath()) 'Zlib' | ||
Expand-Archive -Path $ZlibZipLocalPath -DestinationPath $ZlibTempDir -Force -ErrorAction SilentlyContinue | ||
$SourceDirectory = Get-Item $SourceDirectory | Select-Object -ExpandProperty FullName | ||
Get-ChildItem -Path "${ZlibTempDir}\*\*.c" | Copy-Item -Destination $SourceDirectory -Force | ||
Get-ChildItem -Path "${ZlibTempDir}\*\*.h" | Copy-Item -Destination $SourceDirectory -Force | ||
|
||
# Cleanup local zip file | ||
Remove-Item $ZlibZipLocalPath -Force -ErrorAction SilentlyContinue |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.