1 $ErrorActionPreference = "Stop" 2 3 if (-not (Test-Path 'C:\build-cache')) { 4 [void](New-Item 'C:\build-cache' -ItemType 'directory') 5 } 6 7 $bname = "php-sdk-$env:BIN_SDK_VER.zip" 8 if (-not (Test-Path "C:\build-cache\$bname")) { 9 Invoke-WebRequest "https://github.com/Microsoft/php-sdk-binary-tools/archive/$bname" -OutFile "C:\build-cache\$bname" 10 } 11 $dname0 = "php-sdk-binary-tools-php-sdk-$env:BIN_SDK_VER" 12 $dname1 = "php-sdk-$env:BIN_SDK_VER" 13 if (-not (Test-Path "C:\build-cache\$dname1")) { 14 Expand-Archive "C:\build-cache\$bname" 'C:\build-cache' 15 Move-Item "C:\build-cache\$dname0" "C:\build-cache\$dname1" 16 } 17 18 $gareleases = Invoke-WebRequest "https://windows.php.net/downloads/releases/releases.json" | ConvertFrom-Json 19 $qareleases = Invoke-WebRequest "https://windows.php.net/downloads/qa/releases.json" | ConvertFrom-Json 20 $garev = [regex]::split($gareleases.$env:PHP_VER.version, '[^\d]')[2] 21 $qarev = [regex]::split($qareleases.$env:PHP_VER.version, '[^\d]')[2] 22 if ($qarev -gt $garev) { 23 $phpversion = $qareleases.$env:PHP_VER.version 24 $phprelease = 'QA' 25 } else { 26 $phpversion = $gareleases.$env:PHP_VER.version 27 $phprelease = 'GA' 28 } 29 30 $ts_part = '' 31 if ($env:TS -eq '0') { 32 $ts_part += '-nts' 33 } 34 $bname = "php-devel-pack-$phpversion$ts_part-Win32-$env:VC-$env:ARCH.zip" 35 if (-not (Test-Path "C:\build-cache\$bname")) { 36 if ($phprelease -eq "GA") { 37 Invoke-WebRequest "https://windows.php.net/downloads/releases/$bname" -OutFile "C:\build-cache\$bname" 38 } else { 39 Invoke-WebRequest "https://windows.php.net/downloads/qa/$bname" -OutFile "C:\build-cache\$bname" 40 } 41 } 42 $dname0 = "php-$phpversion-devel-$env:VC-$env:ARCH" 43 $dname1 = "php-$phpversion$ts_part-devel-$env:VC-$env:ARCH" 44 if (-not (Test-Path "C:\build-cache\$dname1")) { 45 Expand-Archive "C:\build-cache\$bname" 'C:\build-cache' 46 if ($dname0 -ne $dname1) { 47 Move-Item "C:\build-cache\$dname0" "C:\build-cache\$dname1" 48 } 49 } 50 $env:PATH = "C:\build-cache\$dname1;$env:PATH" 51 52 $bname = "php-$phpversion$ts_part-Win32-$env:VC-$env:ARCH.zip" 53 if (-not (Test-Path "C:\build-cache\$bname")) { 54 if ($phprelease -eq "GA") { 55 Invoke-WebRequest "https://windows.php.net/downloads/releases/$bname" -OutFile "C:\build-cache\$bname" 56 } else { 57 Invoke-WebRequest "https://windows.php.net/downloads/qa/$bname" -OutFile "C:\build-cache\$bname" 58 } 59 } 60 $dname = "php-$phpversion$ts_part-$env:VC-$env:ARCH" 61 if (-not (Test-Path "C:\build-cache\$dname")) { 62 Expand-Archive "C:\build-cache\$bname" "C:\build-cache\$dname" 63 } 64 $env:PATH = "c:\build-cache\$dname;$env:PATH" 65