-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-android.sh
More file actions
89 lines (79 loc) · 2.43 KB
/
Copy pathbuild-android.sh
File metadata and controls
89 lines (79 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/bin/bash
# Build script for PaddleOCR-rs Android targets
# Usage: ./build-android.sh [target] [--release]
#
# Note: ort-sys only provides prebuilt binaries for aarch64-linux-android.
# Other Android targets (armv7, x86_64) are NOT supported by ort-sys.
set -e
# Default values
TARGET="aarch64-linux-android"
RELEASE=""
FEATURES="ffi"
# Parse arguments
while [[ $# -gt 0 ]]; do
case $1 in
aarch64-linux-android)
TARGET="$1"
shift
;;
--release)
RELEASE="--release"
shift
;;
--features)
FEATURES="$2"
shift 2
;;
--help|-h)
echo "Usage: $0 [target] [--release] [--features features]"
echo ""
echo "Supported targets:"
echo " aarch64-linux-android ARM64 (default)"
echo ""
echo "Note: armv7-linux-androideabi and x86_64-linux-android"
echo " are NOT supported by ort-sys prebuilt binaries."
echo ""
echo "Options:"
echo " --release Build in release mode"
echo " --features Comma-separated list of features to enable"
exit 0
;;
*)
echo "Unknown option: $1"
echo "Only aarch64-linux-android is supported by ort-sys."
exit 1
;;
esac
done
# Check for Android NDK
if [ -z "$ANDROID_NDK_HOME" ] && [ -z "$NDK_HOME" ]; then
echo "Error: ANDROID_NDK_HOME or NDK_HOME environment variable not set"
echo "Please install Android NDK and set the environment variable"
exit 1
fi
NDK_DIR="${ANDROID_NDK_HOME:-$NDK_HOME}"
echo "Building for Android target: $TARGET"
echo "NDK directory: $NDK_DIR"
echo "Features: $FEATURES"
echo "Mode: ${RELEASE:+release}${RELEASE:-debug}"
# Build
cargo build $RELEASE --target "$TARGET" --features "$FEATURES"
# Find output file
if [ -n "$RELEASE" ]; then
OUTPUT_DIR="target/$TARGET/release"
else
OUTPUT_DIR="target/$TARGET/debug"
fi
OUTPUT_FILE="libpaddleocr_rs_onnx.so"
OUTPUT_PATH="$OUTPUT_DIR/$OUTPUT_FILE"
if [ -f "$OUTPUT_PATH" ]; then
echo ""
echo "Build successful!"
echo "Output: $OUTPUT_PATH"
echo "Size: $(du -h "$OUTPUT_PATH" | cut -f1)"
else
echo ""
echo "Build completed but output file not found at: $OUTPUT_PATH"
echo "Available files in $OUTPUT_DIR:"
ls -la "$OUTPUT_DIR/" 2>/dev/null || echo " (directory not found)"
fi