diff --git a/images/macos/provision/core/gcc.sh b/images/macos/provision/core/gcc.sh index 2721725a9..6f96f2ae9 100644 --- a/images/macos/provision/core/gcc.sh +++ b/images/macos/provision/core/gcc.sh @@ -1,15 +1,16 @@ #!/bin/bash -e -o pipefail source ~/utils/utils.sh -echo "Installing GCC@8 using homebrew..." -brew_smart_install "gcc@8" +gccVersions=$(get_toolset_value '.gcc.versions | .[]') -echo "Installing GCC@9 using homebrew..." -brew_smart_install "gcc@9" +for gccVersion in $gccVersions; do + brew_smart_install "gcc@${gccVersion}" +done -# https://github.com/actions/virtual-environments/issues/1280 -echo "Installing GCC@10 using homebrew..." -brew_smart_install "gcc@10" -rm $(which gfortran) +# Delete default gfortran link if it exists https://github.com/actions/virtual-environments/issues/1280 +gfortranPath=$(which gfortran) +if [ $gfortranPath ]; then + rm $gfortranPath +fi invoke_tests "Common" "GCC" diff --git a/images/macos/software-report/SoftwareReport.Common.psm1 b/images/macos/software-report/SoftwareReport.Common.psm1 index a316ae175..928d1aaf2 100644 --- a/images/macos/software-report/SoftwareReport.Common.psm1 +++ b/images/macos/software-report/SoftwareReport.Common.psm1 @@ -80,7 +80,7 @@ function Get-VcpkgVersion { } function Get-GccVersion { - $versionList = @("8", "9", "10") + $versionList = Get-ToolsetValue -KeyPath gcc.versions $versionList | Foreach-Object { $version = Run-Command "gcc-${_} --version" | Select-Object -First 1 "$version - available by ``gcc-${_}`` alias" @@ -88,10 +88,10 @@ function Get-GccVersion { } function Get-FortranVersion { - $versionList = @("8", "9", "10") + $versionList = Get-ToolsetValue -KeyPath gcc.versions $versionList | Foreach-Object { $version = Run-Command "gfortran-${_} --version" | Select-Object -First 1 - "$version - available by ``gfortran-${_}`` alias" + "$version - available by ``gfortran-${_}`` alias" } } diff --git a/images/macos/software-report/SoftwareReport.Generator.ps1 b/images/macos/software-report/SoftwareReport.Generator.ps1 index 5860e5d3e..f9532db04 100644 --- a/images/macos/software-report/SoftwareReport.Generator.ps1 +++ b/images/macos/software-report/SoftwareReport.Generator.ps1 @@ -60,7 +60,9 @@ if ($os.IsLessThanBigSur) { ) } -$markdown += New-MDList -Style Unordered -Lines ($languageAndRuntimeList | Sort-Object) +# To sort GCC and Gfortran correctly, we need to use natural sort https://gist.github.com/markwragg/e2a9dc05f3464103d6998298fb575d4e#file-sort-natural-ps1 +$toNatural = { [regex]::Replace($_, '\d+', { $args[0].Value.PadLeft(20) }) } +$markdown += New-MDList -Style Unordered -Lines ($languageAndRuntimeList | Sort-Object $toNatural) # Package Management $markdown += New-MDHeader "Package Management" -Level 3 diff --git a/images/macos/tests/Common.Tests.ps1 b/images/macos/tests/Common.Tests.ps1 index 2994573a8..f066fac44 100644 --- a/images/macos/tests/Common.Tests.ps1 +++ b/images/macos/tests/Common.Tests.ps1 @@ -10,7 +10,7 @@ Describe ".NET" { } Describe "GCC" -Skip:($os.IsHighSierra) { - $testCases = @("8", "9", "10") | ForEach-Object { @{Version = $_} } + $testCases = Get-ToolsetValue -KeyPath gcc.versions | ForEach-Object { @{Version = $_} } It "GCC " -TestCases $testCases { param ( diff --git a/images/macos/toolsets/toolset-10.14.json b/images/macos/toolsets/toolset-10.14.json index e0acdbbaf..a2d5868b3 100644 --- a/images/macos/toolsets/toolset-10.14.json +++ b/images/macos/toolsets/toolset-10.14.json @@ -263,6 +263,14 @@ "virtualbox" ] }, + "gcc": { + "versions": [ + "8", + "9", + "10", + "11" + ] + }, "toolcache": [ { "name": "Python", diff --git a/images/macos/toolsets/toolset-10.15.json b/images/macos/toolsets/toolset-10.15.json index 6b98fe1b9..ee1b5550b 100644 --- a/images/macos/toolsets/toolset-10.15.json +++ b/images/macos/toolsets/toolset-10.15.json @@ -222,6 +222,14 @@ "virtualbox" ] }, + "gcc": { + "versions": [ + "8", + "9", + "10", + "11" + ] + }, "toolcache": [ { "name": "Python", diff --git a/images/macos/toolsets/toolset-11.0.json b/images/macos/toolsets/toolset-11.0.json index f397fb364..9291d71c8 100644 --- a/images/macos/toolsets/toolset-11.0.json +++ b/images/macos/toolsets/toolset-11.0.json @@ -150,6 +150,14 @@ "julia" ] }, + "gcc": { + "versions": [ + "8", + "9", + "10", + "11" + ] + }, "toolcache": [ { "name": "Python",