Skip to content

Commit c665514

Browse files
committed
feat(android): add support for armeabi-v7a
1 parent 0964d9c commit c665514

File tree

2 files changed

+24
-10
lines changed

2 files changed

+24
-10
lines changed

.github/workflows/main.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
build:
1313
runs-on: ${{ matrix.os }}
1414
container: ${{ matrix.container && matrix.container || '' }}
15-
name: ${{ matrix.name }}${{ matrix.arch && format('-{0}', matrix.arch) || '' }} build${{ matrix.arch != 'arm64-v8a' && matrix.name != 'ios-sim' && matrix.name != 'ios' && matrix.name != 'apple-xcframework' && matrix.name != 'android-aar' && ( matrix.name != 'macos' || matrix.arch != 'x86_64' ) && ' + test' || ''}}
15+
name: ${{ matrix.name }}${{ matrix.arch && format('-{0}', matrix.arch) || '' }} build${{ matrix.arch != 'arm64-v8a' && matrix.arch != 'armeabi-v7a' && matrix.name != 'ios-sim' && matrix.name != 'ios' && matrix.name != 'apple-xcframework' && matrix.name != 'android-aar' && ( matrix.name != 'macos' || matrix.arch != 'x86_64' ) && ' + test' || ''}}
1616
timeout-minutes: 20
1717
strategy:
1818
fail-fast: false
@@ -49,6 +49,10 @@ jobs:
4949
arch: arm64-v8a
5050
name: android
5151
make: PLATFORM=android ARCH=arm64-v8a
52+
- os: ubuntu-22.04
53+
arch: armeabi-v7a
54+
name: android
55+
make: PLATFORM=android ARCH=armeabi-v7a
5256
- os: ubuntu-22.04
5357
arch: x86_64
5458
name: android
@@ -161,7 +165,7 @@ jobs:
161165
security delete-keychain build.keychain
162166
163167
- name: android setup test environment
164-
if: matrix.name == 'android' && matrix.arch != 'arm64-v8a'
168+
if: matrix.name == 'android' && matrix.arch != 'arm64-v8a' && matrix.arch != 'armeabi-v7a'
165169
run: |
166170
167171
echo "::group::enable kvm group perms"
@@ -192,7 +196,7 @@ jobs:
192196
echo "::endgroup::"
193197
194198
- name: android test sqlite-sync
195-
if: matrix.name == 'android' && matrix.arch != 'arm64-v8a'
199+
if: matrix.name == 'android' && matrix.arch != 'arm64-v8a' && matrix.arch != 'armeabi-v7a'
196200
uses: reactivecircus/[email protected]
197201
with:
198202
api-level: 26

Makefile

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ else ifeq ($(PLATFORM),macos)
8686
STRIP = strip -x -S $@
8787
else ifeq ($(PLATFORM),android)
8888
ifndef ARCH # Set ARCH to find Android NDK's Clang compiler, the user should set the ARCH
89-
$(error "Android ARCH must be set to ARCH=x86_64 or ARCH=arm64-v8a")
89+
$(error "Android ARCH must be set to ARCH=x86_64, ARCH=arm64-v8a, or ARCH=armeabi-v7a")
9090
endif
9191
ifndef ANDROID_NDK # Set ANDROID_NDK path to find android build tools; e.g. on MacOS: export ANDROID_NDK=/Users/username/Library/Android/sdk/ndk/25.2.9519653
9292
$(error "Android NDK must be set")
@@ -97,11 +97,17 @@ else ifeq ($(PLATFORM),android)
9797

9898
ifneq (,$(filter $(ARCH),arm64 arm64-v8a))
9999
override ARCH := aarch64
100+
ANDROID_ABI := android26
101+
else ifeq ($(ARCH),armeabi-v7a)
102+
override ARCH := armv7a
103+
ANDROID_ABI := androideabi26
104+
else
105+
ANDROID_ABI := android26
100106
endif
101107

