|
3 | 3 | ## Desc: Install GNU tools for Windows |
4 | 4 | ################################################################################ |
5 | 5 |
|
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" |
8 | 9 |
|
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 | +} |
13 | 71 |
|
14 | 72 | Invoke-PesterTests -TestFile "Tools" -TestName "Mingw64" |
0 commit comments