forked from RevocGG/MasterDnsVPN-AndroidGG
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_build.ps1
More file actions
34 lines (32 loc) · 1.27 KB
/
Copy pathrun_build.ps1
File metadata and controls
34 lines (32 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
$ErrorActionPreference = "Continue"
$env:GOFLAGS = "-mod=mod"
$env:ANDROID_HOME = "$env:USERPROFILE\AppData\Local\Android\Sdk"
$ndkDir = Get-ChildItem "$env:ANDROID_HOME\ndk" -ErrorAction SilentlyContinue | Sort-Object Name -Descending | Select-Object -First 1
if ($ndkDir) {
$env:ANDROID_NDK_HOME = $ndkDir.FullName
Write-Host "NDK=$($ndkDir.FullName)"
} else {
Write-Host "ERROR: No NDK found"
exit 1
}
Write-Host "=== Step 1: gomobile bind ==="
& gomobile bind -v -target android -androidapi 26 -javapkg com.masterdnsvpn.gomobile -o "android\app\libs\masterdnsvpn.aar" masterdnsvpn-go/cmd/android *>&1 | ForEach-Object { Write-Host $_ }
if ($LASTEXITCODE -ne 0) {
Write-Host "ERROR: gomobile bind failed with exit code $LASTEXITCODE"
Write-Host "Full output above"
exit 1
}
Write-Host "=== AAR built successfully ==="
Write-Host "=== Step 2: Gradle assembleDebug ==="
Push-Location android
.\gradlew.bat assembleDebug 2>&1
$gradleExit = $LASTEXITCODE
Pop-Location
if ($gradleExit -ne 0) {
Write-Host "ERROR: Gradle build failed with exit code $gradleExit"
exit 1
}
Write-Host "=== APK built successfully ==="
Get-ChildItem "android\app\build\outputs\apk\debug\*.apk" | ForEach-Object {
Write-Host "APK: $($_.FullName) ($([math]::Round($_.Length/1MB,1)) MB)"
}