37 lines
2.6 KiB
PowerShell
37 lines
2.6 KiB
PowerShell
|
|
param([string]$ToolRoot='C:\Users\Administrator\Documents\ChatGPT\优创未来\services\toplc-vpn-android\.tools')
|
||
|
|
$ErrorActionPreference='Stop'
|
||
|
|
$tests=Split-Path -Parent $MyInvocation.MyCommand.Path
|
||
|
|
$source=Split-Path -Parent $tests
|
||
|
|
$stage=Join-Path 'C:\CodexBuild' ('ZhaoQueueCheck-'+[guid]::NewGuid().ToString('N'))
|
||
|
|
New-Item -ItemType Directory -Path $stage,"$stage\classes","$stage\dex" | Out-Null
|
||
|
|
$jdk=Join-Path $ToolRoot 'jdk-staging\jdk-21.0.12.1+1'
|
||
|
|
$sdk=Join-Path $ToolRoot 'android-sdk'
|
||
|
|
$bt=Join-Path $sdk 'build-tools\36.0.0'
|
||
|
|
$android=Join-Path $sdk 'platforms\android-37.0\android.jar'
|
||
|
|
$env:JAVA_HOME=$jdk
|
||
|
|
$env:Path="$jdk\bin;$env:Path"
|
||
|
|
@'
|
||
|
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="cn.ucvl.zhaodisplay.queuecheck" android:versionCode="1" android:versionName="1">
|
||
|
|
<uses-sdk android:minSdkVersion="26" android:targetSdkVersion="30"/>
|
||
|
|
<application android:label="轨迹队列隔离测试" android:allowBackup="false"/>
|
||
|
|
<instrumentation android:name="cn.ucvl.zhaodisplay.QueueInstrumentation" android:targetPackage="cn.ucvl.zhaodisplay.queuecheck"/>
|
||
|
|
</manifest>
|
||
|
|
'@ | Set-Content -LiteralPath "$stage\AndroidManifest.xml" -Encoding utf8
|
||
|
|
& "$bt\aapt2.exe" link -o "$stage\unsigned.apk" -I $android --manifest "$stage\AndroidManifest.xml"
|
||
|
|
if($LASTEXITCODE){throw 'Test resource linking failed'}
|
||
|
|
& "$jdk\bin\javac.exe" -encoding UTF-8 -source 8 -target 8 -cp $android -d "$stage\classes" "$source\src\cn\ucvl\zhaodisplay\LocationQueue.java" "$tests\QueueInstrumentation.java"
|
||
|
|
if($LASTEXITCODE){throw 'Test Java compile failed'}
|
||
|
|
& "$jdk\bin\jar.exe" cf "$stage\classes.jar" -C "$stage\classes" .
|
||
|
|
& "$bt\d8.bat" --lib $android --min-api 26 --output "$stage\dex" "$stage\classes.jar"
|
||
|
|
if($LASTEXITCODE){throw 'Test Dex compile failed'}
|
||
|
|
Add-Type -AssemblyName System.IO.Compression.FileSystem
|
||
|
|
$zip=[IO.Compression.ZipFile]::Open("$stage\unsigned.apk",[IO.Compression.ZipArchiveMode]::Update)
|
||
|
|
try{[IO.Compression.ZipFileExtensions]::CreateEntryFromFile($zip,"$stage\dex\classes.dex",'classes.dex',[IO.Compression.CompressionLevel]::Optimal) | Out-Null}finally{$zip.Dispose()}
|
||
|
|
& "$bt\zipalign.exe" -f 4 "$stage\unsigned.apk" "$stage\aligned.apk"
|
||
|
|
$keystore=Join-Path $env:LOCALAPPDATA 'ZhaoDisplay\display-signing.jks'
|
||
|
|
& "$bt\apksigner.bat" sign --ks $keystore --ks-pass pass:android --key-pass pass:android --ks-key-alias zhaodisplay --out "$source\build\QueueCheck.apk" "$stage\aligned.apk"
|
||
|
|
if($LASTEXITCODE){throw 'Test APK signing failed'}
|
||
|
|
& "$bt\apksigner.bat" verify "$source\build\QueueCheck.apk"
|
||
|
|
if($LASTEXITCODE){throw 'Test APK verification failed'}
|
||
|
|
Write-Output "$source\build\QueueCheck.apk"
|