-
Notifications
You must be signed in to change notification settings - Fork 509
/
Copy pathmtk_build.sh
executable file
·48 lines (38 loc) · 1.35 KB
/
mtk_build.sh
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
#!/bin/bash
# Exit immediately if a command exits with a non-zero status.
set -e
# Define the directory where CMakeLists.txt is located
SOURCE_DIR=$(realpath "$(dirname "$0")/../../..")
# Check if buck2 exists
BUCK_PATH=${BUCK2:-buck2}
if [ -z "$BUCK2" ]; then
echo "Info: BUCK2 environment variable is not set." >&2
fi
# Check if the ANDROID_NDK environment variable is set
if [ -z "$ANDROID_NDK" ]; then
echo "Error: ANDROID_NDK environment variable is not set." >&2
exit 1
fi
# Check if the NEURON_BUFFER_ALLOCATOR_LIB environment variable is set
if [ -z "$NEURON_BUFFER_ALLOCATOR_LIB" ]; then
echo "Error: NEURON_BUFFER_ALLOCATOR_LIB environment variable is not set." >&2
exit 1
fi
# Create and enter the build directory
cd "$SOURCE_DIR"
rm -rf cmake-android-out && mkdir cmake-android-out && cd cmake-android-out
# Configure the project with CMake
# Note: Add any additional configuration options you need here
cmake -DBUCK2="$BUCK_PATH" \
-DCMAKE_TOOLCHAIN_FILE="$ANDROID_NDK/build/cmake/android.toolchain.cmake" \
-DANDROID_ABI=arm64-v8a \
-DEXECUTORCH_BUILD_NEURON=ON \
-DNEURON_BUFFER_ALLOCATOR_LIB="$NEURON_BUFFER_ALLOCATOR_LIB" \
..
# Build the project
cd ..
cmake --build cmake-android-out -j4
# Switch back to the original directory
cd - > /dev/null
# Print a success message
echo "Build successfully completed."