diff --git a/android/build.gradle b/android/build.gradle index 6386d44..171b91a 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -50,7 +50,7 @@ android { manifest.srcFile 'AndroidManifest.xml' // where to find generated Java source - java.srcDirs = ['../src', 'src', '../src/java'] + java.srcDirs = ['../src', 'src', '../src/java', '../../downloadclient', '../../signedpkg', '../../pEpEngine'] jniLibs.srcDirs = ['libs', // 'external/data/data/security.pEp/app_opt/lib' ] @@ -78,7 +78,7 @@ android { jniDebuggable true externalNativeBuild { ndkBuild { - arguments "-j${threadsToUse}", 'NDK_LOG=1', 'NDK_DEBUG=1', 'NDEBUG=null' + arguments "-j${threadsToUse}", 'NDK_LOG=0', 'NDK_DEBUG=1', 'NDEBUG=null', '--output-sync=none' // arguments '-B', 'NDK_DEBUG=1', 'NDEBUG=null', 'NDK_LOG=1' } } diff --git a/android/external/Makefile.conf b/android/external/Makefile.conf index 514e8ee..81a9b81 100644 --- a/android/external/Makefile.conf +++ b/android/external/Makefile.conf @@ -25,6 +25,7 @@ GMP_VERSION=6.2.1 NETTLE_VERSION=3.7.3 BOOST_VERSION=1.74.0 LIB_ARCHIVE_VERSION=3.6.1 +LIB_XML_VERSION=2.10.0 ### Git deps repos EXTERNAL_GIT_REPOS += libetpan|https://gitea.pep.foundation/pEp.foundation/libetpan.git?507ab94fc9609432ef2d4c62770139482f1b5084 @@ -34,7 +35,7 @@ EXTERNAL_GIT_REPOS += cryptopp|https://github.com/weidai11/cryptopp.git?CRYPTOPP ### Common variables #### Source code targets -EXTERNAL_SRCS += libiconv-src +EXTERNAL_SRCS += libiconv- EXTERNAL_SRCS += uuid-src EXTERNAL_SRCS += openssl-src EXTERNAL_SRCS += gmp-src @@ -49,6 +50,7 @@ EXTERNAL_SRCS_CLEAN += gmp-clean EXTERNAL_SRCS_CLEAN += nettle-clean EXTERNAL_SRCS_CLEAN += sequoia-ffi-clean EXTERNAL_SRCS_CLEAN += cryptopp-clean +EXTERNAL_SRCS_CLEAN += libarchive-clean ### Other variables ANDROID_ETPAN_BUILD_VERSION=2 diff --git a/android/external/arm64-v8a/Makefile b/android/external/arm64-v8a/Makefile index 60730bd..529b7df 100644 --- a/android/external/arm64-v8a/Makefile +++ b/android/external/arm64-v8a/Makefile @@ -17,7 +17,7 @@ APP_ABI ?= arm64-v8a all: build -build: showsetup uuid-install sequoia-ffi-install libetpan-build cryptopp-install +build: showsetup uuid-install sequoia-ffi-install libetpan-build cryptopp-install libarchive-install #------------------------------------------------------------------------------# # Manage paths for PREFIX, DESTDIR, LOCAL and PATH @@ -50,8 +50,8 @@ CXX := $(ANDROID_NDK_HOME)/bin/$(HOST)$(ANDROID_API)-clang++ RANLIB := $(ANDROID_NDK_HOME)/bin/$(HOST)-ranlib STRIP := $(ANDROID_NDK_HOME)/bin/$(HOST)-strip -CFLAGS += -DANDROID -I$(LOCAL)/include $(TARGET_CFLAGS) -fPIE -fPIC -std=c99 -LDFLAGS += -llog -L$(LOCAL)/lib $(TARGET_LDFLAGS) -pie +CFLAGS += -DANDROID -I$(LOCAL)/include $(TARGET_CFLAGS) -fPIE -fPIC -std=c99 --sysroot=$(NDK_SYSROOT) +LDFLAGS += -lz -llog -L$(LOCAL)/lib $(TARGET_LDFLAGS) -pie --sysroot=$(NDK_SYSROOT) # change 'release' to 'debug' for unoptimized debug builds CFLAGS += $(TARGET_arm64_debug_CFLAGS) @@ -209,6 +209,7 @@ openssl/libssl.so: | openssl/Makefile PATH="$(ANDROID_NDK_HOME)/bin:$(PATH)" $(MAKE) -C openssl $(LOCAL)/lib/libssl.so: openssl/libssl.so + mkdir -p $(LOCAL) $(MAKE) -C openssl install ls -l $(LOCAL)/lib @@ -300,13 +301,13 @@ libarchive.src.stamp: ../downloads/libarchive-$(LIB_ARCHIVE_VERSION).tar.gz mv libarchive-$(LIB_ARCHIVE_VERSION) libarchive touch $@ -libarchive-src: nettle.src.stamp gmp-install +libarchive-src: libarchive.src.stamp libarchive-clean: rm -rf libarchive rm -rf libarchive.src.stamp -libarchive/Makefile: libarchive.src.stamp +libarchive/Makefile: libarchive.src.stamp libarchive-install cd libarchive && \ CC="$(CC)" LD="$(LD)" AR="$(AR)" AS="$(AS)" RANLIB=$(RANLIB) STRIP="$(STRIP)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \ ./configure \ @@ -328,7 +329,42 @@ libarchive-build: libarchive/libarchive.so libarchive-install: $(LOCAL)/lib/libarchive.so +#------------------------------------------------------------------------------# +# libxml2 + +libxml2.src.stamp: ../downloads/libxml2-$(LIB_XML_VERSION).tar.xz + tar xvf $< + mv libxml2-$(LIB_XML_VERSION) libxml2 + touch $@ + +libxml2-src: libxml2.src.stamp + +libxml2-clean: + rm -rf libxml2 + rm -rf libxml2.src.stamp + +#There is a libxml2 version on the AOSP source code: https://android.googlesource.com/platform/external/libxml2/ +#, maybe it is a good idea to take it from there instead of mainstrem +libxml2/Makefile: libxml2.src.stamp + cd libxml2 && \ + CC="$(CC)" LD="$(LD)" AR="$(AR)" AS="$(AS)" RANLIB=$(RANLIB) STRIP="$(STRIP)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \ + ./configure \ + --enable-static \ + --disable-shared \ + --without-lzma \ + --without-zlib \ + --host=$(HOST) \ + --prefix=$(LOCAL) + +libxml2/.libs/libxml2.a: libxml2/Makefile + $(MAKE) -C libxml2 + +$(LOCAL)/lib/libxml2.a: libxml2/.libs/libxml2.a + $(MAKE) -C libxml2 DESTDIR=$(DESTDIR) prefix=$(prefix) install + +libxml2-build: libxml2/.libs/libxml2.a +libxml2-install: $(LOCAL)/lib/libxml2.a #------------------------------------------------------------------------------# # Sequoia-ffi diff --git a/android/external/armeabi-v7a/Makefile b/android/external/armeabi-v7a/Makefile index 8a2991c..b88569c 100644 --- a/android/external/armeabi-v7a/Makefile +++ b/android/external/armeabi-v7a/Makefile @@ -17,7 +17,7 @@ APP_ABI ?= armeabi-v7a all: build #assets -build: showsetup uuid-install sequoia-ffi-install libetpan-build cryptopp-install +build: showsetup uuid-install sequoia-ffi-install libetpan-build cryptopp-install archive-install #------------------------------------------------------------------------------# @@ -214,6 +214,7 @@ openssl/libssl.so: | openssl/Makefile PATH="$(ANDROID_NDK_HOME)/bin:$(PATH)" $(MAKE) -C openssl $(LOCAL)/lib/libssl.so: openssl/libssl.so + mkdir -p $(LOCAL) $(MAKE) -C openssl install ls -l $(LOCAL)/lib @@ -295,6 +296,79 @@ nettle-build: nettle/libnettle.so nettle-install: $(LOCAL)/lib/libnettle.so +#------------------------------------------------------------------------------# +# LibArchive + +libarchive.src.stamp: ../downloads/libarchive-$(LIB_ARCHIVE_VERSION).tar.gz + tar xvf $< + mv libarchive-$(LIB_ARCHIVE_VERSION) libarchive + touch $@ + +libarchive-src: libarchive.src.stamp + +libarchive-clean: + rm -rf libarchive + rm -rf libarchive.src.stamp + +libarchive/Makefile: libarchive.src.stamp libarchive-install + cd libarchive && \ + CC="$(CC)" LD="$(LD)" AR="$(AR)" AS="$(AS)" RANLIB=$(RANLIB) STRIP="$(STRIP)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \ + ./configure \ + --with-lib-path=$(LOCAL)/lib \ + --with-include-path=$(LOCAL)/include \ + --disable-documentation \ + --disable-bsdtar \ + --disable-bsdcpio \ + --host=$(HOST) \ + --prefix=$(LOCAL) + +libarchive/libarchive.so: libarchive/Makefile + $(MAKE) -C libarchive + +$(LOCAL)/lib/libarchive.so: libarchive/libarchive.so + $(MAKE) -C libarchive DESTDIR=$(DESTDIR) prefix=$(prefix) install + +libarchive-build: libarchive/libarchive.so + +libarchive-install: $(LOCAL)/lib/libarchive.so + +#------------------------------------------------------------------------------# +# libxml2 + + +libxml2.src.stamp: ../downloads/libxml2-$(LIB_XML_VERSION).tar.xz + tar xvf $< + mv libxml2-$(LIB_XML_VERSION) libxml2 + touch $@ + +libxml2-src: libxml2.src.stamp + +libxml2-clean: + rm -rf libxml2 + rm -rf libxml2.src.stamp + +#There is a libxml2 version on the AOSP source code: https://android.googlesource.com/platform/external/libxml2/ +#, maybe it is a good idea to take it from there instead of mainstrem +libxml2/Makefile: libxml2.src.stamp + cd libxml2 && \ + CC="$(CC)" LD="$(LD)" AR="$(AR)" AS="$(AS)" RANLIB=$(RANLIB) STRIP="$(STRIP)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \ + ./configure \ + --enable-static \ + --disable-shared \ + --without-lzma \ + --without-zlib \ + --host=$(HOST) \ + --prefix=$(LOCAL) + +libxml2/.libs/libxml2.a: libxml2/Makefile + $(MAKE) -C libxml2 + +$(LOCAL)/lib/libxml2.a: libxml2/.libs/libxml2.a + $(MAKE) -C libxml2 DESTDIR=$(DESTDIR) prefix=$(prefix) install + +libxml2-build: libxml2/.libs/libxml2.a + +libxml2-install: $(LOCAL)/lib/libxml2.a #------------------------------------------------------------------------------# # Sequoia-ffi CARGO_TARGET_DIR=$(EXTERNAL_ROOT)/../build diff --git a/android/external/common/Makefile b/android/external/common/Makefile index ad3637b..f22652e 100644 --- a/android/external/common/Makefile +++ b/android/external/common/Makefile @@ -35,6 +35,7 @@ boost.src.stamp:../downloads/boost-for-android.tar.gz boost.stamp: boost.src.stamp + mkdir -p $(LOCAL) cd boost; NCPU=$(NCPU) bash ./build-android.sh $(ANDROID_NDK) \ --boost=$(BOOST_VERSION) \ --layout=system \ diff --git a/android/external/downloads/Makefile b/android/external/downloads/Makefile index 4e621ed..d227d39 100644 --- a/android/external/downloads/Makefile +++ b/android/external/downloads/Makefile @@ -14,7 +14,7 @@ include ../Makefile.conf # Build parameters all: download-iconv download-uuid download-sequoia-deps download-etpan download-sequoia download-boost \ - download-cryptopp download-archive + download-cryptopp download-archive download-xml2 download-iconv: libiconv-1.15.tar.gz @@ -32,6 +32,9 @@ download-boost: boost-for-android.tar.gz download-cryptopp: cryptopp.tar.gz download-archive: libarchive-$(LIB_ARCHIVE_VERSION).tar.gz + +download-xml2: libxml2-$(LIB_XML_VERSION).tar.xz + # Download source and patch it libiconv-1.15.tar.gz: wget https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.15.tar.gz @@ -56,6 +59,10 @@ libarchive-$(LIB_ARCHIVE_VERSION).tar.gz: wget -nc https://libarchive.org/downloads/libarchive-$(LIB_ARCHIVE_VERSION).tar.gz md5sum -c libarchive-$(LIB_ARCHIVE_VERSION).tar.gz.md5 +libxml2-$(LIB_XML_VERSION).tar.xz: + wget -nc https://download.gnome.org/sources/libxml2/2.10/libxml2-$(LIB_XML_VERSION).tar.xz + md5sum -c libxml2-$(LIB_XML_VERSION).tar.xz.md5 + #------------------------------------------------------------------------------# # Clone update and archive external projects GIT repos diff --git a/android/external/downloads/libarchive-3.6.1.tar.gz.md5 b/android/external/downloads/libarchive-3.6.1.tar.gz.md5 new file mode 100644 index 0000000..e33eb80 --- /dev/null +++ b/android/external/downloads/libarchive-3.6.1.tar.gz.md5 @@ -0,0 +1 @@ +802a56ef9eaa0b8776296ba78a6d0c2c libarchive-3.6.1.tar.gz diff --git a/android/external/downloads/libxml2-2.10.0.tar.xz.md5 b/android/external/downloads/libxml2-2.10.0.tar.xz.md5 new file mode 100644 index 0000000..6f30278 --- /dev/null +++ b/android/external/downloads/libxml2-2.10.0.tar.xz.md5 @@ -0,0 +1 @@ +54fdcf2404eb5c1ca59ffc82b2edff78 libxml2-2.10.0.tar.xz diff --git a/android/external/x86/Makefile b/android/external/x86/Makefile index 1e99f9f..fc8eb5c 100644 --- a/android/external/x86/Makefile +++ b/android/external/x86/Makefile @@ -17,7 +17,7 @@ APP_ABI ?= x86 all: build -build: showsetup uuid-install sequoia-ffi-install libetpan-build cryptopp-install +build: showsetup uuid-install sequoia-ffi-install libetpan-build cryptopp-install libarchive-install #------------------------------------------------------------------------------# # Manage paths for PREFIX, DESTDIR, LOCAL and PATH @@ -209,6 +209,7 @@ openssl/libssl.so: | openssl/Makefile PATH="$(ANDROID_NDK_HOME)/bin:$(PATH)" $(MAKE) -C openssl $(LOCAL)/lib/libssl.so: openssl/libssl.so + mkdir -p $(LOCAL) $(MAKE) -C openssl install ls -l $(LOCAL)/lib @@ -293,8 +294,80 @@ nettle-install: $(LOCAL)/lib/libnettle.so #------------------------------------------------------------------------------# -# Sequoia-ffi +# LibArchive + +libarchive.src.stamp: ../downloads/libarchive-$(LIB_ARCHIVE_VERSION).tar.gz + tar xvf $< + mv libarchive-$(LIB_ARCHIVE_VERSION) libarchive + touch $@ + +libarchive-src: libarchive.src.stamp + +libarchive-clean: + rm -rf libarchive + rm -rf libarchive.src.stamp + +libarchive/Makefile: libarchive.src.stamp libarchive-install + cd libarchive && \ + CC="$(CC)" LD="$(LD)" AR="$(AR)" AS="$(AS)" RANLIB=$(RANLIB) STRIP="$(STRIP)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \ + ./configure \ + --with-lib-path=$(LOCAL)/lib \ + --with-include-path=$(LOCAL)/include \ + --disable-documentation \ + --disable-bsdtar \ + --disable-bsdcpio \ + --host=$(HOST) \ + --prefix=$(LOCAL) + +libarchive/libarchive.so: libarchive/Makefile + $(MAKE) -C libarchive + +$(LOCAL)/lib/libarchive.so: libarchive/libarchive.so + $(MAKE) -C libarchive DESTDIR=$(DESTDIR) prefix=$(prefix) install + +libarchive-build: libarchive/libarchive.so + +libarchive-install: $(LOCAL)/lib/libarchive.so +#------------------------------------------------------------------------------# +# libxml2 + + +libxml2.src.stamp: ../downloads/libxml2-$(LIB_XML_VERSION).tar.xz + tar xvf $< + mv libxml2-$(LIB_XML_VERSION) libxml2 + touch $@ + +libxml2-src: libxml2.src.stamp + +libxml2-clean: + rm -rf libxml2 + rm -rf libxml2.src.stamp + +#There is a libxml2 version on the AOSP source code: https://android.googlesource.com/platform/external/libxml2/ +#, maybe it is a good idea to take it from there instead of mainstrem +libxml2/Makefile: libxml2.src.stamp + cd libxml2 && \ + CC="$(CC)" LD="$(LD)" AR="$(AR)" AS="$(AS)" RANLIB=$(RANLIB) STRIP="$(STRIP)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \ + ./configure \ + --enable-static \ + --disable-shared \ + --without-lzma \ + --without-zlib \ + --host=$(HOST) \ + --prefix=$(LOCAL) + +libxml2/.libs/libxml2.a: libxml2/Makefile + $(MAKE) -C libxml2 + +$(LOCAL)/lib/libxml2.a: libxml2/.libs/libxml2.a + $(MAKE) -C libxml2 DESTDIR=$(DESTDIR) prefix=$(prefix) install + +libxml2-build: libxml2/.libs/libxml2.a + +libxml2-install: $(LOCAL)/lib/libxml2.a +#------------------------------------------------------------------------------# +# Sequoia-ffi CARGO_TARGET_DIR=$(EXTERNAL_ROOT)/../build/ sequoia.src.stamp: ../downloads/sequoia.tar.gz diff --git a/android/external/x86_64/Makefile b/android/external/x86_64/Makefile index f43904d..bcb990b 100644 --- a/android/external/x86_64/Makefile +++ b/android/external/x86_64/Makefile @@ -17,7 +17,7 @@ APP_ABI ?= x86_64 all: build -build: showsetup uuid-install sequoia-ffi-install libetpan-build cryptopp-install +build: showsetup uuid-install sequoia-ffi-install libetpan-build cryptopp-install libarchive-install #------------------------------------------------------------------------------# # Manage paths for PREFIX, DESTDIR, LOCAL and PATH @@ -209,6 +209,7 @@ openssl/libssl.so: | openssl/Makefile PATH="$(ANDROID_NDK_HOME)/bin:$(PATH)" $(MAKE) -C openssl $(LOCAL)/lib/libssl.so: openssl/libssl.so + mkdir -p $(LOCAL) $(MAKE) -C openssl install ls -l $(LOCAL)/lib @@ -292,6 +293,79 @@ nettle-build: nettle/libnettle.so nettle-install: $(LOCAL)/lib/libnettle.so +#------------------------------------------------------------------------------# +# LibArchive + +libarchive.src.stamp: ../downloads/libarchive-$(LIB_ARCHIVE_VERSION).tar.gz + tar xvf $< + mv libarchive-$(LIB_ARCHIVE_VERSION) libarchive + touch $@ + +libarchive-src: libarchive.src.stamp + +libarchive-clean: + rm -rf libarchive + rm -rf libarchive.src.stamp + +libarchive/Makefile: libarchive.src.stamp libarchive-install + cd libarchive && \ + CC="$(CC)" LD="$(LD)" AR="$(AR)" AS="$(AS)" RANLIB=$(RANLIB) STRIP="$(STRIP)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \ + ./configure \ + --with-lib-path=$(LOCAL)/lib \ + --with-include-path=$(LOCAL)/include \ + --disable-documentation \ + --disable-bsdtar \ + --disable-bsdcpio \ + --host=$(HOST) \ + --prefix=$(LOCAL) + +libarchive/libarchive.so: libarchive/Makefile + $(MAKE) -C libarchive + +$(LOCAL)/lib/libarchive.so: libarchive/libarchive.so + $(MAKE) -C libarchive DESTDIR=$(DESTDIR) prefix=$(prefix) install + +libarchive-build: libarchive/libarchive.so + +libarchive-install: $(LOCAL)/lib/libarchive.so + +#------------------------------------------------------------------------------# +# libxml2 + + +libxml2.src.stamp: ../downloads/libxml2-$(LIB_XML_VERSION).tar.xz + tar xvf $< + mv libxml2-$(LIB_XML_VERSION) libxml2 + touch $@ + +libxml2-src: libxml2.src.stamp + +libxml2-clean: + rm -rf libxml2 + rm -rf libxml2.src.stamp + +#There is a libxml2 version on the AOSP source code: https://android.googlesource.com/platform/external/libxml2/ +#, maybe it is a good idea to take it from there instead of mainstrem +libxml2/Makefile: libxml2.src.stamp + cd libxml2 && \ + CC="$(CC)" LD="$(LD)" AR="$(AR)" AS="$(AS)" RANLIB=$(RANLIB) STRIP="$(STRIP)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \ + ./configure \ + --enable-static \ + --disable-shared \ + --without-lzma \ + --without-zlib \ + --host=$(HOST) \ + --prefix=$(LOCAL) + +libxml2/.libs/libxml2.a: libxml2/Makefile + $(MAKE) -C libxml2 + +$(LOCAL)/lib/libxml2.a: libxml2/.libs/libxml2.a + $(MAKE) -C libxml2 DESTDIR=$(DESTDIR) prefix=$(prefix) install + +libxml2-build: libxml2/.libs/libxml2.a + +libxml2-install: $(LOCAL)/lib/libxml2.a #------------------------------------------------------------------------------# # Sequoia-ffi diff --git a/android/jni/Android.mk b/android/jni/Android.mk index e854158..55dd737 100644 --- a/android/jni/Android.mk +++ b/android/jni/Android.mk @@ -71,13 +71,13 @@ $(shell sh $(ENGINE_PATH)/build-android/takeOutHeaderFiles.sh $(ENGINE_PATH)) include $(CLEAR_VARS) LOCAL_MODULE := pEpJNI LOCAL_SHARED_LIBRARIES := libnettle libhogweed libgmp libcryptopp -LOCAL_STATIC_LIBRARIES := pEpEngine libetpan libiconv libuuid pEpAdapter libsequoia_openpgp_ffi +LOCAL_STATIC_LIBRARIES := pEpEngine libetpan libiconv libuuid pEpAdapter libsequoia_openpgp_ffi downloadclient signedpkg LOCAL_STATIC_LIBRARIES += libssl libcrypto libboost_system libboost_regex libboost_iostreams LOCAL_CPPFLAGS += -fexceptions LOCAL_CPPFLAGS += -frtti -LOCAL_CPP_FEATURES += exceptions +LOCAL_CPP_FEATURES += exceptiovns LOCAL_CPPFLAGS += -std=c++17 -DANDROID_STL=c++_shared -DHAVE_PTHREADS -DDISABLE_SYNC -fuse-ld=lld LOCAL_SRC_FILES := \ ../../src/cxx/foundation_pEp_jniadapter_AbstractEngine.cc \