102108
OPENSSL := $(BIN)/../sysroot/usr/include/openssl
103-
CC = $(BIN)/$(ARCH)-linux-android26-clang
104-
CURL_CONFIG = --host $(ARCH)-$(HOST)-android26 --with-openssl=$(BIN)/../sysroot/usr LIBS="-lssl -lcrypto" AR=$(BIN)/llvm-ar AS=$(BIN)/llvm-as CC=$(CC) CXX=$(BIN)/$(ARCH)-linux-android26-clang++ LD=$(BIN)/ld RANLIB=$(BIN)/llvm-ranlib STRIP=$(BIN)/llvm-strip
109+
CC = $(BIN)/$(ARCH)-linux-$(ANDROID_ABI)-clang
110+
CURL_CONFIG = --host $(ARCH)-linux-$(ANDROID_ABI) --with-openssl=$(BIN)/../sysroot/usr LIBS="-lssl -lcrypto" AR=$(BIN)/llvm-ar AS=$(BIN)/llvm-as CC=$(CC) CXX=$(BIN)/$(ARCH)-linux-$(ANDROID_ABI)-clang++ LD=$(BIN)/ld RANLIB=$(BIN)/llvm-ranlib STRIP=$(BIN)/llvm-strip
105111
TARGET := $(DIST_DIR)/cloudsync.so
106112
LDFLAGS += -shared -lcrypto -lssl
107113
STRIP = $(BIN)/llvm-strip --strip-unneeded $@
@@ -202,7 +208,7 @@ $(OPENSSL):
202208
git clone https://github.com/openssl/openssl.git $(CURL_DIR)/src/openssl
203209

204210
cd $(CURL_DIR)/src/openssl && \
205-
./Configure android-$(if $(filter aarch64,$(ARCH)),arm64,$(ARCH)) \
211+
./Configure android-$(if $(filter aarch64,$(ARCH)),arm64,$(if $(filter armv7a,$(ARCH)),arm,$(ARCH))) \
206212
--prefix=$(BIN)/../sysroot/usr \
207213
no-shared no-unit-test \
208214
-D__ANDROID_API__=26 && \
@@ -353,14 +359,18 @@ $(DIST_DIR)/%.xcframework: $(LIB_NAMES)
353359

354360
xcframework: $(DIST_DIR)/CloudSync.xcframework
355361

356-
AAR_ARM = packages/android/src/main/jniLibs/arm64-v8a/
362+
AAR_ARM64 = packages/android/src/main/jniLibs/arm64-v8a/
363+
AAR_ARM = packages/android/src/main/jniLibs/armeabi-v7a/
357364
AAR_X86 = packages/android/src/main/jniLibs/x86_64/
358365
AAR_USR = $(ANDROID_NDK)/toolchains/llvm/prebuilt/$(HOST)-x86_64/sysroot/usr/
359366
AAR_CLEAN = rm -rf $(CURL_DIR)/android $(AAR_USR)bin/openssl $(AAR_USR)include/openssl $(AAR_USR)lib/libssl.a $(AAR_USR)lib/libcrypto.a $(AAR_USR)lib/ossl-modules
360367
aar:
361-
mkdir -p $(AAR_ARM) $(AAR_X86)
368+
mkdir -p $(AAR_ARM64) $(AAR_ARM) $(AAR_X86)
362369
$(AAR_CLEAN)
363370
$(MAKE) clean && $(MAKE) PLATFORM=android ARCH=arm64-v8a
371+
mv $(DIST_DIR)/cloudsync.so $(AAR_ARM64)
372+
$(AAR_CLEAN)
373+
$(MAKE) clean && $(MAKE) PLATFORM=android ARCH=armeabi-v7a
364374
mv $(DIST_DIR)/cloudsync.so $(AAR_ARM)
365375
$(AAR_CLEAN)
366376
$(MAKE) clean && $(MAKE) PLATFORM=android ARCH=x86_64
@@ -386,7 +396,7 @@ help:
386396
@echo " linux (default on Linux)"
387397
@echo " macos (default on macOS - can be compiled with native network support)"
388398
@echo " windows (default on Windows)"
389-
@echo " android (needs ARCH to be set to x86_64 or arm64-v8a and ANDROID_NDK to be set)"
399+
@echo " android (needs ARCH to be set to x86_64, arm64-v8a, or armeabi-v7a and ANDROID_NDK to be set)"
390400
@echo " ios (only on macOS - can be compiled with native network support)"
391401
@echo " ios-sim (only on macOS - can be compiled with native network support)"
392402
@echo ""

0 commit comments

Comments
 (0)