33 lines
1.3 KiB
PowerShell
33 lines
1.3 KiB
PowerShell
$ErrorActionPreference = 'Stop'
|
|||
|
|
$tasks = $args
|
||
|
|
if ($tasks.Count -eq 0) {
|
||
|
|
$tasks = @('assembleDebug')
|
||
|
|
}
|
||
|
|
|
||
|
|
$toolchain = & (Join-Path $PSScriptRoot 'env.ps1')
|
||
|
|
foreach ($path in @($toolchain.Java, $toolchain.Gradle, (Join-Path $env:ANDROID_HOME 'platforms\android-35\android.jar'))) {
|
||
|
|
if (-not (Test-Path -LiteralPath $path -PathType Leaf)) {
|
||
|
|
throw "Missing build dependency: $path. Configure SHIJIAN_JAVA_HOME, SHIJIAN_GRADLE and SHIJIAN_ANDROID_SDK as needed."
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
$localProperties = Join-Path $toolchain.Root 'local.properties'
|
||
|
|
if (Test-Path -LiteralPath $localProperties) {
|
||
|
|
$sdkLines = Select-String -LiteralPath $localProperties -Pattern '^\s*sdk\.dir\s*[:=]?\s*(.*)$'
|
||
|
|
foreach ($line in $sdkLines) {
|
||
|
|
$sdkValue = $line.Matches[0].Groups[1].Value.Trim().Replace('\:', ':').Replace('\\', '\')
|
||
|
|
if ($sdkValue -notmatch '^[dD]:[\\/]' -or [IO.Path]::GetFullPath($sdkValue).TrimEnd('\') -ne $env:ANDROID_HOME.TrimEnd('\')) {
|
||
|
|
throw "Set sdk.dir in local.properties to the configured D: SDK: $env:ANDROID_HOME"
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
Push-Location -LiteralPath $toolchain.Root
|
||
|
|
try {
|
||
|
|
& $toolchain.Gradle --no-daemon --console=plain "-Dorg.gradle.java.home=$env:JAVA_HOME" @tasks
|
||
|
|
$buildExitCode = $LASTEXITCODE
|
||
|
|
} finally {
|
||
|
|
Pop-Location
|
||
|
|
}
|
||
|
|
exit $buildExitCode
|