Repository navigation
Expand file tree
/
Copy pathbuild_android_libs.ps1
More file actions
66 lines (54 loc) · 2.43 KB
/
Copy pathbuild_android_libs.ps1
File metadata and controls
66 lines (54 loc) · 2.43 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# =============================================================================
# TechScript AppForge — Native Library Cross-Compilation Script
# examples/appforge/techscript-appforge/build_android_libs.ps1
#
# Builds release-optimized libts_android.so for both arm64-v8a and x86_64
# and installs them into android/app/src/main/jniLibs.
# =============================================================================
[CmdletBinding()]
param (
[string]$NdkPath = "C:\AndroidSDK\ndk\27.1.12297006",
[string]$Profile = "release"
)
$ErrorActionPreference = "Stop"
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$projectRoot = Resolve-Path (Join-Path $scriptDir "..\..\..")
$outJniLibs = Join-Path $scriptDir "android\app\src\main\jniLibs"
Write-Host "============================================================" -ForegroundColor Cyan
Write-Host " TechScript AppForge Native Library Builder" -ForegroundColor Cyan
Write-Host " Project Root: $projectRoot" -ForegroundColor Gray
Write-Host " Output JNI: $outJniLibs" -ForegroundColor Gray
Write-Host " NDK Path: $NdkPath" -ForegroundColor Gray
Write-Host " Profile: $Profile" -ForegroundColor Gray
Write-Host "============================================================" -ForegroundColor Cyan
if (-not (Test-Path $NdkPath)) {
# Check alternate NDK paths under C:\AndroidSDK\ndk
$found = Get-ChildItem -Path "C:\AndroidSDK\ndk" -Directory -ErrorAction SilentlyContinue | Select-Object -Last 1
if ($found) {
$NdkPath = $found.FullName
Write-Host " Auto-detected NDK: $NdkPath" -ForegroundColor Yellow
} else {
Write-Error "Android NDK not found at $NdkPath. Please specify -NdkPath or install via Android Studio SDK Manager."
}
}
$env:ANDROID_NDK_HOME = $NdkPath
Set-Location $projectRoot
$buildArgs = @(
"ndk",
"-t", "arm64-v8a",
"-t", "x86_64",
"-o", $outJniLibs,
"build",
"-p", "techscript_android_runtime"
)
if ($Profile -eq "release") {
$buildArgs += "--release"
}
Write-Host " Running: cargo $($buildArgs -join ' ')" -ForegroundColor Green
& cargo $buildArgs
if ($LASTEXITCODE -ne 0) {
Write-Error "cargo-ndk build failed with exit code $LASTEXITCODE"
}
Write-Host "`n Output Binaries:" -ForegroundColor Cyan
Get-ChildItem -Path $outJniLibs -Recurse -File | Select-Object Name, Length, LastWriteTime | Format-Table -AutoSize
Write-Host " AppForge native libraries successfully built and staged!" -ForegroundColor Green