Skip to content

Commit 15d02fc

Browse files
Use Ant compile demo and UT projects when NDK version lower than r18 (#3690)
* android-ndk-r18b and below use Ant to compile demo and unit_test projects * give the ndk-version-check.sh executable permissions
1 parent b3feec2 commit 15d02fc

File tree

2 files changed

+42
-3
lines changed

2 files changed

+42
-3
lines changed

Makefile

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ CCASFLAGS=$(CFLAGS)
3535
STATIC_LDFLAGS=-lstdc++
3636
STRIP ?= strip
3737
USE_STACK_PROTECTOR = Yes
38+
USE_LOW_VERSION_NDK=No
39+
USE_ANT=No
3840

3941
SHAREDLIB_MAJORVERSION=7
4042
FULL_VERSION := 2.3.0
@@ -80,10 +82,16 @@ endif
8082
# Make sure the all target is the first one
8183
all: libraries binaries
8284

83-
ifeq ($(findstring android-ndk-r18, $(NDKROOT)), android-ndk-r18)
84-
include $(SRC_PATH)build/platform-android-r18b.mk
85+
ifeq (android, $(OS))
86+
USE_LOW_VERSION_NDK = $(shell $(SRC_PATH)build/ndk-version-check.sh $(NDKROOT))
87+
ifeq (Yes, $(USE_LOW_VERSION_NDK))
88+
USE_ANT = Yes
89+
include $(SRC_PATH)build/platform-android-r18b.mk
8590
else
86-
include $(SRC_PATH)build/platform-$(OS).mk
91+
include $(SRC_PATH)build/platform-android.mk
92+
endif
93+
else
94+
include $(SRC_PATH)build/platform-$(OS).mk
8795
endif
8896

8997
MODULE := $(LIBPREFIX)$(MODULE_NAME).$(SHAREDLIBSUFFIX)
@@ -368,14 +376,23 @@ endif
368376
ifeq (android,$(OS))
369377
ifeq (./,$(SRC_PATH))
370378
codec_unittest$(EXEEXT):
379+
ifeq ($(USE_ANT), Yes)
380+
cd ./test/build/android && $(NDKROOT)/ndk-build -B APP_ABI=$(APP_ABI) && android update project -t $(TARGET) -p . && ant debug
381+
else
371382
$(NDK_BUILD) -C test/build/android -B
372383
./gradlew unittest:assembleDebug
384+
endif
373385

374386
clean_Android: clean_Android_ut
375387
clean_Android_ut:
388+
ifeq ($(USE_ANT), Yes)
389+
-cd ./test/build/android && $(NDKROOT)/ndk-build APP_ABI=$(APP_ABI) clean && ant clean
390+
else
376391
-$(NDK_BUILD) -C test/build/android -B clean
377392
-./gradlew unittest:clean
378393
endif
394+
395+
endif
379396
endif
380397

381398
endif

build/ndk-version-check.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
#**********************************************************************************
3+
# This script is using in Makefile to check the ndk version:
4+
#
5+
# --usage:
6+
# ./ndk-version-check.sh ndkroot
7+
#
8+
# date: 10/20/2023 Created
9+
#**********************************************************************************
10+
11+
NDK_PATH=$1
12+
if [ ! -n "$NDK_PATH" ]
13+
then
14+
exit 1
15+
fi
16+
NDK_VERSION=${NDK_PATH##*/}
17+
NDK_VERSION_NUM=`echo $NDK_VERSION | tr -cd "[0-9]"`
18+
19+
if [ $NDK_VERSION_NUM -le 18 ]
20+
then
21+
echo "Yes"
22+
fi

0 commit comments

Comments
 (0)