-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup-windows.ps1
153 lines (128 loc) · 5.4 KB
/
setup-windows.ps1
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# Create folders
Write-Host "Creating folders..."
$folders = @(
"tmp",
"cache",
"cache\Https",
"bin",
"share"
)
foreach ($folder in $folders)
{
if (-not (Test-Path -Path $folder -ErrorAction SilentlyContinue))
{
New-Item -Path $folder -ItemType Directory | Out-Null
Write-Host "$folder created" -ForegroundColor Green
}
}
Write-Host "Folders created" -ForegroundColor Green
Write-Host ""
function Check-VisualStudio
{
$installer = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
$path = & $installer -latest -property installationPath
if (-not (Test-Path -Path $path -ErrorAction SilentlyContinue))
{
Write-Host "Visual Studio not installed!" -ForegroundColor Red
}
else
{
Write-Host "Visual Studio installed" -ForegroundColor Green
}
}
Write-Host "Checking toolchains..."
Check-VisualStudio
Write-Host ""
function Check-Git
{
if (-not (Get-Command git -ErrorAction SilentlyContinue))
{
Write-Host "Git not installed!" -ForegroundColor Red
}
else
{
Write-Host "Git installed" -ForegroundColor Green
}
}
function Install-SevenZip
{
$release = "24.09"
$source1 = "https://github.com/ip7z/7zip/releases/download/${release}/7zr.exe"
if (-not (Test-Path -Path cache\Https\7zr-${release}.exe -ErrorAction SilentlyContinue))
{
Write-Host "Downloading 7-Zip..." -ForegroundColor Yellow
Invoke-WebRequest -Uri $source1 -OutFile tmp\7zr.exe
Move-Item -Path tmp\7zr.exe -Destination cache\Https\7zr-${release}.exe
}
$source2 = "https://github.com/ip7z/7zip/releases/download/${release}/7z2409-extra.7z "
if (-not (Test-Path -Path cache\Https\7z2409-extra.7z -ErrorAction SilentlyContinue))
{
Invoke-WebRequest -Uri $source2 -OutFile tmp\7z2409-extra.7z
Move-Item -Path tmp\7z2409-extra.7z -Destination cache\Https\7z2409-extra.7z
}
if (-not(Test-Path -Path bin\7za.exe -ErrorAction SilentlyContinue))
{
Copy-Item -Path cache\Https\7zr-${release}.exe -Destination tmp\7zr.exe
Copy-Item -Path cache\Https\7z2409-extra.7z -Destination tmp\7z2409-extra.7z
Write-Host "Extracting 7-Zip..." -ForegroundColor Yellow
Push-Location tmp
& .\7zr.exe x 7z2409-extra.7z -o7z | Out-Null
Pop-Location
Move-Item -Path tmp\7z\x64\7za.exe -Destination bin\
Move-Item -Path tmp\7z\x64\7za.dll -Destination bin\
Move-Item -Path tmp\7z\x64\7zxa.dll -Destination bin\
Remove-Item -Path tmp\7z -Recurse
Remove-Item -Path tmp\7z2409-extra.7z
Remove-Item -Path tmp\7zr.exe
}
Write-Host "7-Zip installed" -ForegroundColor Green
}
function Install-CMake
{
$release = "3.31.6"
$architecture = "x86_64"
$source = "https://github.com/Kitware/CMake/releases/download/v${release}/cmake-${release}-windows-${architecture}.zip"
if (-not (Test-Path -Path cache\Https\cmake-${release}-windows-${architecture}.zip -ErrorAction SilentlyContinue))
{
Write-Host "Downloading CMake..." -ForegroundColor Yellow
Invoke-WebRequest -Uri $source -OutFile tmp\cmake-${release}-windows-${architecture}.zip
Move-Item -Path tmp\cmake-${release}-windows-${architecture}.zip -Destination cache\Https\cmake-${release}-windows-${architecture}.zip
}
if (-not(Test-Path -Path bin\cmake.exe -ErrorAction SilentlyContinue))
{
Copy-Item -Path cache\Https\cmake-${release}-windows-${architecture}.zip -Destination tmp/cmake-${release}-windows-${architecture}.zip
Write-Host "Extracting CMake..." -ForegroundColor Yellow
& .\bin\7za.exe x tmp\cmake-${release}-windows-${architecture}.zip -otmp | Out-Null
Move-Item -Path tmp\cmake-${release}-windows-${architecture}\bin\cmake.exe -Destination bin\
Move-Item -Path tmp\cmake-${release}-windows-${architecture}\bin\cmake-gui.exe -Destination bin\
Move-Item -Path tmp\cmake-${release}-windows-${architecture}\bin\cmcldeps.exe -Destination bin\
Move-Item -Path tmp\cmake-${release}-windows-${architecture}\bin\ctest.exe -Destination bin\
Move-Item -Path tmp\cmake-${release}-windows-${architecture}\bin\cpack.exe -Destination bin\
Move-Item -Path tmp\cmake-${release}-windows-${architecture}\share\cmake-3.31 -Destination share\
Remove-Item -Path tmp\cmake-${release}-windows-${architecture} -Recurse
Remove-Item -Path tmp\cmake-${release}-windows-${architecture}.zip
}
Write-Host "CMake installed" -ForegroundColor Green
}
function Install-NuGet
{
$release = "6.13.2"
$architecture = "x86"
$source = "https://dist.nuget.org/win-${architecture}-commandline/v${release}/nuget.exe"
if (-not (Test-Path -Path cache\Https\nuget-${release}-${architecture}.exe -ErrorAction SilentlyContinue))
{
Write-Host "Downloading NuGet..." -ForegroundColor Yellow
Invoke-WebRequest -Uri $source -OutFile tmp\nuget-${release}-${architecture}.exe
Move-Item -Path tmp\nuget-${release}-${architecture}.exe -Destination cache\Https\nuget-${release}-${architecture}.exe
}
if (-not(Test-Path -Path bin\nuget.exe -ErrorAction SilentlyContinue))
{
Copy-Item -Path cache\Https\nuget-${release}-${architecture}.exe -Destination bin\nuget.exe
}
Write-Host "NuGet installed" -ForegroundColor Green
}
Write-Host "Checking utilities..."
Check-Git
Install-SevenZip
Install-CMake
Install-NuGet