-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup-sdk.ps1
More file actions
94 lines (78 loc) · 2.93 KB
/
Copy pathsetup-sdk.ps1
File metadata and controls
94 lines (78 loc) · 2.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
param (
[Parameter(Mandatory)] [String] $version,
[Parameter(Mandatory)] [String] $arch,
[Parameter(Mandatory)] [String] $ts
)
$ErrorActionPreference = "Stop"
$versions = @{
"7.0" = "vc14"
"7.1" = "vc14"
"7.2" = "vc15"
"7.3" = "vc15"
"7.4" = "vc15"
"8.0" = "vs16"
"8.1" = "vs16"
"8.2" = "vs16"
"8.3" = "vs16"
"8.4" = "vs17"
"8.5" = "vs17"
}
$vs = $versions.$version
if (-not $vs) {
throw "unsupported version"
}
Write-Output "Install PHP SDK ..."
$temp = New-TemporaryFile | Rename-Item -NewName {$_.Name + ".zip"} -PassThru
$url = "https://github.com//php/php-sdk-binary-tools/archive/refs/tags/php-sdk-2.6.0.zip"
Invoke-WebRequest $url -OutFile $temp
Expand-Archive $temp -DestinationPath "." -Force
Rename-Item "php-sdk-binary-tools-php-sdk-2.6.0" "php-sdk"
$baseurl = "https://windows.php.net/downloads/releases/archives"
$releases = @{
"7.0" = "7.0.33"
"7.1" = "7.1.33"
"7.2" = "7.2.34"
"7.3" = "7.3.33"
}
$phpversion = $releases.$version
if (-not $phpversion) {
$baseurl = "https://windows.php.net/downloads/releases"
$url = "$baseurl/releases.json"
$releases = Invoke-WebRequest $url -UseBasicParsing | ConvertFrom-Json
$phpversion = $releases.$version.version
if (-not $phpversion) {
$baseurl = "https://windows.php.net/downloads/qa"
$url = "$baseurl/releases.json"
$releases = Invoke-WebRequest $url -UseBasicParsing | ConvertFrom-Json
$phpversion = $releases.$version.version
if (-not $phpversion) {
throw "unknown version"
}
}
}
$tspart = if ($ts -eq "nts") {"nts-Win32"} else {"Win32"}
ForEach ($Dir in ("bin","include","lib","share","template"))
{
New-Item -ItemType Directory -Path php-sdk\PHP-$phpversion\$arch\$vs\deps\$Dir | out-null
}
Write-Output "Install PHP SRC $phpversion ..."
$temp = New-TemporaryFile | Rename-Item -NewName {$_.Name + ".zip"} -PassThru
$urlsrc = "https://github.com/php/php-src/archive/refs/heads/PHP-$phpversion.zip";
Invoke-WebRequest $urlsrc -OutFile $temp
Expand-Archive $temp -DestinationPath "php-sdk\PHP-$phpversion\$arch\$vs\"
Rename-Item -Path "php-sdk\PHP-$phpversion\$arch\$vs\php-src-PHP-$phpversion" "PHP-$phpversion"
New-Item -Path "php-sdk\run.bat" | out-null
Set-Content "php-sdk\run.bat" "@echo off `r`n cd PHP-$phpversion\$arch\$vs\PHP-$phpversion"
Write-Output "Install PHP $phpversion ..."
$temp = New-TemporaryFile | Rename-Item -NewName {$_.Name + ".zip"} -PassThru
$fname = "php-$phpversion-$tspart-$vs-$arch.zip"
$url = "$baseurl/$fname"
Invoke-WebRequest $url -OutFile $temp
Expand-Archive $temp "php-bin"
Write-Output "Install development pack ..."
$temp = New-TemporaryFile | Rename-Item -NewName {$_.Name + ".zip"} -PassThru
$fname = "php-devel-pack-$phpversion-$tspart-$vs-$arch.zip"
$url = "$baseurl/$fname"
Invoke-WebRequest $url -OutFile $temp
Expand-Archive $temp "."
Rename-Item "php-$phpversion-devel-$vs-$arch" "php-dev"