From: Marcus Comstedt Date: Sat, 12 Apr 2014 12:01:35 +0000 (+0200) Subject: sigrok-cross-android: PulseView now starts X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=aef0361e598870a8e2a16ff568efbae3e1ad20b9;p=sigrok-util.git sigrok-cross-android: PulseView now starts SRD has been temporarily disabled, since there was a crash in it. --- diff --git a/cross-compile/android/fix-libraries.sh b/cross-compile/android/fix-libraries.sh new file mode 100755 index 0000000..8d14940 --- /dev/null +++ b/cross-compile/android/fix-libraries.sh @@ -0,0 +1,71 @@ +#!/bin/sh + +set -e +tmpdir=/tmp/fixlib$$ +trap 'rm -rf "$tmpdir"' 0 1 2 3 15 +mkdir -p "$tmpdir" + +if [ $# -lt 3 ]; then + echo >&2 "Usage: $0 srclib destlib library ..." + exit 1 +fi + +: ${READELF=readelf} + +srclib="$1" +destlib="$2" +shift +shift +rm -f "$tmpdir"/todo +touch "$tmpdir"/todo +for lib; do + echo "$lib" >> "$tmpdir"/todo +done + +process() +{ + libname="$1" + libfile="$destlib"/"$libname" + if [ ! -f "$libfile" ]; then + echo >&2 "$libfile not found" + exit 1 + fi + "$READELF" -d "$libfile" | awk '$1=="0x00000001" {print $NF}' | tr -d '][' | grep '\.so\.' | sort >> "$tmpdir"/worklist +} + +install() +{ + libname="$1" + libfile=`echo "$libname" | sed -e 's/\.so\..*/.so/'` + cp "$srclib"/"$libname" "$destlib"/"$libfile" + echo "$libfile" >> "$tmpdir"/worklist + for deplib in `"$READELF" -d "$destlib"/"$libfile" | awk '$1=="0x00000001" {print $NF}' | tr -d '][' | grep '\.so\.' | sort`; do + echo "$deplib $libname" >> "$tmpdir"/liblist + done +} + +rm -f "$tmpdir"/liblist +touch "$tmpdir"/liblist +sort "$tmpdir"/todo > "$tmpdir"/processed +while [ -s "$tmpdir"/todo ]; do + rm -f "$tmpdir"/worklist + touch "$tmpdir"/worklist + cat "$tmpdir"/todo | while read lib; do + if [ ! -z "$lib" ]; then + process "$lib" + fi + done + sort "$tmpdir"/worklist | uniq > "$tmpdir"/todo.tmp + comm -13 "$tmpdir"/processed "$tmpdir"/todo.tmp > "$tmpdir"/todo + sort -m "$tmpdir"/processed "$tmpdir"/todo | uniq > "$tmpdir"/processed.tmp + mv "$tmpdir"/processed.tmp "$tmpdir"/processed + rm -f "$tmpdir"/worklist + touch "$tmpdir"/worklist + cat "$tmpdir"/todo | while read lib; do + if [ ! -z "$lib" ]; then + install "$lib" + fi + done + mv "$tmpdir"/worklist "$tmpdir"/todo +done +tsort "$tmpdir"/liblist diff --git a/cross-compile/android/pulseview-cpp.patch b/cross-compile/android/pulseview-cpp.patch new file mode 100644 index 0000000..496a3dd --- /dev/null +++ b/cross-compile/android/pulseview-cpp.patch @@ -0,0 +1,39 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 11767a6..b8eed96 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -317,12 +317,21 @@ if(WIN32) + list(APPEND PULSEVIEW_LINK_LIBS "-lqsvg") + endif() + ++if(ANDROID) ++add_library(${PROJECT_NAME} SHARED ++ ${pulseview_SOURCES} ++ ${pulseview_HEADERS_MOC} ++ ${pulseview_FORMS_HEADERS} ++ ${pulseview_RESOURCES_RCC} ++) ++else() + add_executable(${PROJECT_NAME} + ${pulseview_SOURCES} + ${pulseview_HEADERS_MOC} + ${pulseview_FORMS_HEADERS} + ${pulseview_RESOURCES_RCC} + ) ++endif() + + target_link_libraries(${PROJECT_NAME} ${PULSEVIEW_LINK_LIBS}) + +diff --git a/pv/view/decodetrace.cpp b/pv/view/decodetrace.cpp +index e4f0276..861d25b 100644 +--- a/pv/view/decodetrace.cpp ++++ b/pv/view/decodetrace.cpp +@@ -373,7 +373,7 @@ void DecodeTrace::draw_instant(const pv::data::decode::Annotation &a, QPainter & + { + const QString text = a.annotations().empty() ? + QString() : a.annotations().back(); +- const double w = min(p.boundingRect(QRectF(), 0, text).width(), ++ const double w = min((double)p.boundingRect(QRectF(), 0, text).width(), + 0.0) + h; + const QRectF rect(x - w / 2, y - h / 2, w, h); + diff --git a/cross-compile/android/pulseview-java.patch b/cross-compile/android/pulseview-java.patch new file mode 100644 index 0000000..993f8a3 --- /dev/null +++ b/cross-compile/android/pulseview-java.patch @@ -0,0 +1,118 @@ +diff --git a/java/AndroidManifest.xml b/java/AndroidManifest.xml +index 0564a8d..0356f33 100644 +--- a/java/AndroidManifest.xml ++++ b/java/AndroidManifest.xml +@@ -1,5 +1,5 @@ + +- ++ + + + +@@ -8,7 +8,7 @@ + + + +- ++ + + + +diff --git a/java/res/values/strings.xml b/java/res/values/strings.xml +index bd6928f..68f017e 100644 +--- a/java/res/values/strings.xml ++++ b/java/res/values/strings.xml +@@ -1,6 +1,6 @@ + + +- ++ PulseView + Can\'t find Ministro service.\nThe application can\'t start. + This application requires Ministro service. Would you like to install it? + Your application encountered a fatal error and cannot continue. +diff --git a/java/src/org/kde/necessitas/origo/QtActivity.java b/java/src/org/kde/necessitas/origo/QtActivity.java +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 + { + try + { ++ System.loadLibrary("gnustl_shared"); ++ org.sigrok.androidutils.LibWrangler.setupLibs( ++ getAssets().open("liblist.txt"), ++ new File(getApplicationInfo().nativeLibraryDir), ++ new File(getFilesDir(), "lib")); ++ + if (loaderParams.getInt(ERROR_CODE_KEY) != 0) + { // fatal error, show the error and quit + AlertDialog errorDialog = new AlertDialog.Builder(QtActivity.this).create(); +diff --git a/java/src/org/sigrok/androidutils/LibWrangler.java b/java/src/org/sigrok/androidutils/LibWrangler.java +new file mode 100644 +index 0000000..0c9effe +--- /dev/null ++++ b/java/src/org/sigrok/androidutils/LibWrangler.java +@@ -0,0 +1,63 @@ ++package org.sigrok.androidutils; ++ ++import java.io.InputStream; ++import java.io.InputStreamReader; ++import java.io.BufferedReader; ++import java.io.IOException; ++import java.io.File; ++ ++public final class LibWrangler ++{ ++ protected static String stripSoVersion(String s) ++ { ++ int p = s.lastIndexOf(".so."); ++ if (p >= 0) ++ s = s.substring(0, p+3); ++ return s; ++ } ++ ++ protected static void makeLink(File from, File to) ++ throws IOException ++ { ++ if (to.equals(from.getCanonicalFile())) { ++ // Symlink already correct ++ return; ++ } ++ from.delete(); ++ int rc; ++ Process proc = ++ Runtime.getRuntime().exec(new String[]{"ln", "-s", ++ to.getAbsolutePath(), ++ from.getAbsolutePath()}); ++ for(;;) { ++ try { ++ rc = proc.waitFor(); ++ break; ++ } catch(InterruptedException ie) { ++ } ++ } ++ if (rc != 0) ++ throw new IOException("Failed to create symlink "+from); ++ } ++ ++ public static void setupLibs(BufferedReader reader, File libDir1, File libDir2) ++ throws IOException ++ { ++ if (!libDir2.exists()) ++ libDir2.mkdir(); ++ ++ String libname; ++ while ((libname = reader.readLine()) != null) { ++ File shlib = new File(libDir2, libname); ++ makeLink(shlib, new File(libDir1, stripSoVersion(libname))); ++ System.load(shlib.getAbsolutePath()); ++ } ++ } ++ ++ public static void setupLibs(InputStream is, File libDir1, File libDir2) ++ throws IOException ++ { ++ setupLibs(new BufferedReader(new InputStreamReader(is, "US-ASCII")), ++ libDir1, libDir2); ++ } ++} diff --git a/cross-compile/android/sigrok-cross-android b/cross-compile/android/sigrok-cross-android index b845039..c31cb97 100755 --- a/cross-compile/android/sigrok-cross-android +++ b/cross-compile/android/sigrok-cross-android @@ -310,7 +310,16 @@ cd .. # PulseView $GIT_CLONE git://sigrok.org/pulseview cd pulseview -cmake $CM -DQT_QMAKE_EXECUTABLE=${PREFIX}/bin/qmake -DANDROID_STL_PATH=${ANDROID_NDK}/sources/cxx-stl . -make $PARALLEL VERBOSE=1 -make install -cd .. +patch -p1 < ../../pulseview-cpp.patch +cmake $CM -DQT_QMAKE_EXECUTABLE=${PREFIX}/bin/qmake -DANDROID_STL_PATH=${ANDROID_NDK}/sources/cxx-stl -DENABLE_DECODE=FALSE . +make $PARALLEL +cp -r "$PREFIX"/src/android/java . +cp -r libs java/ +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 ${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 +cd ../..