-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-android.ps1
More file actions
62 lines (51 loc) · 1.98 KB
/
Copy pathbuild-android.ps1
File metadata and controls
62 lines (51 loc) · 1.98 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
# Build script for PaddleOCR-rs Android targets (Windows)
# Usage: .\build-android.ps1 [-Target <target>] [-Release] [-Features <features>]
#
# Note: ort-sys only provides prebuilt binaries for aarch64-linux-android.
# Other Android targets (armv7, x86_64) are NOT supported by ort-sys.
param(
[ValidateSet("aarch64-linux-android")]
[string]$Target = "aarch64-linux-android",
[switch]$Release,
[string]$Features = "ffi"
)
$ErrorActionPreference = "Stop"
# Check for Android NDK
if (-not $env:ANDROID_NDK_HOME -and -not $env:NDK_HOME) {
Write-Error "ANDROID_NDK_HOME or NDK_HOME environment variable not set"
Write-Host "Please install Android NDK and set the environment variable"
exit 1
}
$NDKDir = if ($env:ANDROID_NDK_HOME) { $env:ANDROID_NDK_HOME } else { $env:NDK_HOME }
Write-Host "Building for Android target: $Target"
Write-Host "NDK directory: $NDKDir"
Write-Host "Features: $Features"
Write-Host "Mode: $(if ($Release) { 'release' } else { 'debug' })"
Write-Host ""
Write-Host "Note: Only aarch64-linux-android is supported by ort-sys."
Write-Host " armv7-linux-androideabi and x86_64-linux-android are NOT supported."
# Build
$cargoArgs = @("build")
if ($Release) { $cargoArgs += "--release" }
$cargoArgs += "--target", $Target
$cargoArgs += "--features", $Features
& cargo @cargoArgs
# Find output file
$OutputDir = if ($Release) { "target\$Target\release" } else { "target\$Target\debug" }
$OutputFile = "paddleocr_rs_onnx.dll"
$OutputPath = "$OutputDir\$OutputFile"
if (Test-Path $OutputPath) {
Write-Host ""
Write-Host "Build successful!"
Write-Host "Output: $OutputPath"
Write-Host "Size: $((Get-Item $OutputPath).Length / 1MB) MB"
} else {
Write-Host ""
Write-Host "Build completed but output file not found at: $OutputPath"
Write-Host "Available files in $OutputDir:"
if (Test-Path $OutputDir) {
Get-ChildItem $OutputDir | Format-Table Name, Length
} else {
Write-Host " (directory not found)"
}
}