Browse Source

Added android build, as android library

feature/update-test-suite
Edouard Tisserant 7 years ago
parent
commit
6d07135966
9 changed files with 228 additions and 7 deletions
  1. +2
    -0
      android/AndroidManifest.xml
  2. +109
    -0
      android/build.gradle
  3. +86
    -0
      android/jni/Android.mk
  4. +1
    -0
      android/jni/Application.mk
  5. +8
    -0
      android/local.properties
  6. +16
    -2
      src/Makefile
  7. +3
    -3
      src/Makefile.conf
  8. +2
    -1
      src/jniutils.cc
  9. +1
    -1
      src/types_c.ysl2

+ 2
- 0
android/AndroidManifest.xml View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="org.pEp.jniadapter" />

+ 109
- 0
android/build.gradle View File

@ -0,0 +1,109 @@
// Android pEp JNI adapter Aar gradle build script
import org.apache.tools.ant.taskdefs.condition.Os
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
}
}
apply plugin: 'com.android.library'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
// where to find generated Java source
java.srcDirs = ['../src']
// disable automatic ndk-build call, which ignore our Android.mk
jni.srcDirs = []
jniLibs.srcDir 'src/main/libs'
}
}
lintOptions {
abortOnError false
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
// call source generation makefile target
task genSources(type:Exec) {
workingDir '../src'
commandLine 'make', 'gensource'
}
// unzip some of the dependencies
task unzipDeps(type: Copy) {
from zipTree(file('../../pEpEngine/android/pEpEngine-android-1.zip'))
from zipTree(file('../../libetpan/build-android/libetpan-android-1.zip'))
from zipTree(file('../../libetpan/build-android/dependencies/openssl/openssl-android-1.zip'))
from zipTree(file('../../libetpan/build-android/dependencies/cyrus-sasl/cyrus-sasl-android-1.zip'))
into file("${buildDir}")
}
// call regular ndk-build(.cmd) script from app directory
task jniBuild(type: Exec) {
commandLine getNdkBuildCmd(), 'V=1'
}
jniBuild.dependsOn genSources
jniBuild.dependsOn unzipDeps
// Ensure this is done before java build
tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn jniBuild
}
task cleanNative(type: Exec) {
commandLine getNdkBuildCmd(), 'clean'
}
clean.dependsOn cleanNative
}
def getNdkDir() {
if (System.env.ANDROID_NDK_ROOT != null)
return System.env.ANDROID_NDK_ROOT
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
def ndkdir = properties.getProperty('ndk.dir', null)
if (ndkdir == null)
throw new GradleException("NDK location not found. Define location with ndk.dir in the local.properties file or with an ANDROID_NDK_ROOT environment variable.")
return ndkdir
}
def getNdkBuildCmd() {
def ndkbuild = getNdkDir() + "/ndk-build"
if (Os.isFamily(Os.FAMILY_WINDOWS))
ndkbuild += ".cmd"
return ndkbuild
}

+ 86
- 0
android/jni/Android.mk View File

@ -0,0 +1,86 @@
LOCAL_PATH:= $(call my-dir)
GPGEXT := ../../../gnupg-for-android/external
GPGROOT := data/data/info.guardianproject.gpg/app_opt
GPGBUILD := $(GPGEXT)/$(GPGROOT)
include $(CLEAR_VARS)
LOCAL_MODULE := libassuan
LOCAL_SRC_FILES := $(GPGBUILD)/lib/libassuan.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libcurl
LOCAL_SRC_FILES := $(GPGBUILD)/lib/libcurl.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libgcrypt
LOCAL_SRC_FILES := $(GPGBUILD)/lib/libgcrypt.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libgpg-error
LOCAL_SRC_FILES := $(GPGBUILD)/lib/libgpg-error.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libgpgme
LOCAL_SRC_FILES := $(GPGBUILD)/lib/libgpgme.so
LOCAL_EXPORT_C_INCLUDES := $(GPGEXT)/$(GPGROOT)/include $(GPGEXT)/gpgme/src
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libksba
LOCAL_SRC_FILES := $(GPGBUILD)/lib/libksba.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libnpth
LOCAL_SRC_FILES := $(GPGBUILD)/lib/libnpth.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := openssl
LOCAL_SRC_FILES := ../build/openssl-android-1/libs/$(TARGET_ARCH_ABI)/libcrypto.a
#\
# ../build/openssl-android-1/libs/$(TARGET_ARCH_ABI)/libssl.a
LOCAL_EXPORT_C_INCLUDES := build/openssl-android-1/include
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := cyrus-sasl
LOCAL_SRC_FILES := ../build/cyrus-sasl-android-1/libs/$(TARGET_ARCH_ABI)/libsasl2.a
LOCAL_EXPORT_C_INCLUDES := build/cyrus-sasl-android-1/include
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libetpan
LOCAL_SRC_FILES := ../build/libetpan-android-1/libs/$(TARGET_ARCH_ABI)/libetpan.a
LOCAL_EXPORT_C_INCLUDES := build/libetpan-android-1/include
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := pEpEngine
LOCAL_SRC_FILES := ../build/pEpEngine-android-1/libs/$(TARGET_ARCH_ABI)/libpEpEngine.a
LOCAL_EXPORT_C_INCLUDES := build/pEpEngine-android-1/include
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := pEpJNIAdapter
LOCAL_SHARED_LIBRARIES := libgpgme
LOCAL_STATIC_LIBRARIES := openssl cyrus-sasl libetpan pEpEngine
LOCAL_CPP_FEATURES += exceptions
LOCAL_SRC_FILES := \
../../src/org_pEp_jniadapter_Engine.cc \
../../src/org_pEp_jniadapter_Message.cc \
../../src/throw_pEp_exception.cc \
../../src/jniutils.cc
LOCAL_C_INCLUDES := ../src
include $(BUILD_SHARED_LIBRARY)

