Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .ci/scripts/build-mediatek-sdk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ build_neuron_backend() {
export NEURON_BUFFER_ALLOCATOR_LIB=${MEDIATEK_SDK_ROOT}/libneuron_buffer_allocator.so
export EXECUTORCH_ROOT="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/../.." && pwd)"


cd ${EXECUTORCH_ROOT}
./backends/mediatek/scripts/mtk_build.sh
./examples/mediatek/mtk_build_examples.sh
}

build_neuron_backend
8 changes: 5 additions & 3 deletions backends/mediatek/scripts/mtk_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,20 @@
set -e

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

# 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

# Create and enter the build directory
# Enter the build directory
cd "$EXECUTORCH_ROOT"

# Set build directory
build_dir="cmake-android-out"
cd "$SOURCE_DIR"
rm -rf "${build_dir}"

# Configure the project with CMake
Expand Down
2 changes: 2 additions & 0 deletions examples/mediatek/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ examples/mediatek
## Environment Setup
- Follow the instructions of **Prerequisites** and **Setup** in `backends/mediatek/scripts/README.md`.

- Build required libraries by `backends/mediatek/scripts/mtk_build.sh` before building examples.

## Build MediaTek Examples
1. Build the backend and the examples by exedcuting the script:
```bash
Expand Down
29 changes: 9 additions & 20 deletions examples/mediatek/mtk_build_examples.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,18 @@ if [ -z "$ANDROID_NDK" ]; then
fi

main() {
# Set build directory
local build_dir="cmake-android-out"

# Create and enter the build directory
# Enter the build directory
cd "$EXECUTORCH_ROOT"
rm -rf "${build_dir}"

# Configure the project with CMake
# Note: Add any additional configuration options you need here
cmake -DCMAKE_INSTALL_PREFIX="${build_dir}" \
-DCMAKE_TOOLCHAIN_FILE="$ANDROID_NDK/build/cmake/android.toolchain.cmake" \
-DANDROID_ABI=arm64-v8a \
-DANDROID_NATIVE_API_LEVEL=26 \
-DANDROID_PLATFORM=android-26 \
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
-DEXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR=ON \
-DEXECUTORCH_BUILD_NEURON=ON \
-B"${build_dir}"

# Set build directory
local build_dir="cmake-android-out"

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

## Build example
local example_dir=examples/mediatek
Expand Down
Loading