Initial Shijian Android source import
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
function Get-DPath {
|
||||
param([string]$Path)
|
||||
|
||||
if ($Path -notmatch '^[dD]:[\\/]') {
|
||||
throw "Tool and workspace paths must be absolute D: paths: $Path"
|
||||
}
|
||||
$fullPath = [IO.Path]::GetFullPath($Path)
|
||||
for ($cursor = $fullPath; $cursor; $cursor = Split-Path -Parent $cursor) {
|
||||
if (Test-Path -LiteralPath $cursor) {
|
||||
$item = Get-Item -LiteralPath $cursor -Force
|
||||
if ($item.Attributes -band [IO.FileAttributes]::ReparsePoint) {
|
||||
throw "Use a physical D: path for build data: $cursor"
|
||||
}
|
||||
}
|
||||
}
|
||||
return $fullPath
|
||||
}
|
||||
|
||||
function Get-ToolPath {
|
||||
param([string]$Setting, [string]$DefaultPath)
|
||||
|
||||
$currentPath = [Environment]::GetEnvironmentVariable("SHIJIAN_$Setting")
|
||||
if ($currentPath) {
|
||||
return Get-DPath $currentPath
|
||||
}
|
||||
$legacyPath = [Environment]::GetEnvironmentVariable("JIELIU_$Setting")
|
||||
if ($legacyPath) {
|
||||
return Get-DPath $legacyPath
|
||||
}
|
||||
return Get-DPath $DefaultPath
|
||||
}
|
||||
|
||||
$projectRoot = Get-DPath (Split-Path -Parent $PSScriptRoot)
|
||||
$localData = Get-DPath (Join-Path $projectRoot '.local')
|
||||
$projectJavaHome = Get-ToolPath 'JAVA_HOME' (Join-Path $localData 'jdk-21')
|
||||
$projectSdk = Get-ToolPath 'ANDROID_SDK' 'D:\env\android-sdk'
|
||||
$gradleDistribution = Get-ToolPath 'GRADLE' 'D:\env\gradle'
|
||||
$gradleUserDirectory = Get-ToolPath 'GRADLE_USER_HOME' 'D:\env\gradle-home'
|
||||
$tempDirectory = Get-DPath (Join-Path $localData 'temp')
|
||||
$javaUserDirectory = Get-DPath (Join-Path $localData 'user')
|
||||
$androidUserDirectory = Get-DPath (Join-Path $javaUserDirectory '.android')
|
||||
|
||||
foreach ($directory in @($tempDirectory, $androidUserDirectory, $gradleUserDirectory)) {
|
||||
New-Item -ItemType Directory -Force -Path $directory | Out-Null
|
||||
}
|
||||
|
||||
$env:JAVA_HOME = $projectJavaHome
|
||||
$env:GRADLE_USER_HOME = $gradleUserDirectory
|
||||
$env:ANDROID_HOME = $projectSdk
|
||||
$env:ANDROID_SDK_ROOT = $projectSdk
|
||||
$env:ANDROID_USER_HOME = $androidUserDirectory
|
||||
$env:ANDROID_SDK_DISABLE_ANALYTICS = '1'
|
||||
$env:TEMP = $tempDirectory
|
||||
$env:TMP = $tempDirectory
|
||||
$env:JAVA_TOOL_OPTIONS = "`"-Duser.home=$javaUserDirectory`" `"-Djava.io.tmpdir=$tempDirectory`""
|
||||
|
||||
foreach ($name in @('ANDROID_SDK_HOME', 'ANDROID_EMULATOR_HOME', 'ANDROID_AVD_HOME', 'ADB_VENDOR_KEYS',
|
||||
'JAVA_OPTS', 'GRADLE_OPTS', 'JDK_JAVA_OPTIONS', '_JAVA_OPTIONS')) {
|
||||
Remove-Item -LiteralPath "Env:$name" -ErrorAction SilentlyContinue
|
||||
}
|
||||
|
||||
[pscustomobject]@{
|
||||
Root = $projectRoot
|
||||
Java = Get-DPath (Join-Path $projectJavaHome 'bin\java.exe')
|
||||
Gradle = Get-DPath (Join-Path $gradleDistribution 'bin\gradle.bat')
|
||||
Adb = Get-DPath (Join-Path $projectSdk 'platform-tools\adb.exe')
|
||||
}
|
||||
Reference in New Issue
Block a user