Skip to content

Commit

Permalink
Merge pull request #11 from argmaxinc/user/keith/clean_fix
Browse files Browse the repository at this point in the history
added 'make clean' fix
  • Loading branch information
keith4ever authored Dec 6, 2024
2 parents 0ec5240 + c1b80b7 commit 0ea9860
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 16 deletions.
18 changes: 15 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,20 @@
SCRIPTS_DIR = ./scripts

# Define targets for each script
.PHONY: setup env rebuild-env download-models build adb-push adb-shell help
.PHONY: setup env clean rebuild-env download-models build build_gpu build_x86 adb-push adb-shell help

help:
@echo "Available targets:"
@echo " setup Checking dependencies and any setup for the host."
@echo " download-models Download all models and files."
@echo " env Builds and runs docker environment to build axie_tflite CLI."
@echo " rebuild-env Rebuilds and runs docker environment."
@echo " build Build the axie_tflite CLI. Run this inside development environment."
@echo " build Build the axie_tflite CLI (QNN). Run this inside development environment."
@echo " build_gpu Build the axie_tflite CLI (GPU). Run this inside development environment."
@echo " build_x86 Build the axie_tflite CLI (x86). Run this inside development environment."
@echo " adb-push Push axie_tflite CLI and other dependencies to the Android device. Run this on host."
@echo " adb-shell Open an interactive ADB shell and setups environment. Run this on host."
@echo " clean Clean up previous build, both Android and x86."


setup:
Expand All @@ -38,8 +41,17 @@ env:
rebuild-env:
@bash $(SCRIPTS_DIR)/dev_env.sh -r

clean:
@bash $(SCRIPTS_DIR)/build.sh clean

build:
@bash $(SCRIPTS_DIR)/build.sh
@bash $(SCRIPTS_DIR)/build.sh qnn

build_x86:
@bash $(SCRIPTS_DIR)/build.sh x86

build_gpu:
@bash $(SCRIPTS_DIR)/build.sh gpu

adb-push:
@bash $(SCRIPTS_DIR)/adb_push.sh
Expand Down
39 changes: 26 additions & 13 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,9 @@ echo " ${0} gpu : build for arm64 Android (in build_android)"
echo " ${0} : build for Android with QNN (in build_android)"

arg=$1
if [[ "$arg" == "clean" ]]; then
if [ -d "build_android" ]; then
cd build_android
else
cd build_x86
fi

function build_clean {
# clean up the previous build
ninja clean
rm CMakeCache.txt
rm -rf CMakeFiles
Expand All @@ -23,30 +20,49 @@ if [[ "$arg" == "clean" ]]; then
rm -rf compile_commands.json
find . -name \CMakeCache.txt -type f -delete
rm build.ninja
exit 0
fi
}

CURRENT_DIR="$(dirname "$(realpath "$0")")"
SOURCE_DIR="$CURRENT_DIR/.."

if [[ "$arg" == "clean" ]]; then
if [ -d "$SOURCE_DIR/build_android" ]; then
cd $SOURCE_DIR/build_android
build_clean
fi

if [ -d "$SOURCE_DIR/build_x86" ]; then
cd $SOURCE_DIR/build_x86
build_clean
fi
exit 0
fi

if [[ "$arg" == "x86" ]]; then
PLATFORM="x86"
else
PLATFORM="android"
fi
mkdir -p $SOURCE_DIR/libs
mkdir -p $SOURCE_DIR/libs/$PLATFORM

BUILD_DIR="build_${PLATFORM}"

# check if libSDL3.so is built and exists
if [ ! -f $SOURCE_DIR/libs/$PLATFORM/libSDL3.so ]; then
echo "SDL3 libs are not found, building it now.."
./build_SDL.sh $arg
$SOURCE_DIR/scripts/build_SDL.sh $arg
fi

if [ ! -f $SOURCE_DIR/libs/$PLATFORM/libavcodec.so ]; then
echo "ffmpeg libs are not found, building it now.."
./build_ffmpeg.sh $arg
$SOURCE_DIR/scripts/build_ffmpeg.sh $arg
fi

if [ -d "$SOURCE_DIR/$BUILD_DIR" ]; then
cd $SOURCE_DIR/$BUILD_DIR
build_clean
fi

if [[ "$arg" == "x86" ]]; then
cmake \
Expand All @@ -58,9 +74,6 @@ if [[ "$arg" == "x86" ]]; then
-GNinja \
-DTENSORFLOW_SOURCE_DIR=${TENSORFLOW_SOURCE_DIR}
else
CURRENT_DIR="$(dirname "$(realpath "$0")")"
SOURCE_DIR="$CURRENT_DIR/.."

find "$TENSORFLOW_SOURCE_DIR/" $TENSORFLOW_SOURCE_DIR/bazel-bin/ -name libtensorflowlite_gpu_delegate.so -exec cp {} $SOURCE_DIR/libs/android/ \;

if [[ "$arg" == "gpu" ]]; then # Generic TFLite GPU delegate
Expand Down

0 comments on commit 0ea9860

Please sign in to comment.