From 9ebc095c4af0de3f5ccba03e780ad49a5221f967 Mon Sep 17 00:00:00 2001 From: Mikhail Koliada <88318005+mikhailkoliada@users.noreply.github.com> Date: Thu, 11 Nov 2021 11:23:05 +0300 Subject: [PATCH] [macOS] move llvm to toolset (#4457) --- images/macos/provision/core/commonutils.sh | 4 ++-- images/macos/provision/core/llvm.sh | 8 ++++++++ images/macos/templates/macOS-10.15.json | 1 + images/macos/templates/macOS-11.json | 3 ++- images/macos/templates/macOS-11.pkr.hcl | 1 + images/macos/tests/BasicTools.Tests.ps1 | 7 ------- images/macos/tests/LLVM.Tests.ps1 | 9 +++++++++ images/macos/toolsets/toolset-10.15.json | 4 +++- images/macos/toolsets/toolset-11.json | 4 +++- 9 files changed, 29 insertions(+), 12 deletions(-) create mode 100644 images/macos/provision/core/llvm.sh create mode 100644 images/macos/tests/LLVM.Tests.ps1 diff --git a/images/macos/provision/core/commonutils.sh b/images/macos/provision/core/commonutils.sh index 0f046e699..a91554f68 100644 --- a/images/macos/provision/core/commonutils.sh +++ b/images/macos/provision/core/commonutils.sh @@ -2,8 +2,8 @@ source ~/utils/utils.sh # Monterey needs future review: -# Llvm, aliyun-cli, gnupg, helm have issues with building from the source code. -# Added gmp for now, because toolcache ruby needs its libs. Remove it when php starts to build from source code. +# aliyun-cli, gnupg, helm have issues with building from the source code. +# Added gmp for now, because toolcache ruby needs its libs. Remove it when php starts to build from source code. common_packages=$(get_toolset_value '.brew.common_packages[]') for package in $common_packages; do echo "Installing $package..." diff --git a/images/macos/provision/core/llvm.sh b/images/macos/provision/core/llvm.sh new file mode 100644 index 000000000..ff1aa683f --- /dev/null +++ b/images/macos/provision/core/llvm.sh @@ -0,0 +1,8 @@ +#!/bin/bash -e -o pipefail +source ~/utils/utils.sh + +llvmVersion=$(get_toolset_value '.llvm.version') + +brew_smart_install "llvm@${llvmVersion}" + +invoke_tests "LLVM" \ No newline at end of file diff --git a/images/macos/templates/macOS-10.15.json b/images/macos/templates/macOS-10.15.json index 6c07559e3..d6f57c07f 100644 --- a/images/macos/templates/macOS-10.15.json +++ b/images/macos/templates/macOS-10.15.json @@ -160,6 +160,7 @@ "execute_command": "chmod +x {{ .Path }}; {{ .Vars }} {{ .Path }}", "scripts": [ "./provision/core/commonutils.sh", + "./provision/core/llvm.sh", "./provision/core/golang.sh", "./provision/core/swiftlint.sh", "./provision/core/openjdk.sh", diff --git a/images/macos/templates/macOS-11.json b/images/macos/templates/macOS-11.json index b564327a3..bebcfc2d7 100644 --- a/images/macos/templates/macOS-11.json +++ b/images/macos/templates/macOS-11.json @@ -165,6 +165,7 @@ "execute_command": "chmod +x {{ .Path }}; {{ .Vars }} {{ .Path }}", "scripts": [ "./provision/core/commonutils.sh", + "./provision/core/llvm.sh", "./provision/core/golang.sh", "./provision/core/swiftlint.sh", "./provision/core/openjdk.sh", @@ -198,7 +199,7 @@ { "type": "shell", "execute_command": "chmod +x {{ .Path }}; {{ .Vars }} pwsh -f {{ .Path }}", - "scripts": [ + "scripts": [ "./provision/core/toolset.ps1", "./provision/core/configure-toolset.ps1" ] diff --git a/images/macos/templates/macOS-11.pkr.hcl b/images/macos/templates/macOS-11.pkr.hcl index 7cc739a82..7e44532a3 100644 --- a/images/macos/templates/macOS-11.pkr.hcl +++ b/images/macos/templates/macOS-11.pkr.hcl @@ -163,6 +163,7 @@ build { provisioner "shell" { scripts = [ "./provision/core/commonutils.sh", + "./provision/core/llvm.sh", "./provision/core/golang.sh", "./provision/core/swiftlint.sh", "./provision/core/openjdk.sh", diff --git a/images/macos/tests/BasicTools.Tests.ps1 b/images/macos/tests/BasicTools.Tests.ps1 index 8fdd2bdb2..4389c89e6 100644 --- a/images/macos/tests/BasicTools.Tests.ps1 +++ b/images/macos/tests/BasicTools.Tests.ps1 @@ -30,19 +30,12 @@ Describe "SwiftFormat" -Skip:($os.IsMonterey) { } } - Describe "GnuPG" -Skip:($os.IsMonterey) { It "GnuPG" { "gpg --version" | Should -ReturnZeroExitCode } } -Describe "Clang/LLVM" -Skip:($os.IsMonterey) { - It "Clang/LLVM is installed" { - "$(brew --prefix llvm)/bin/clang --version" | Should -ReturnZeroExitCode - } -} - Describe "zstd" { It "zstd" { "zstd --version" | Should -ReturnZeroExitCode diff --git a/images/macos/tests/LLVM.Tests.ps1 b/images/macos/tests/LLVM.Tests.ps1 new file mode 100644 index 000000000..75b67e9c4 --- /dev/null +++ b/images/macos/tests/LLVM.Tests.ps1 @@ -0,0 +1,9 @@ +$os = Get-OSVersion + +Describe "Clang/LLVM" -Skip:($os.IsMonterey) { + It "Clang/LLVM is installed and version is correct" { + $toolsetVersion = Get-ToolsetValue 'llvm.version' + $clangVersion = & "$(brew --prefix llvm)/bin/clang" --version + $clangVersion[0] | Should -BeLike "*${toolsetVersion}*" + } +} \ No newline at end of file diff --git a/images/macos/toolsets/toolset-10.15.json b/images/macos/toolsets/toolset-10.15.json index 5aa1f47e8..8b80a88ce 100644 --- a/images/macos/toolsets/toolset-10.15.json +++ b/images/macos/toolsets/toolset-10.15.json @@ -215,7 +215,6 @@ "helm", "kotlin", "libpq", - "llvm", "p7zip", "packer", "parallel", @@ -339,5 +338,8 @@ "12", "14" ] + }, + "llvm": { + "version": "13" } } diff --git a/images/macos/toolsets/toolset-11.json b/images/macos/toolsets/toolset-11.json index a6f4a9a52..45b784a75 100644 --- a/images/macos/toolsets/toolset-11.json +++ b/images/macos/toolsets/toolset-11.json @@ -176,7 +176,6 @@ "helm", "kotlin", "libpq", - "llvm", "p7zip", "packer", "perl", @@ -291,5 +290,8 @@ "12", "14" ] + }, + "llvm": { + "version": "13" } }