feat: 初始化跨平台远程编译服务与 Android Studio 插件
This commit is contained in:
commit
9eba4556db
44 files changed
+2802
No files matched your search
@@ -0,0 +1,40 @@
|
||||
param([string]$Root='C:\ProgramData\VibeCodingRemoteCompilation')
|
||||
$ErrorActionPreference='Stop'
|
||||
[xml]$config=Get-Content -LiteralPath "$Root\bin\RemoteCompileService.xml" -Raw
|
||||
$token=($config.service.env | Where-Object name -eq 'REMOTE_BUILD_TOKEN').value
|
||||
$headers=@{Authorization="Bearer $token"}
|
||||
function Api([string]$method,[string]$path,$body=$null) {
|
||||
$args=@{Method=$method;Uri="http://127.0.0.1:8765/api/v1$path";Headers=$headers;TimeoutSec=30}
|
||||
if($null -ne $body){$args.ContentType='application/json';$args.Body=($body | ConvertTo-Json -Depth 12 -Compress)}
|
||||
Invoke-RestMethod @args
|
||||
}
|
||||
$project=(Api POST '/projects').id
|
||||
$wrapper=@'
|
||||
@echo off
|
||||
"%JAVA_HOME%\bin\java.exe" -version
|
||||
if errorlevel 1 exit /b 1
|
||||
if not exist "%ANDROID_HOME%\platforms\android-35\android.jar" exit /b 2
|
||||
"%ANDROID_HOME%\build-tools\35.0.0\aapt2.exe" version
|
||||
if errorlevel 1 exit /b 3
|
||||
mkdir app\build\outputs\apk\debug 2>nul
|
||||
echo windows-service-smoke>app\build\outputs\apk\debug\app-debug.apk
|
||||
exit /b 0
|
||||
'@
|
||||
$content=[Text.Encoding]::ASCII.GetBytes($wrapper.Replace("`n","`r`n"))
|
||||
$sha=[Security.Cryptography.SHA256]::Create()
|
||||
try {$hash=([BitConverter]::ToString($sha.ComputeHash($content))).Replace('-','').ToLowerInvariant()}finally{$sha.Dispose()}
|
||||
$files=@{'gradlew.bat'=@{hash=$hash;data=[Convert]::ToBase64String($content)}}
|
||||
Api POST "/projects/$project/sync" @{revision='windows-deploy-smoke';files=$files} | Out-Null
|
||||
$build=(Api POST "/projects/$project/builds" @{revision='windows-deploy-smoke';task=':app:assembleDebug'}).id
|
||||
for($i=0;$i -lt 120;$i++) {
|
||||
$result=Api GET "/builds/$build"
|
||||
if($result.status -notin @('queued','running')){break}
|
||||
Start-Sleep -Milliseconds 250
|
||||
}
|
||||
if($result.status -ne 'success'){throw ($result | ConvertTo-Json -Depth 6)}
|
||||
$artifact=$result.artifacts[0]
|
||||
$download=Join-Path $env:TEMP 'remotecompile-deploy-smoke.apk'
|
||||
Invoke-WebRequest -UseBasicParsing -Uri "http://127.0.0.1:8765/api/v1/builds/$build/artifacts/$($artifact.name)" -Headers $headers -OutFile $download
|
||||
if((Get-FileHash -LiteralPath $download -Algorithm SHA256).Hash.ToLowerInvariant() -ne $artifact.hash){throw 'Artifact hash mismatch'}
|
||||
Remove-Item -LiteralPath $download
|
||||
Write-Output "PASS: sync, LocalService JDK, SDK android-35 read, aapt2, build, download, SHA256. Build=$build. Simulated APK only."
|
||||
Reference in new issue
Block a user