forked from rjyo/mosh-android
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-protobuf-android.sh
More file actions
executable file
·57 lines (43 loc) · 1.43 KB
/
build-protobuf-android.sh
File metadata and controls
executable file
·57 lines (43 loc) · 1.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
#!/bin/bash
set -e
ANDROID_NDK_HOME="/opt/homebrew/share/android-ndk"
BUILD_DIR="/Users/jyo/projects/ai/mosh-android"
SRC_DIR="$BUILD_DIR/src/protobuf-33.3"
OUTPUT_DIR="$BUILD_DIR/output"
API=24
# Ensure we have cmake
which cmake || brew install cmake
build_protobuf() {
local ARCH=$1
local ABI=$2
echo "=========================================="
echo "Building protobuf for $ARCH"
echo "=========================================="
local BUILD="$BUILD_DIR/build/protobuf-$ARCH"
local OUT="$OUTPUT_DIR/$ARCH/protobuf"
rm -rf "$BUILD"
mkdir -p "$BUILD" "$OUT"
cd "$BUILD"
cmake "$SRC_DIR" \
-DCMAKE_TOOLCHAIN_FILE="$ANDROID_NDK_HOME/build/cmake/android.toolchain.cmake" \
-DANDROID_ABI="$ABI" \
-DANDROID_PLATFORM="android-$API" \
-DCMAKE_INSTALL_PREFIX="$OUT" \
-Dprotobuf_BUILD_TESTS=OFF \
-Dprotobuf_BUILD_PROTOC_BINARIES=OFF \
-Dprotobuf_BUILD_SHARED_LIBS=OFF \
-Dprotobuf_BUILD_LIBPROTOC=OFF \
-Dprotobuf_WITH_ZLIB=OFF \
-Dprotobuf_ABSL_PROVIDER="module" \
-DCMAKE_BUILD_TYPE=Release
cmake --build . --parallel $(sysctl -n hw.ncpu)
cmake --install .
echo "protobuf for $ARCH built!"
}
# Build for arm64-v8a
build_protobuf "arm64-v8a" "arm64-v8a"
# Build for armeabi-v7a
build_protobuf "armeabi-v7a" "armeabi-v7a"
# Build for x86_64
build_protobuf "x86_64" "x86_64"
echo "All protobuf builds complete!"