From c3b4363d8a031754c246e96e244798366261042e Mon Sep 17 00:00:00 2001 From: Sascha Bacardit Date: Tue, 14 Feb 2023 11:20:30 +0100 Subject: [PATCH] Updated android build script Makefiles for android need to point towards backend, not old sequoia with all that implies, such as changing .mk, makefiles and includes. Added libCxx11 to the task list with the same logic as libPEpTransport as they work the same. Added header link to identity_api.cc this is purely for the sake of android studio and not required, but android studio complains about missing headers without it. Updated Engine_version_code, will move it to a gradle variable later. Todo: Investigate why JNI dislikes using identity without a global variable during handshakes. --- android/build.gradle | 12 ++++++++++-- android/external/MakefileTemplate | 2 +- android/jni/Android.mk | 2 -- .../foundation/pEp/jniadapter/AndroidHelper.java | 15 +++++++++------ src/cxx/identity_api.cc | 1 + 5 files changed, 21 insertions(+), 11 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index 2994f49..3a5e9e4 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -2,6 +2,7 @@ def pEpEngineSrc = hasProperty('pEpEngineSrc') ? pEpEngineSrc : "../../pEpEngine" def libpEpTransportSrc = hasProperty('libpEpTransportSrc') ? libpEpTransportSrc : "../../libpEpTransport" +def libCxx11Src = hasProperty('libCxx11Src') ? libCxx11Src : "../../libpEpCxx11" def buildAutomatic = hasProperty('buildAutomatic') ? buildAutomatic : "true" //CHeck M1 answers the correct thing off .avaialableprocessors here //def threadsToUse = hasProperty('threadsToUse') ? @@ -34,7 +35,6 @@ apply plugin: 'com.android.library' android { compileSdkVersion 31 - defaultConfig { minSdkVersion 21 targetSdkVersion 31 @@ -96,9 +96,13 @@ android { path 'jni/Android.mk' } } + task genlibCxx11Sources(type:Exec) { + workingDir "${libCxx11Src}" + commandLine 'make', "-j${threadsToUse}", 'install' + } // call source generation makefile target - task genSources(type:Exec, dependsOn: 'genpEpEngineAsn1Sources') { + task genSources(type:Exec, dependsOn: ['genlibCxx11Sources', 'genpEpEngineAsn1Sources']) { workingDir '../src' commandLine 'make', 'lib-java' } @@ -162,6 +166,10 @@ android { into 'assets' } ndkVersion '25.1.8937393' + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } if(buildAutomatic == "true") { buildpEpEngineSystemDB.dependsOn(buildExternal) diff --git a/android/external/MakefileTemplate b/android/external/MakefileTemplate index 560f436..42e22b5 100644 --- a/android/external/MakefileTemplate +++ b/android/external/MakefileTemplate @@ -42,7 +42,7 @@ LDFLAGS += $(MYLDFLAGS) # GNU Tools trickery # point pkg-config to the .pc files generated from these builds -export PKG_CONFIG_PATH=$(LOCAL)/lib/pkgconfig +export PKG_CONFIG_PATH=$(LOCAL)/lib/src/pEpEngineSequoiaBackend/target/release # workaround for cross-compiling bug in autoconf export ac_cv_func_malloc_0_nonnull=yes diff --git a/android/jni/Android.mk b/android/jni/Android.mk index b4077e3..6ba5fb3 100644 --- a/android/jni/Android.mk +++ b/android/jni/Android.mk @@ -59,10 +59,8 @@ LOCAL_SRC_FILES := \ ../../src/cxx/jniutils.cc LOCAL_C_INCLUDES += $(GPGBUILD)/$(TARGET_ARCH_ABI)/include -#LOCAL_C_INCLUDES += $(ENGINE_PATH)/build-android/include/pEp LOCAL_C_INCLUDES += $(LIB_PEP_ADAPTER_PATH)/build-android/include $(SRC_PATH)/libpEpAdapter LOCAL_C_INCLUDES += $(LIB_PEP_CXX11_PATH)/build-android/include $(SRC_PATH)/libpEpCxx11 -#LOCAL_C_INCLUDES += $(LIB_PEP_TRANSPORT_PATH)/build-android/include $(SRC_PATH)/libpEpTransport LOCAL_C_INCLUDES += $(ENGINE_PATH)/asn.1 LOCAL_LDFLAGS = -Wl,--allow-multiple-definition diff --git a/android/src/foundation/pEp/jniadapter/AndroidHelper.java b/android/src/foundation/pEp/jniadapter/AndroidHelper.java index e746075..cba616f 100644 --- a/android/src/foundation/pEp/jniadapter/AndroidHelper.java +++ b/android/src/foundation/pEp/jniadapter/AndroidHelper.java @@ -31,7 +31,8 @@ public class AndroidHelper { // TODO : Increment when needed. // TODO : Check if this version tracking is really needed and Automatize it - public static String ENGINE_VERSION_CODE = "Release_2.1.56"; + // TODO : This could be automatically generated as the version is tied to git tag && other files in the JNI part. + public static String ENGINE_VERSION_CODE = "v3.2.0-RC3"; private static File shareDir; @@ -141,12 +142,14 @@ public class AndroidHelper { byte[] pubringBytes = new byte[(int) pubring.length()]; pubring.readFully(pubringBytes); - Engine pEpEngine = new Engine(); - pEpEngine.importKey(pubringBytes); + Log.d("boss", "init engine objc at "+Thread.currentThread().getId()); + try (Engine pEpEngine = new Engine()) { + pEpEngine.importKey(pubringBytes); - byte[] secringBytes = new byte[(int) secring.length()]; - secring.readFully(secringBytes); - pEpEngine.importKey(secringBytes); + byte[] secringBytes = new byte[(int) secring.length()]; + secring.readFully(secringBytes); + pEpEngine.importKey(secringBytes); + } //TODO: MARK KEYRING AS IMPORTED diff --git a/src/cxx/identity_api.cc b/src/cxx/identity_api.cc index c9b850f..cdad04b 100644 --- a/src/cxx/identity_api.cc +++ b/src/cxx/identity_api.cc @@ -1,5 +1,6 @@ #include #include +#include "foundation_pEp_jniadapter_Identity.h" #include "jniutils.hh"