mirror of
https://github.com/php-win-ext/winlib-builder.git
synced 2026-03-24 09:12:07 +01:00
81 lines
2.6 KiB
PowerShell
81 lines
2.6 KiB
PowerShell
param (
|
|
[Parameter(Mandatory)] [String] $lib,
|
|
[Parameter(Mandatory)] [String] $version,
|
|
[Parameter(Mandatory)] [String] $vs,
|
|
[Parameter(Mandatory)] [String] $arch,
|
|
[Parameter(Mandatory)] [String] $stability
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
$deps = @{
|
|
"curl" = "libssh2", "nghttp2", "openssl", "zlib";
|
|
"cyrus-sasl" = "liblmdb", "openssl", "sqlite3";
|
|
"enchant" = "glib";
|
|
"glib" = "libffi", "libintl", "zlib";
|
|
"libpng" = "zlib";
|
|
"librdkafka" = "libzstd", "openssl", "zlib";
|
|
"libssh2" = "openssl", "zlib";
|
|
"libxml2" = "libiconv";
|
|
"libxslt" = "libiconv", "libxml2";
|
|
"libzip" = "libbzip2", "zlib";
|
|
"net-snmp" = "openssl";
|
|
"openldap" = "openssl", "libsasl";
|
|
"postgresql" = "openssl"
|
|
}
|
|
if ($version -ge "8.0") {
|
|
$deps."libzip" += "liblzma"
|
|
}
|
|
$deps = $deps.$lib
|
|
if (-not $deps) {
|
|
exit
|
|
}
|
|
|
|
$needs = @{}
|
|
$response = Invoke-WebRequest "https://downloads.php.net/~windows/php-sdk/deps/series/packages-$version-$vs-$arch-$stability.txt"
|
|
foreach ($line in $response.Content -split "`r`n") {
|
|
foreach ($dep in $deps) {
|
|
if ($line -match "$dep-(.+)-$vs-$arch.zip") {
|
|
$needs.$dep = $matches[1]
|
|
}
|
|
}
|
|
}
|
|
|
|
New-Item "deps" -ItemType "directory"
|
|
|
|
$baseurl = "https://downloads.php.net/~windows/php-sdk/deps/$vs/$arch"
|
|
foreach ($dep in $needs.GetEnumerator()) {
|
|
Write-Output "Fetching $($dep.Name)-$($dep.Value)"
|
|
$temp = New-TemporaryFile | Rename-Item -NewName {$_.Name + ".zip"} -PassThru
|
|
$url = "$baseurl/$($dep.Name)-$($dep.Value)-$vs-$arch.zip"
|
|
Invoke-WebRequest $url -OutFile $temp
|
|
Expand-Archive $temp -DestinationPath "deps"
|
|
}
|
|
|
|
$deps = $deps | Where-Object {$needs.Keys -NotContains $_}
|
|
if ($deps.Count -gt 0) {
|
|
$needs = @{}
|
|
$response = Invoke-WebRequest "https://downloads.php.net/~windows/pecl/deps/packages.txt"
|
|
foreach ($line in $response.Content -split "`r`n") {
|
|
foreach ($dep in $deps) {
|
|
if ($line -match "$dep-(.+)-$vs-$arch.zip") {
|
|
$needs.$dep = $matches[1]
|
|
}
|
|
}
|
|
}
|
|
|
|
$baseurl = "https://downloads.php.net/~windows/pecl/deps"
|
|
foreach ($dep in $needs.GetEnumerator()) {
|
|
Write-Output "Fetching $($dep.Name)-$($dep.Value)"
|
|
$temp = New-TemporaryFile | Rename-Item -NewName {$_.Name + ".zip"} -PassThru
|
|
$url = "$baseurl/$($dep.Name)-$($dep.Value)-$vs-$arch.zip"
|
|
Invoke-WebRequest $url -OutFile $temp
|
|
Expand-Archive $temp -DestinationPath "deps"
|
|
}
|
|
}
|
|
|
|
$deps = $deps | Where-Object {$needs.Keys -NotContains $_}
|
|
if ($deps.Count -gt 0) {
|
|
throw "dependencies not found: $deps"
|
|
}
|