|
| 1 | +$ErrorActionPreference = "Stop" |
| 2 | + |
| 3 | +if (-not (Test-Path 'C:\php')) { |
| 4 | + [void](New-Item 'C:\php' -ItemType 'directory') |
| 5 | +} |
| 6 | + |
| 7 | +# PHP SDK |
| 8 | +$bname = "php-sdk-$env:BIN_SDK_VER.zip" |
| 9 | +if (-not (Test-Path C:\php\$bname)) { |
| 10 | + echo "Download: https://github.com/php/php-sdk-binary-tools/archive/$bname" |
| 11 | + Invoke-WebRequest "https://github.com/php/php-sdk-binary-tools/archive/$bname" -OutFile "C:\php\$bname" |
| 12 | +} |
| 13 | +$dname0 = "php-sdk-binary-tools-php-sdk-$env:BIN_SDK_VER" |
| 14 | +$dname1 = "php-sdk-$env:BIN_SDK_VER" |
| 15 | +if (-not (Test-Path "C:\php\$dname1")) { |
| 16 | + Expand-Archive "C:\php\$bname" "C:\php" |
| 17 | + Move-Item "C:\php\$dname0" "C:\php\$dname1" |
| 18 | +} |
| 19 | + |
| 20 | +# PHP releases |
| 21 | +if (-not (Test-Path C:\php\releases.json)) { |
| 22 | + echo "Download: https://windows.php.net/downloads/releases/releases.json" |
| 23 | + Invoke-WebRequest "https://windows.php.net/downloads/releases/releases.json" -OutFile "C:\php\releases.json" |
| 24 | +} |
| 25 | +$php_version = (Get-Content -Path "C:\php\releases.json" | ConvertFrom-Json | ForEach-Object { |
| 26 | + if ($_."$env:PHP_VER") { |
| 27 | + return $_."$env:PHP_VER".version |
| 28 | + } else { |
| 29 | + return "$env:PHP_VER" |
| 30 | + } |
| 31 | +}) |
| 32 | + |
| 33 | +# PHP devel pack: "C:\php\devel" |
| 34 | +$ts_part = '' |
| 35 | +if ('nts' -eq $env:TS) { |
| 36 | + $ts_part = '-nts' |
| 37 | +} |
| 38 | +$bname = "php-devel-pack-$php_version$ts_part-Win32-$env:VS-$env:ARCH.zip" |
| 39 | +if (-not (Test-Path "C:\php\$bname")) { |
| 40 | + try { |
| 41 | + echo "Download: https://windows.php.net/downloads/releases/$bname" |
| 42 | + Invoke-WebRequest "https://windows.php.net/downloads/releases/$bname" -OutFile "C:\php\$bname" |
| 43 | + } catch [System.Net.WebException] { |
| 44 | + echo "Downlaod: https://windows.php.net/downloads/releases/archives/$bname" |
| 45 | + Invoke-WebRequest "https://windows.php.net/downloads/releases/archives/$bname" -OutFile "C:\php\$bname" |
| 46 | + } |
| 47 | +} |
| 48 | +$dname = "php-$php_version-devel-$env:VS-$env:ARCH" |
| 49 | +if (-not (Test-Path "C:\php\devel")) { |
| 50 | + Expand-Archive "C:\php\$bname" 'C:\php' |
| 51 | + if (-not (Test-Path "C:\php\$dname")) { |
| 52 | + $php_normalize_version = $php_version.Split("-")[0] |
| 53 | + $dname = "php-$php_normalize_version-devel-$env:VS-$env:ARCH" |
| 54 | + } |
| 55 | + if (-not (Test-Path "C:\php\devel")) { |
| 56 | + Move-Item "C:\php\$dname" "C:\php\devel" |
| 57 | + } |
| 58 | +} |
| 59 | + |
| 60 | +# PHP binary: "C:\php\bin" |
| 61 | +$bname = "php-$php_version$ts_part-Win32-$env:VS-$env:ARCH.zip" |
| 62 | +if (-not (Test-Path "C:\php\$bname")) { |
| 63 | + try { |
| 64 | + echo "Download: https://windows.php.net/downloads/releases/$bname" |
| 65 | + Invoke-WebRequest "https://windows.php.net/downloads/releases/$bname" -OutFile "C:\php\$bname" |
| 66 | + } catch [System.Net.WebException] { |
| 67 | + echo "Download: https://windows.php.net/downloads/releases/archives/$bname" |
| 68 | + Invoke-WebRequest "https://windows.php.net/downloads/releases/archives/$bname" -OutFile "C:\php\$bname" |
| 69 | + } |
| 70 | +} |
| 71 | +if (-not (Test-Path "C:\php\bin")) { |
| 72 | + Expand-Archive "C:\php\$bname" "C:\php\bin" |
| 73 | +} |
| 74 | + |
| 75 | +# library dependency: "C:\php\deps" |
| 76 | +if ("$env:DEP" -ne "") { |
| 77 | + $bname = "$env:DEP-$env:VS-$env:ARCH.zip" |
| 78 | + if (-not (Test-Path "C:\php\$bname")) { |
| 79 | + echo "Download: https://windows.php.net/downloads/pecl/deps/$bname" |
| 80 | + Invoke-WebRequest "https://windows.php.net/downloads/pecl/deps/$bname" -OutFile "C:\php\$bname" |
| 81 | + Expand-Archive "C:\php\$bname" "C:\php\deps" |
| 82 | + } |
| 83 | +} |
0 commit comments