Skip to content

Commit 72bdf7e

Browse files
[Windows] Install mingw binaries manually (#8418)
1 parent 375e9a1 commit 72bdf7e

File tree

3 files changed

+66
-10
lines changed

3 files changed

+66
-10
lines changed

images/win/scripts/Installers/Install-Mingw64.ps1

Lines changed: 64 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,70 @@
33
## Desc: Install GNU tools for Windows
44
################################################################################
55

6-
$toolsetVersion = (Get-ToolsetContent).mingw.version
7-
Choco-Install -PackageName mingw -ArgumentList "--version=$toolsetVersion"
6+
if (Test-IsWin19) {
7+
# If Windows 2019, install version 8.1.0 form sourceforge
8+
$baseUrl = "https://sourceforge.net/projects/mingw-w64/files"
89

9-
# Make a copy of mingw32-make.exe to make.exe, which is a more discoverable name
10-
# and so the same command line can be used on Windows as on macOS and Linux
11-
$path = where.exe mingw32-make.exe | Get-Item
12-
Copy-Item -Path $path -Destination (Join-Path $path.Directory 'make.exe')
10+
$("mingw32", "mingw64") | ForEach-Object {
11+
if ($_ -eq "mingw32") {
12+
$url = "$baseUrl/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/8.1.0/threads-posix/dwarf/i686-8.1.0-release-posix-dwarf-rt_v6-rev0.7z/download"
13+
$sha256sum = 'adb84b70094c0225dd30187ff995e311d19424b1eb8f60934c60e4903297f946'
14+
} elseif ($_ -eq "mingw64") {
15+
$url = "$baseUrl/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/8.1.0/threads-posix/seh/x86_64-8.1.0-release-posix-seh-rt_v6-rev0.7z/download"
16+
$sha256sum = '853970527b5de4a55ec8ca4d3fd732c00ae1c69974cc930c82604396d43e79f8'
17+
} else {
18+
throw "Unknown architecture $_"
19+
}
20+
21+
$packagePath = Start-DownloadWithRetry -Url $url -Name "$_.7z"
22+
$hash = Get-FileHash -Path $packagePath -Algorithm SHA256
23+
if ($hash.Hash -ne $sha256sum) {
24+
throw "Checksum verification failed for $packagePath"
25+
}
26+
Extract-7Zip -Path $packagePath -DestinationPath "C:\"
27+
28+
# Make a copy of mingw-make.exe to make.exe, which is a more discoverable name
29+
# and so the same command line can be used on Windows as on macOS and Linux
30+
$path = "C:\$_\bin\mingw32-make.exe" | Get-Item
31+
Copy-Item -Path $path -Destination (Join-Path $path.Directory 'make.exe')
32+
}
33+
34+
Add-MachinePathItem "C:\mingw64\bin"
35+
36+
} else {
37+
$version = (Get-ToolsetContent).mingw.version
38+
$runtime = (Get-ToolsetContent).mingw.runtime
39+
40+
$("mingw32", "mingw64") | ForEach-Object {
41+
if ($_ -eq "mingw32") {
42+
$arch = "i686"
43+
$threads = "posix"
44+
$exceptions = "dwarf"
45+
} elseif ($_ -eq "mingw64") {
46+
$arch = "x86_64"
47+
$threads = "posix"
48+
$exceptions = "seh"
49+
} else {
50+
throw "Unknown architecture $_"
51+
}
52+
53+
$url = Get-GitHubPackageDownloadUrl `
54+
-RepoOwner "niXman" `
55+
-RepoName "mingw-builds-binaries" `
56+
-BinaryName "" `
57+
-Version $version `
58+
-UrlFilter "*$arch-{Version}-release-$threads-$exceptions-$runtime-*.7z"
59+
60+
$packagePath = Start-DownloadWithRetry -Url $url -Name "$_.7z"
61+
Extract-7Zip -Path $packagePath -DestinationPath "C:\"
62+
63+
# Make a copy of mingw-make.exe to make.exe, which is a more discoverable name
64+
# and so the same command line can be used on Windows as on macOS and Linux
65+
$path = "C:\$_\bin\mingw32-make.exe" | Get-Item
66+
Copy-Item -Path $path -Destination (Join-Path $path.Directory 'make.exe')
67+
}
68+
69+
Add-MachinePathItem "C:\mingw64\bin"
70+
}
1371

1472
Invoke-PesterTests -TestFile "Tools" -TestName "Mingw64"

images/win/toolsets/toolset-2019.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,6 @@
176176
]
177177
}
178178
},
179-
"mingw": {
180-
"version": "8.1.0"
181-
},
182179
"MsysPackages": {
183180
"msys2": [
184181
"base-devel",

images/win/toolsets/toolset-2022.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,8 @@
151151
}
152152
},
153153
"mingw": {
154-
"version": "12.2.0.03042023"
154+
"version": "12.2.0",
155+
"runtime": "ucrt"
155156
},
156157
"MsysPackages": {
157158
"msys2": [],

0 commit comments

Comments
 (0)