Skip to content

Commit

Permalink
[Windows] Refactor Msys2 installation to use toolset part 1 (actions#…
Browse files Browse the repository at this point in the history
…3487)

* Refactor Msys2 installation to use toolset

* fix indent in the toolset files

* Resolve nitpicks

* Remove typo (extra $)
  • Loading branch information
miketimofeev authored Jun 2, 2021
1 parent 62046bd commit 4d72ed1
Show file tree
Hide file tree
Showing 5 changed files with 174 additions and 21 deletions.
43 changes: 22 additions & 21 deletions images/win/scripts/Installers/Install-Msys2.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -52,41 +52,42 @@ Write-Host "`n$dash pacman --noconfirm -Syuu (2nd pass)"
pacman.exe -Syuu --noconfirm
taskkill /f /fi "MODULES eq msys-2.0.dll"

$toolsetContent = (Get-ToolsetContent).MsysPackages

Write-Host "`n$dash Install msys2 packages"
pacman.exe -S --noconfirm --needed --noprogressbar base-devel compression
$msys2Packages = $toolsetContent.msys2
pacman.exe -S --noconfirm --needed --noprogressbar $msys2Packages
taskkill /f /fi "MODULES eq msys-2.0.dll"

Write-Host "`n$dash Remove p7zip/7z package due to conflicts"
pacman.exe -R --noconfirm --noprogressbar p7zip

# mingw package list
# libxml2 can be removed from the list after the issue is fixed https://github.com/msys2/MINGW-packages/issues/8658
$tools64 = "___clang ___clang-tools-extra ___cmake ___libxml2 ___llvm ___toolchain ___ragel"
$tools32 = "___clang ___cmake ___libxml2 ___llvm ___toolchain ___ragel"

# install mingw64 packages
Write-Host "`n$dash Install mingw64 packages"
$pre = "mingw-w64-x86_64-"
pacman.exe -S --noconfirm --needed --noprogressbar $tools64.replace('___', $pre).split(' ')

# install mingw32 packages
Write-Host "`n$dash Install mingw32 packages"
$pre = "mingw-w64-i686-"
pacman.exe -S --noconfirm --needed --noprogressbar $tools32.replace('___', $pre).split(' ')
# install mingw packages
$archs = $toolsetContent.mingw.arch
foreach ($arch in $archs)
{
Write-Host "Installing $arch packages"
$archPackages = $toolsetContent.mingw | Where-Object { $_.arch -eq $arch }
$runtimePackages = $archPackages.runtime_packages.name | ForEach-Object { "${arch}-$_" }
$additionalPackages = $archPackages.additional_packages | ForEach-Object { "${arch}-$_" }
$packagesToInstall = $runtimePackages + $additionalPackages
Write-Host "The following packages will be installed: $packagesToInstall"
pacman.exe -S --noconfirm --needed --noprogressbar $packagesToInstall
}

# clean all packages to decrease image size
Write-Host "`n$dash Clean packages"
pacman.exe -Scc --noconfirm

Write-Host "`n$dash Installed mingw64 packages"
pacman.exe -Q | grep ^mingw-w64-x86_64-

Write-Host "`n$dash Installed mingw32 packages"
pacman.exe -Q | grep ^mingw-w64-i686-

Write-Host "`n$dash Installed msys2 packages"
pacman.exe -Q | grep -v ^mingw-w64-

foreach ($arch in $archs)
{
Write-Host "`n$dash Installed $arch packages"
pacman.exe -Q | grep ^${arch}-
}

Write-Host "`nMSYS2 installation completed"

Invoke-PesterTests -TestFile "MSYS2"
73 changes: 73 additions & 0 deletions images/win/toolsets/toolset-2016.json
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,79 @@
"latest": "22"
}
},
"MsysPackages": {
"msys2": [
"base-devel",
"compression"
],
"mingw": [
{
"arch": "mingw-w64-x86_64",
"runtime_packages": [
{
"name": "clang",
"executables": [
"clang",
"g++",
"gcc"
]
},
{
"name": "cmake",
"executables": [
"cmake",
"cpack",
"ctest"
]
},
{
"name": "ragel",
"executables": [
"ragel"
]
}
],
"additional_packages": [
"clang-tools-extra",
"libxml2",
"llvm",
"toolchain"
]
},
{
"arch": "mingw-w64-i686",
"runtime_packages": [
{
"name": "clang",
"executables": [
"clang",
"g++",
"gcc"
]
},
{
"name": "cmake",
"executables": [
"cmake",
"cpack",
"ctest"
]
},
{
"name": "ragel",
"executables": [
"ragel"
]
}
],
"additional_packages": [
"libxml2",
"llvm",
"toolchain"
]
}
]
},
"visualStudio": {
"version" : "2017",
"subversion" : "15",
Expand Down
73 changes: 73 additions & 0 deletions images/win/toolsets/toolset-2019.json
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,79 @@
"latest": "22"
}
},
"MsysPackages": {
"msys2": [
"base-devel",
"compression"
],
"mingw": [
{
"arch": "mingw-w64-x86_64",
"runtime_packages": [
{
"name": "clang",
"executables": [
"clang",
"g++",
"gcc"
]
},
{
"name": "cmake",
"executables": [
"cmake",
"cpack",
"ctest"
]
},
{
"name": "ragel",
"executables": [
"ragel"
]
}
],
"additional_packages": [
"clang-tools-extra",
"libxml2",
"llvm",
"toolchain"
]
},
{
"arch": "mingw-w64-i686",
"runtime_packages": [
{
"name": "clang",
"executables": [
"clang",
"g++",
"gcc"
]
},
{
"name": "cmake",
"executables": [
"cmake",
"cpack",
"ctest"
]
},
{
"name": "ragel",
"executables": [
"ragel"
]
}
],
"additional_packages": [
"libxml2",
"llvm",
"toolchain"
]
}
]
},
"visualStudio": {
"version" : "2019",
"subversion" : "16",
Expand Down
3 changes: 3 additions & 0 deletions images/win/windows2016.json
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,9 @@
},
{
"type": "powershell",
"environment_vars": [
"TOOLSET_JSON_PATH={{user `toolset_json_path`}}"
],
"elevated_user": "SYSTEM",
"elevated_password": "",
"scripts": [
Expand Down
3 changes: 3 additions & 0 deletions images/win/windows2019.json
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,9 @@
},
{
"type": "powershell",
"environment_vars": [
"TOOLSET_JSON_PATH={{user `toolset_json_path`}}"
],
"elevated_user": "SYSTEM",
"elevated_password": "",
"scripts": [
Expand Down

0 comments on commit 4d72ed1

Please sign in to comment.