+ 1
- 0
android/jni/Application.mk View File

@ -0,0 +1 @@
APP_STL := stlport_static

+ 8
- 0
android/local.properties View File

@ -0,0 +1,8 @@
## This file must *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
#
# Location of the SDK. This is only used by Gradle.
#
#Wed Apr 15 10:58:28 EDT 2015
sdk.dir=/home/pepdev/Android/Sdk
ndk.dir=/home/pepdev/Android/android-ndk-r10d

+ 16
- 2
src/Makefile View File

@ -1,11 +1,25 @@
LIBRARY=libpEpJNI.a
JAR=jniadapter.jar
include Makefile.conf
all: $(JAR) $(LIBRARY)
$(JAR): org/pEp/jniadapter/pEpException.java org/pEp/jniadapter/AbstractEngine.java org/pEp/jniadapter/Message.java org/pEp/jniadapter/Engine.java
JAVA_SOURCES=org/pEp/jniadapter/pEpException.java \
org/pEp/jniadapter/AbstractEngine.java \
org/pEp/jniadapter/Message.java \
org/pEp/jniadapter/Engine.java
C_SOURCES=org_pEp_jniadapter_Engine.cc \
org_pEp_jniadapter_Engine.h \
org_pEp_jniadapter_Message.cc \
org_pEp_jniadapter_Message.h \
throw_pEp_exception.cc \
throw_pEp_exception.hh \
org_pEp_jniadapter_AbstractEngine.h
gensource: $(JAVA_SOURCES) $(C_SOURCES)
$(JAR): $(JAVA_SOURCES)
javac org/pEp/jniadapter/*.java
jar cf $@ org/pEp/jniadapter/*.class


+ 3
- 3
src/Makefile.conf View File

@ -1,3 +1,3 @@
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_11.jdk/Contents/Home
CXXFLAGS=-I$(JAVA_HOME)/include -I/opt/local/include -I$(JAVA_HOME)/include/darwin -I$(HOME)/include
CLASSPATH=.:$(HOME)/k-9/src
JAVA_HOME=$(readlink -f /usr/bin/javac | sed "s:/bin/javac::")
CXXFLAGS=-I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux -I$(HOME)/include
CLASSPATH=.:$(HOME)/src/k-9/k9mail/src

+ 2
- 1
src/jniutils.cc View File

@ -3,6 +3,7 @@
#include <stdexcept>
#include <typeinfo>
#include <assert.h>
#include <string>
namespace pEp {
namespace JNIAdapter {
@ -30,7 +31,7 @@ namespace pEp {
jclass ex = env->FindClass("java/lang/NoSuchFieldError");
assert(ex);
env->ThrowNew(ex, fieldname);
throw std::invalid_argument(fieldname);
throw std::invalid_argument(std::string(fieldname));
}
return field;


+ 1
- 1
src/types_c.ysl2 View File

@ -12,7 +12,7 @@ function "toC" {
when "$type='EncFormat'" > PEP_enc_format
when "$type='bloblist'" > bloblist_t
when "$type='stringpairlist'" > stringpair_list_t
when "$type='direction'" > PEP_direction
when "$type='direction'" > PEP_msg_direction
otherwise value "$type";
}


Loading…
Cancel
Save