From: Marcus Comstedt Date: Sun, 27 Apr 2014 07:58:24 +0000 (+0200) Subject: sigrok-cross-android: Make Python work in PulseView, and reenable SRD X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=bdf42f4b4dc9c46b1f8c9852694b43b5e9d52f7f;p=sigrok-util.git sigrok-cross-android: Make Python work in PulseView, and reenable SRD --- diff --git a/cross-compile/android/pulseview-cpp.patch b/cross-compile/android/pulseview-cpp.patch index 496a3dd..1405704 100644 --- a/cross-compile/android/pulseview-cpp.patch +++ b/cross-compile/android/pulseview-cpp.patch @@ -37,3 +37,65 @@ index e4f0276..861d25b 100644 0.0) + h; const QRectF rect(x - w / 2, y - h / 2, w, h); +diff --git a/main.cpp b/main.cpp +index 2c6a59e..79627db 100644 +--- a/main.cpp 2014-04-26 23:40:24.253187700 +0200 ++++ b/main.cpp 2014-04-27 00:38:55.378353311 +0200 +@@ -20,6 +20,9 @@ + + #ifdef ENABLE_DECODE + #include /* First, so we avoid a _POSIX_C_SOURCE warning. */ ++#ifdef ANDROID ++#include ++#endif + #endif + + #include +@@ -45,6 +48,47 @@ + Q_IMPORT_PLUGIN(qsvg) + #endif + ++#if defined(ENABLE_DECODE) && defined(ANDROID) ++jint JNI_OnLoad(JavaVM *vm, void *reserved) ++{ ++ JNIEnv* env; ++ ++ (void)reserved; ++ ++ if (vm->GetEnv((void **)&env, JNI_VERSION_1_6) != JNI_OK) { ++ return -1; ++ } ++ ++ jclass envc = env->FindClass("org/sigrok/androidutils/Environment"); ++ jmethodID getEnv = env->GetStaticMethodID(envc, "getEnvironment", ++ "()[Ljava/lang/String;"); ++ jobjectArray envs = ++ (jobjectArray)env->CallStaticObjectMethod(envc, getEnv); ++ jsize i, envn = env->GetArrayLength(envs); ++ for (i=0; iGetObjectArrayElement(envs, i); ++ jstring value = (jstring)env->GetObjectArrayElement(envs, i+1); ++ const char *utfkey = env->GetStringUTFChars(key, 0); ++ const char *utfvalue = env->GetStringUTFChars(value, 0); ++ setenv(utfkey, utfvalue, 1); ++ env->ReleaseStringUTFChars(value, utfvalue); ++ env->ReleaseStringUTFChars(key, utfkey); ++ env->DeleteLocalRef(value); ++ env->DeleteLocalRef(key); ++ } ++ env->DeleteLocalRef(envs); ++ env->DeleteLocalRef(envc); ++ ++ return JNI_VERSION_1_6; ++} ++ ++void JNI_OnUnload(JavaVM *vm, void *reserved) ++{ ++ (void)vm; ++ (void)reserved; ++} ++#endif ++ + void usage() + { + fprintf(stdout, diff --git a/cross-compile/android/pulseview-java.patch b/cross-compile/android/pulseview-java.patch index 993f8a3..5695614 100644 --- a/cross-compile/android/pulseview-java.patch +++ b/cross-compile/android/pulseview-java.patch @@ -34,10 +34,12 @@ diff --git a/java/src/org/kde/necessitas/origo/QtActivity.java b/java/src/org/kd index 4ebf1f6..f4e3598 100644 --- a/java/src/org/kde/necessitas/origo/QtActivity.java +++ b/java/src/org/kde/necessitas/origo/QtActivity.java -@@ -108,6 +108,12 @@ public class QtActivity extends Activity +@@ -108,6 +108,14 @@ public class QtActivity extends Activity { try { ++ org.sigrok.androidutils.Environment.initEnvironment( ++ getApplicationInfo().sourceDir); + System.loadLibrary("gnustl_shared"); + org.sigrok.androidutils.LibWrangler.setupLibs( + getAssets().open("liblist.txt"), @@ -116,3 +118,30 @@ index 0000000..0c9effe + libDir1, libDir2); + } +} +diff --git a/java/src/org/sigrok/androidutils/Environment.java b/java/src/org/sigrok/androidutils/Environment.java +new file mode 100644 +index 0000000..0c9effe +--- /dev/null 2014-04-15 00:13:35.543030287 +0200 ++++ b/java/src/org/sigrok/androidutils/Environment.java 2014-04-27 00:09:23.073513663 +0200 +@@ -0,0 +1,21 @@ ++package org.sigrok.androidutils; ++ ++public final class Environment ++{ ++ static private String[] environment; ++ ++ public static String[] getEnvironment() ++ { ++ return environment; ++ } ++ ++ public static void initEnvironment(String apkFile) ++ { ++ environment = new String[] ++ { ++ "PYTHONHOME", ".", ++ "PYTHONPATH", apkFile+"/assets/python3.3", ++ "SIGROKDECODE_DIR", apkFile+"/assets/libsigrokdecode/decoders", ++ }; ++ } ++} diff --git a/cross-compile/android/sigrok-cross-android b/cross-compile/android/sigrok-cross-android index 84a303a..130afda 100755 --- a/cross-compile/android/sigrok-cross-android +++ b/cross-compile/android/sigrok-cross-android @@ -312,7 +312,7 @@ cd .. $GIT_CLONE git://sigrok.org/pulseview cd pulseview patch -p1 < ../../pulseview-cpp.patch -cmake $CM -DQT_QMAKE_EXECUTABLE=${PREFIX}/bin/qmake -DANDROID_STL_PATH=${ANDROID_NDK}/sources/cxx-stl -DENABLE_DECODE=FALSE . +cmake $CM -DQT_QMAKE_EXECUTABLE=${PREFIX}/bin/qmake -DANDROID_STL_PATH=${ANDROID_NDK}/sources/cxx-stl . make $PARALLEL cp -r "$PREFIX"/src/android/java . cp -r libs java/ @@ -320,6 +320,8 @@ cd java patch -p2 < ../../../pulseview-java.patch mkdir -p assets READELF=$TOOLCHAIN_TRIPLET-readelf ../../../fix-libraries.sh "$PREFIX/lib" libs/"$TARGET_ARCH" libpulseview.so > assets/liblist.txt +cp -r "$PREFIX"/lib/python3.3 assets/ +cp -r "$PREFIX"/share/libsigrokdecode assets/ cp ${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/${NDK_TOOLCHAIN_VERSION}/libs/${TARGET_ARCH}/libgnustl_shared.so libs/${TARGET_ARCH}/ "$ANDROID_TOOLS/android" update project -p . -t android-14 -n PulseView ant debug