Skip to content

Commit 4266820

Browse files
Refactor MTK build scripts Test building MTK examples and runners in ci (#13085)
### Summary - Add building MTK examples to CI - Separate MTK backend build script and example build script
1 parent 2f782bf commit 4266820

File tree

4 files changed

+17
-24
lines changed

4 files changed

+17
-24
lines changed

.ci/scripts/build-mediatek-sdk.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ build_neuron_backend() {
1414
export NEURON_BUFFER_ALLOCATOR_LIB=${MEDIATEK_SDK_ROOT}/libneuron_buffer_allocator.so
1515
export EXECUTORCH_ROOT="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/../.." && pwd)"
1616

17-
1817
cd ${EXECUTORCH_ROOT}
1918
./backends/mediatek/scripts/mtk_build.sh
19+
./examples/mediatek/mtk_build_examples.sh
2020
}
2121

2222
build_neuron_backend

backends/mediatek/scripts/mtk_build.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,20 @@
44
set -e
55

66
# Define the directory where CMakeLists.txt is located
7-
SOURCE_DIR=$(realpath "$(dirname "$0")/../../..")
7+
EXECUTORCH_ROOT=$(realpath "$(dirname "$0")/../../..")
8+
echo EXECUTORCH_ROOT=${EXECUTORCH_ROOT}
89

910
# Check if the ANDROID_NDK environment variable is set
1011
if [ -z "$ANDROID_NDK" ]; then
1112
echo "Error: ANDROID_NDK environment variable is not set." >&2
1213
exit 1
1314
fi
1415

15-
# Create and enter the build directory
16+
# Enter the build directory
17+
cd "$EXECUTORCH_ROOT"
18+
1619
# Set build directory
1720
build_dir="cmake-android-out"
18-
cd "$SOURCE_DIR"
1921
rm -rf "${build_dir}"
2022

2123
# Configure the project with CMake

examples/mediatek/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ examples/mediatek
2828
## Environment Setup
2929
- Follow the instructions of **Prerequisites** and **Setup** in `backends/mediatek/scripts/README.md`.
3030

31+
- Build required libraries by `backends/mediatek/scripts/mtk_build.sh` before building examples.
32+
3133
## Build MediaTek Examples
3234
1. Build the backend and the examples by exedcuting the script:
3335
```bash

examples/mediatek/mtk_build_examples.sh

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,18 @@ if [ -z "$ANDROID_NDK" ]; then
1414
fi
1515

1616
main() {
17-
# Set build directory
18-
local build_dir="cmake-android-out"
19-
20-
# Create and enter the build directory
17+
# Enter the build directory
2118
cd "$EXECUTORCH_ROOT"
22-
rm -rf "${build_dir}"
23-
24-
# Configure the project with CMake
25-
# Note: Add any additional configuration options you need here
26-
cmake -DCMAKE_INSTALL_PREFIX="${build_dir}" \
27-
-DCMAKE_TOOLCHAIN_FILE="$ANDROID_NDK/build/cmake/android.toolchain.cmake" \
28-
-DANDROID_ABI=arm64-v8a \
29-
-DANDROID_NATIVE_API_LEVEL=26 \
30-
-DANDROID_PLATFORM=android-26 \
31-
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
32-
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
33-
-DEXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR=ON \
34-
-DEXECUTORCH_BUILD_NEURON=ON \
35-
-B"${build_dir}"
3619

20+
# Set build directory
21+
local build_dir="cmake-android-out"
3722

38-
# Build the project
39-
cmake --build "${build_dir}" --target install --config Release -j5
23+
# Check if the build directory exists
24+
if [ ! -d "$EXECUTORCH_ROOT/$build_dir" ]; then
25+
echo "Error: Build directory '$build_dir' does not exist."
26+
echo "Please build MTK backend before running this script."
27+
exit 1
28+
fi
4029

4130
## Build example
4231
local example_dir=examples/mediatek

0 commit comments

Comments
 (0)