]> sigrok.org Git - sigrok-util.git/commitdiff
sigrok-cross-android: Make Python work in PulseView, and reenable SRD
authorMarcus Comstedt <redacted>
Sun, 27 Apr 2014 07:58:24 +0000 (09:58 +0200)
committerUwe Hermann <redacted>
Mon, 25 Aug 2014 20:38:43 +0000 (22:38 +0200)
cross-compile/android/pulseview-cpp.patch
cross-compile/android/pulseview-java.patch
cross-compile/android/sigrok-cross-android

index 496a3dd280c2e35ee315d05490a4533d0a556282..14057048f9db9d3aceb37dc7b7ebf7f4c662fe0f 100644 (file)
@@ -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 <libsigrokdecode/libsigrokdecode.h> /* First, so we avoid a _POSIX_C_SOURCE warning. */
++#ifdef ANDROID
++#include <jni.h>
++#endif
+ #endif
+ #include <stdint.h>
+@@ -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; i<envn; i+=2) {
++              jstring key = (jstring)env->GetObjectArrayElement(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,
index 993f8a3c84b6fa075608e9c69b2efd4e80a6ff39..56956141f32cdfc3085e00cfd6300df067e7f336 100644 (file)
@@ -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",
++      };
++    }
++}
index 84a303ade85b24fd9fb6c2904ffa89c82350faab..130afda5494bad44ef70c4f5b194e058f700afd7 100755 (executable)
@@ -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