From 8eabd4605b2bd6009894926aeb32c7acea6d1e81 Mon Sep 17 00:00:00 2001 From: Maksim Shilov <89912354+shilovmaksim@users.noreply.github.com> Date: Wed, 2 Feb 2022 11:02:55 +0300 Subject: [PATCH] [MacOS] Add GraalVM to macOS 1015 and 11 images (#4959) * Add GraalVM to macOS 1015 and 11 images * Replace graalVM tests * Resolve comments * Fix native image install command path * Fixing graalvm root path in tests * Fix GRAALVM_11_ROOT path for software report * Fix function name --- images/macos/provision/core/graalvm.sh | 20 +++++++++++++++++++ .../SoftwareReport.Common.psm1 | 15 ++++++++++++++ .../SoftwareReport.Generator.ps1 | 4 ++++ images/macos/templates/macOS-10.15.json | 3 ++- images/macos/templates/macOS-11.json | 3 ++- images/macos/templates/macOS-12.json | 3 ++- images/macos/tests/Common.Tests.ps1 | 10 ++++++++++ 7 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 images/macos/provision/core/graalvm.sh diff --git a/images/macos/provision/core/graalvm.sh b/images/macos/provision/core/graalvm.sh new file mode 100644 index 00000000..62c8b2ab --- /dev/null +++ b/images/macos/provision/core/graalvm.sh @@ -0,0 +1,20 @@ +#!/bin/bash -e -o pipefail +source ~/utils/utils.sh + +echo Installing GraalVM... +brew install --cask graalvm/tap/graalvm-ce-java11 + +exportPath=$(echo /Library/Java/JavaVirtualMachines/graalvm-ce-java*/Contents/Home/bin) +echo "Setting up GRAALVM_11_ROOT variable to ${exportPath}" +echo "export GRAALVM_11_ROOT=${exportPath}" >> "${HOME}/.bashrc" + +# GraalVM not being signed and notarized yet on macOS Catalina +if is_Catalina; then + quarantinePath=$(echo /Library/Java/JavaVirtualMachines/graalvm-ce-java*) + sudo xattr -rd com.apple.quarantine $quarantinePath +fi + +# Install Native Image +$exportPath/gu install native-image + +invoke_tests "Common" "GraalVM" \ No newline at end of file diff --git a/images/macos/software-report/SoftwareReport.Common.psm1 b/images/macos/software-report/SoftwareReport.Common.psm1 index 2b30c2e7..290f934c 100644 --- a/images/macos/software-report/SoftwareReport.Common.psm1 +++ b/images/macos/software-report/SoftwareReport.Common.psm1 @@ -549,3 +549,18 @@ function Build-PackageManagementEnvironmentTable { } } } + +function Get-GraalVMVersion { + $version = & "$env:GRAALVM_11_ROOT\java" --version | Select-String -Pattern "GraalVM" | Take-Part -Part 5,6 + return $version +} + +function Build-GraalVMTable { + $version = Get-GraalVMVersion + $envVariables = "GRAALVM_11_ROOT" + + return [PSCustomObject] @{ + "Version" = $version + "Environment variables" = $envVariables + } +} \ No newline at end of file diff --git a/images/macos/software-report/SoftwareReport.Generator.ps1 b/images/macos/software-report/SoftwareReport.Generator.ps1 index f77bc980..93154dfd 100644 --- a/images/macos/software-report/SoftwareReport.Generator.ps1 +++ b/images/macos/software-report/SoftwareReport.Generator.ps1 @@ -208,6 +208,10 @@ $markdown += New-MDHeader "Java" -Level 3 $markdown += Get-JavaVersions | New-MDTable $markdown += New-MDNewLine +$markdown += New-MDHeader "GraalVM" -Level 3 +$markdown += Build-GraalVMTable | New-MDTable +$markdown += New-MDNewLine + # Toolcache $markdown += Build-ToolcacheSection $markdown += New-MDNewLine diff --git a/images/macos/templates/macOS-10.15.json b/images/macos/templates/macOS-10.15.json index 9f130ad8..4edf744a 100644 --- a/images/macos/templates/macOS-10.15.json +++ b/images/macos/templates/macOS-10.15.json @@ -194,7 +194,8 @@ "./provision/core/xcode-postbuild.sh", "./provision/core/pypy.sh", "./provision/core/pipx-packages.sh", - "./provision/core/bicep.sh" + "./provision/core/bicep.sh", + "./provision/core/graalvm.sh" ], "environment_vars": [ "API_PAT={{user `github_api_pat`}}" diff --git a/images/macos/templates/macOS-11.json b/images/macos/templates/macOS-11.json index 01a086ac..10046d35 100644 --- a/images/macos/templates/macOS-11.json +++ b/images/macos/templates/macOS-11.json @@ -197,7 +197,8 @@ "./provision/core/firefox.sh", "./provision/core/pypy.sh", "./provision/core/pipx-packages.sh", - "./provision/core/bicep.sh" + "./provision/core/bicep.sh", + "./provision/core/graalvm.sh" ], "environment_vars": [ "API_PAT={{user `github_api_pat`}}" diff --git a/images/macos/templates/macOS-12.json b/images/macos/templates/macOS-12.json index e9c1de9d..d79e86bc 100644 --- a/images/macos/templates/macOS-12.json +++ b/images/macos/templates/macOS-12.json @@ -196,7 +196,8 @@ "./provision/core/firefox.sh", "./provision/core/pypy.sh", "./provision/core/pipx-packages.sh", - "./provision/core/bicep.sh" + "./provision/core/bicep.sh", + "./provision/core/graalvm.sh" ], "environment_vars": [ "API_PAT={{user `github_api_pat`}}" diff --git a/images/macos/tests/Common.Tests.ps1 b/images/macos/tests/Common.Tests.ps1 index 9d05270f..3c9a717e 100644 --- a/images/macos/tests/Common.Tests.ps1 +++ b/images/macos/tests/Common.Tests.ps1 @@ -103,4 +103,14 @@ Describe "Go" { It "Go" { "go version" | Should -ReturnZeroExitCode } +} + +Describe "GraalVM" { + It "graalvm" { + '$GRAALVM_11_ROOT/java -version' | Should -ReturnZeroExitCode + } + + It "native-image" { + '$GRAALVM_11_ROOT/native-image --version' | Should -ReturnZeroExitCode + } } \ No newline at end of file