[macOS] Refactor Common.Helpers (#8924)

* [macOS] Refactor Common.Helpers

* Update readme file

* Remove unnecessary double quotes

---------

Co-authored-by: Alexey Ayupov <“alexey.ayupov@akvelon.com”>
This commit is contained in:
Alexey-Ayupov
2023-12-04 12:13:08 +01:00
committed by GitHub
parent ff1dc02cbc
commit 69db5c6c63
46 changed files with 292 additions and 359 deletions

View File

@@ -6,8 +6,7 @@
Import-Module "~/image-generation/helpers/Common.Helpers.psm1"
function Get-ToolsetToolFullPath
{
function Get-ToolsetToolFullPath {
param
(
[Parameter(Mandatory)] [string] $ToolName,
@@ -23,25 +22,23 @@ function Get-ToolsetToolFullPath
}
$arch = Get-Architecture
$toolcache = Get-ToolsetValue "toolcache"
$toolcache = (Get-ToolsetContent).toolcache
foreach ($tool in $toolcache)
{
foreach ($tool in $toolcache) {
$toolName = $tool.name
$toolEnvironment = $tool.arch.$arch.variable_template
if (-not $toolEnvironment)
{
if (-not $toolEnvironment) {
continue
}
foreach ($toolVersion in $tool.arch.$arch.versions)
{
foreach ($toolVersion in $tool.arch.$arch.versions) {
Write-Host "Set $toolName $toolVersion environment variable..."
$toolPath = Get-ToolsetToolFullPath -ToolName $toolName -ToolVersion $toolVersion -ToolArchitecture $arch
$envName = $toolEnvironment -f $toolVersion.split(".")
# Add environment variable name=value
Add-EnvironmentVariable -Name $envName -Value $toolPath
$envVar = "export {0}={1}" -f $envName, $toolPath
Add-Content -Path "${env:HOME}/.bashrc" -Value $envVar
}
}

View File

@@ -31,11 +31,11 @@ $arch = Get-Architecture
# Get toolcache content from toolset
$toolsToInstall = @("Python", "Node", "Go")
$tools = Get-ToolsetValue "toolcache" | Where-Object {$toolsToInstall -contains $_.Name}
$tools = (Get-ToolsetContent).toolcache | Where-Object {$toolsToInstall -contains $_.Name}
foreach ($tool in $tools) {
# Get versions manifest for current tool
$assets = Invoke-RestMethodWithRetry -Url $tool.url
$assets = Invoke-RestMethod $tool.url -MaximumRetryCount 10 -RetryIntervalSec 30
# Get github release asset for each version
foreach ($version in $tool.arch.$arch.versions) {

View File

@@ -8,10 +8,10 @@ $ErrorActionPreference = "Stop"
Import-Module "$env:HOME/image-generation/helpers/Common.Helpers.psm1"
Import-Module "$env:HOME/image-generation/helpers/Xcode.Installer.psm1" -DisableNameChecking
$ARCH = Get-Architecture
[Array]$xcodeVersions = Get-ToolsetValue "xcode.$ARCH.versions"
$arch = Get-Architecture
[Array]$xcodeVersions = (Get-ToolsetContent).xcode.$arch.versions
write-host $xcodeVersions
$defaultXcode = Get-ToolsetValue "xcode.default"
$defaultXcode = (Get-ToolsetContent).xcode.default
[Array]::Reverse($xcodeVersions)
$threadCount = "5"
@@ -61,7 +61,7 @@ $xcodeVersions | ForEach-Object {
Write-Host "Rebuilding Launch Services database ..."
$xcodeVersions | ForEach-Object {
Rebuild-XcodeLaunchServicesDb -Version $_.link
Initialize-XcodeLaunchServicesDb -Version $_.link
}
Write-Host "Setting default Xcode to $defaultXcode"

View File

@@ -8,16 +8,16 @@ $ErrorActionPreference = "Stop"
Import-Module "$env:HOME/image-generation/helpers/Xcode.Helpers.psm1" -DisableNameChecking
Import-Module "$env:HOME/image-generation/software-report/SoftwareReport.Xcode.psm1" -DisableNameChecking
function Ensure-SimulatorInstalled {
function Test-SimulatorInstalled {
param(
[Parameter(Mandatory)]
[string]$RuntimeId,
[string] $RuntimeId,
[Parameter(Mandatory)]
[string]$DeviceId,
[string] $DeviceId,
[Parameter(Mandatory)]
[string]$SimulatorName,
[string] $SimulatorName,
[Parameter(Mandatory)]
[string]$XcodeVersion
[string] $XcodeVersion
)
$simctlPath = Get-XcodeToolPath -Version $XcodeVersion -ToolName "simctl"
@@ -52,5 +52,5 @@ Get-XcodeInfoList | Out-Null
Write-Host "Validating and fixing Xcode simulators..."
Get-BrokenXcodeSimulatorsList | ForEach-Object {
Ensure-SimulatorInstalled -RuntimeId $_.RuntimeId -DeviceId $_.DeviceId -SimulatorName $_.SimulatorName -XcodeVersion $_.XcodeVersion
Test-SimulatorInstalled -RuntimeId $_.RuntimeId -DeviceId $_.DeviceId -SimulatorName $_.SimulatorName -XcodeVersion $_.XcodeVersion
}

View File

@@ -33,9 +33,9 @@ components=()
ANDROID_PLATFORM=$(get_toolset_value '.android.platform_min_version')
ANDROID_BUILD_TOOL=$(get_toolset_value '.android.build_tools_min_version')
ANDROID_EXTRA_LIST=($(get_toolset_value '.android."extra-list"[]'))
ANDROID_ADDON_LIST=($(get_toolset_value '.android."addon-list"[]'))
ANDROID_ADDITIONAL_TOOLS=($(get_toolset_value '.android."additional-tools"[]'))
ANDROID_EXTRA_LIST=($(get_toolset_value '.android."extras"[]'))
ANDROID_ADDON_LIST=($(get_toolset_value '.android."addons"[]'))
ANDROID_ADDITIONAL_TOOLS=($(get_toolset_value '.android."additional_tools"[]'))
ANDROID_NDK_MAJOR_VERSIONS=($(get_toolset_value '.android.ndk."versions"[]'))
ANDROID_NDK_MAJOR_DEFAULT=$(get_toolset_value '.android.ndk.default')
ANDROID_NDK_MAJOR_LATEST=$(get_toolset_value '.android.ndk."versions"[-1]')

View File

@@ -7,12 +7,12 @@
source ~/utils/utils.sh
source ~/utils/xamarin-utils.sh
MONO_VERSIONS=($(get_toolset_value '.xamarin."mono-versions" | reverse | .[]'))
XAMARIN_IOS_VERSIONS=($(get_toolset_value '.xamarin."ios-versions" | reverse | .[]'))
XAMARIN_MAC_VERSIONS=($(get_toolset_value '.xamarin."mac-versions" | reverse | .[]'))
XAMARIN_ANDROID_VERSIONS=($(get_toolset_value '.xamarin."android-versions" | reverse | .[]'))
MONO_VERSIONS=($(get_toolset_value '.xamarin."mono_versions" | reverse | .[]'))
XAMARIN_IOS_VERSIONS=($(get_toolset_value '.xamarin."ios_versions" | reverse | .[]'))
XAMARIN_MAC_VERSIONS=($(get_toolset_value '.xamarin."mac_versions" | reverse | .[]'))
XAMARIN_ANDROID_VERSIONS=($(get_toolset_value '.xamarin."android_versions" | reverse | .[]'))
LATEST_SDK_SYMLINK=$(get_toolset_value '.xamarin.bundles[0].symlink')
CURRENT_SDK_SYMLINK=$(get_toolset_value '.xamarin."bundle-default"')
CURRENT_SDK_SYMLINK=$(get_toolset_value '.xamarin."bundle_default"')
DEFAULT_XCODE_VERSION=$(get_toolset_value '.xcode.default')
if [ "$CURRENT_SDK_SYMLINK" == "latest" ]; then