mirror of
https://github.com/actions/runner-images.git
synced 2025-12-12 20:26:49 +00:00
[ubuntu] Refactor Toolset functions (#8948)
This commit is contained in:
committed by
GitHub
parent
a9bc069a35
commit
0ade9f36d3
@@ -155,7 +155,7 @@ function Get-AndroidGoogleAPIsVersions {
|
|||||||
function Get-AndroidNDKVersions {
|
function Get-AndroidNDKVersions {
|
||||||
$ndkFolderPath = Join-Path (Get-AndroidSDKRoot) "ndk"
|
$ndkFolderPath = Join-Path (Get-AndroidSDKRoot) "ndk"
|
||||||
$versions = Get-ChildItem -Path $ndkFolderPath -Name
|
$versions = Get-ChildItem -Path $ndkFolderPath -Name
|
||||||
$ndkDefaultVersion = Get-ToolsetValue "android.ndk.default"
|
$ndkDefaultVersion = (Get-ToolsetContent).android.ndk.default
|
||||||
$ndkDefaultFullVersion = Get-ChildItem "$env:ANDROID_HOME/ndk/$ndkDefaultVersion.*" -Name | Select-Object -Last 1
|
$ndkDefaultFullVersion = Get-ChildItem "$env:ANDROID_HOME/ndk/$ndkDefaultVersion.*" -Name | Select-Object -Last 1
|
||||||
|
|
||||||
return ($versions | ForEach-Object {
|
return ($versions | ForEach-Object {
|
||||||
|
|||||||
@@ -63,39 +63,16 @@ function Test-IsUbuntu22 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function Get-ToolsetContent {
|
function Get-ToolsetContent {
|
||||||
$toolset = Join-Path $env:INSTALLER_SCRIPT_FOLDER "toolset.json"
|
|
||||||
Get-Content $toolset -Raw | ConvertFrom-Json
|
|
||||||
}
|
|
||||||
|
|
||||||
function Get-ToolsetValue {
|
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
This function retrieves the value of a specific toolset.
|
Retrieves the content of the toolset.json file.
|
||||||
|
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
The Get-ToolsetValue is used to retrieve the value of a specific toolset.
|
This function reads the toolset.json in path provided by INSTALLER_SCRIPT_FOLDER
|
||||||
The toolset is a collection of tools or settings in json format.
|
environment variable and returns the content as a PowerShell object.
|
||||||
|
|
||||||
.PARAMETER KeyPath
|
|
||||||
The path to the toolset value in json notation.
|
|
||||||
|
|
||||||
.EXAMPLE
|
|
||||||
Get-ToolsetValue -Toolset "tool.arch.versions"
|
|
||||||
|
|
||||||
This command returns the value of the nodes named "tool", "arch" and "versions" as PSCustomObject.
|
|
||||||
|
|
||||||
#>
|
#>
|
||||||
param (
|
|
||||||
[Parameter(Mandatory = $true)]
|
|
||||||
[string] $KeyPath
|
|
||||||
)
|
|
||||||
|
|
||||||
$jsonNode = Get-ToolsetContent
|
$toolsetPath = Join-Path $env:INSTALLER_SCRIPT_FOLDER "toolset.json"
|
||||||
|
$toolsetJson = Get-Content -Path $toolsetPath -Raw
|
||||||
$pathParts = $KeyPath.Split(".")
|
ConvertFrom-Json -InputObject $toolsetJson
|
||||||
# walk through all arguments consequentially to resolve specific json node
|
|
||||||
$pathParts | ForEach-Object {
|
|
||||||
$jsonNode = $jsonNode.$_
|
|
||||||
}
|
|
||||||
return $jsonNode
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,13 +59,10 @@ verlte() {
|
|||||||
[ "$1" = "$sortedVersion" ]
|
[ "$1" = "$sortedVersion" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
get_toolset_path() {
|
|
||||||
echo "/imagegeneration/installers/toolset.json"
|
|
||||||
}
|
|
||||||
|
|
||||||
get_toolset_value() {
|
get_toolset_value() {
|
||||||
local toolset_path=$(get_toolset_path)
|
local toolset_path="/imagegeneration/installers/toolset.json"
|
||||||
local query=$1
|
local query=$1
|
||||||
|
|
||||||
echo "$(jq -r "$query" $toolset_path)"
|
echo "$(jq -r "$query" $toolset_path)"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -77,9 +77,9 @@ Describe "Android" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$androidSdkManagerPackages = Get-AndroidPackages
|
$androidSdkManagerPackages = Get-AndroidPackages
|
||||||
[int]$platformMinVersion = Get-ToolsetValue "android.platform_min_version"
|
[int]$platformMinVersion = (Get-ToolsetContent).android.platform_min_version
|
||||||
[version]$buildToolsMinVersion = Get-ToolsetValue "android.build_tools_min_version"
|
[version]$buildToolsMinVersion = (Get-ToolsetContent).android.build_tools_min_version
|
||||||
[array]$ndkVersions = Get-ToolsetValue "android.ndk.versions"
|
[array]$ndkVersions = (Get-ToolsetContent).android.ndk.versions
|
||||||
$ndkFullVersions = $ndkVersions |
|
$ndkFullVersions = $ndkVersions |
|
||||||
ForEach-Object { (Get-ChildItem "/usr/local/lib/android/sdk/ndk/${_}.*" |
|
ForEach-Object { (Get-ChildItem "/usr/local/lib/android/sdk/ndk/${_}.*" |
|
||||||
Select-Object -Last 1).Name } | ForEach-Object { "ndk/${_}" }
|
Select-Object -Last 1).Name } | ForEach-Object { "ndk/${_}" }
|
||||||
@@ -102,9 +102,9 @@ Describe "Android" {
|
|||||||
$platformsInstalled,
|
$platformsInstalled,
|
||||||
$buildTools,
|
$buildTools,
|
||||||
$ndkFullVersions,
|
$ndkFullVersions,
|
||||||
(Get-ToolsetValue "android.extra_list" | ForEach-Object { "extras/${_}" }),
|
((Get-ToolsetContent).android.extra_list | ForEach-Object { "extras/${_}" }),
|
||||||
(Get-ToolsetValue "android.addon_list" | ForEach-Object { "add-ons/${_}" }),
|
((Get-ToolsetContent).android.addon_list | ForEach-Object { "add-ons/${_}" }),
|
||||||
(Get-ToolsetValue "android.additional_tools" | ForEach-Object { "${_}" })
|
((Get-ToolsetContent).android.additional_tools | ForEach-Object { "${_}" })
|
||||||
)
|
)
|
||||||
|
|
||||||
$androidPackages = $androidPackages | ForEach-Object { $_ }
|
$androidPackages = $androidPackages | ForEach-Object { $_ }
|
||||||
|
|||||||
Reference in New Issue
Block a user