SkiaSharp/scripts/install-android-platform.ps1

46 строки
1.2 KiB
PowerShell
Исходник Обычный вид История

Param(
2024-07-29 15:48:02 +03:00
[Parameter(Mandatory)] [string[]] $API
)
$ErrorActionPreference = 'Stop'
.\scripts\install-android-sdk.ps1
2024-07-29 15:48:02 +03:00
$sdk = "$env:ANDROID_SDK_ROOT"
2024-07-29 15:48:02 +03:00
$sdkmanager = "$env:ANDROID_SDK_MANAGER_PATH"
2024-07-29 15:48:02 +03:00
$apis = $API -split ','
Write-Host "Installing $($apis.Count) Android API levels $API..."
2024-07-29 15:48:02 +03:00
# install each of the APIs
foreach ($API in $apis) {
Write-Host "Installing Android API level $API..."
2024-07-29 15:48:02 +03:00
# check if already installed
$apiPath = Join-Path "$sdk" "platforms" "android-$API" "android.jar"
if (Test-Path $apiPath) {
Write-Host "Android API level $API was already installed."
continue
}
# install
Set-Content -Value "y" -Path "yes.txt"
try {
Write-Host "Installing Android API level $API..."
if ($IsMacOS -or $IsLinux) {
sh -c "'$sdkmanager' 'platforms;android-$API' < yes.txt"
} else {
cmd /c "`"$sdkmanager`" `"platforms;android-$API`" < yes.txt"
}
if (!$?) {
Write-Host "Failed to install Android API level $API."
exit 1
}
Write-Host "Installation of Android API level $API complete."
} finally {
Remove-Item "yes.txt"
}
}
exit $LASTEXITCODE