Skip to content

Commit

Permalink
Use Ant compile demo and UT projects when NDK version lower than r18 (#…
Browse files Browse the repository at this point in the history
…3690)

* android-ndk-r18b and below use Ant to compile demo and unit_test projects

* give the ndk-version-check.sh executable permissions
  • Loading branch information
BenzhengZhang committed Oct 23, 2023
1 parent b3feec2 commit 15d02fc
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 3 deletions.
23 changes: 20 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ CCASFLAGS=$(CFLAGS)
STATIC_LDFLAGS=-lstdc++
STRIP ?= strip
USE_STACK_PROTECTOR = Yes
USE_LOW_VERSION_NDK=No
USE_ANT=No

SHAREDLIB_MAJORVERSION=7
FULL_VERSION := 2.3.0
Expand Down Expand Up @@ -80,10 +82,16 @@ endif
# Make sure the all target is the first one
all: libraries binaries

ifeq ($(findstring android-ndk-r18, $(NDKROOT)), android-ndk-r18)
include $(SRC_PATH)build/platform-android-r18b.mk
ifeq (android, $(OS))
USE_LOW_VERSION_NDK = $(shell $(SRC_PATH)build/ndk-version-check.sh $(NDKROOT))
ifeq (Yes, $(USE_LOW_VERSION_NDK))
USE_ANT = Yes
include $(SRC_PATH)build/platform-android-r18b.mk
else
include $(SRC_PATH)build/platform-$(OS).mk
include $(SRC_PATH)build/platform-android.mk
endif
else
include $(SRC_PATH)build/platform-$(OS).mk
endif

MODULE := $(LIBPREFIX)$(MODULE_NAME).$(SHAREDLIBSUFFIX)
Expand Down Expand Up @@ -368,14 +376,23 @@ endif
ifeq (android,$(OS))
ifeq (./,$(SRC_PATH))
codec_unittest$(EXEEXT):
ifeq ($(USE_ANT), Yes)
cd ./test/build/android && $(NDKROOT)/ndk-build -B APP_ABI=$(APP_ABI) && android update project -t $(TARGET) -p . && ant debug
else
$(NDK_BUILD) -C test/build/android -B
./gradlew unittest:assembleDebug
endif

clean_Android: clean_Android_ut
clean_Android_ut:
ifeq ($(USE_ANT), Yes)
-cd ./test/build/android && $(NDKROOT)/ndk-build APP_ABI=$(APP_ABI) clean && ant clean
else
-$(NDK_BUILD) -C test/build/android -B clean
-./gradlew unittest:clean
endif

endif
endif

endif
Expand Down
22 changes: 22 additions & 0 deletions build/ndk-version-check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash
#**********************************************************************************
# This script is using in Makefile to check the ndk version:
#
# --usage:
# ./ndk-version-check.sh ndkroot
#
# date: 10/20/2023 Created
#**********************************************************************************

NDK_PATH=$1
if [ ! -n "$NDK_PATH" ]
then
exit 1
fi
NDK_VERSION=${NDK_PATH##*/}
NDK_VERSION_NUM=`echo $NDK_VERSION | tr -cd "[0-9]"`

if [ $NDK_VERSION_NUM -le 18 ]
then
echo "Yes"
fi

0 comments on commit 15d02fc

Please sign in to comment.