sigrok-cross-android: Build boost and qt for PulseView
authorMarcus Comstedt <marcus@mc.pp.se>
Sat, 5 Apr 2014 14:18:17 +0000 (16:18 +0200)
committerUwe Hermann <uwe@hermann-uwe.de>
Mon, 25 Aug 2014 20:38:42 +0000 (22:38 +0200)
cross-compile/android/android-qt.patch [new file with mode: 0644]
cross-compile/android/boost.patch [new file with mode: 0644]
cross-compile/android/sigrok-cross-android

diff --git a/cross-compile/android/android-qt.patch b/cross-compile/android/android-qt.patch
new file mode 100644 (file)
index 0000000..33ac8b2
--- /dev/null
@@ -0,0 +1,61 @@
+diff --git a/android/androidconfigbuild.sh b/android/androidconfigbuild.sh
+index 12ad414..b78f907 100755
+--- a/android/androidconfigbuild.sh
++++ b/android/androidconfigbuild.sh
+@@ -281,7 +281,7 @@ then
+       $SRC_DIR_QT/configure -v -opensource -qpa -arch $ANDROID_ARCHITECTURE \
+               -no-phonon -freetype -fast -xplatform android-g++ \
+-              -host-arch i386 $PLATFORM -host-little-endian \
++              $PLATFORM \
+               -little-endian -no-qt3support -no-largefile \
+               -openssl -pch \
+               -nomake demos -no-multimedia -nomake examples -confirm-license \
+diff --git a/mkspecs/android-g++/qmake.conf b/mkspecs/android-g++/qmake.conf
+index db28cb6..bc8802f 100644
+--- a/mkspecs/android-g++/qmake.conf
++++ b/mkspecs/android-g++/qmake.conf
+@@ -74,8 +74,8 @@ ANDROID_PLATFORM_PATH  = $$ANDROID_PLATFORM_ROOT_PATH/usr
+ QMAKE_ANDROID_PLATFORM_INCDIR = $$NDK_ROOT/platforms/$$ANDROID_PLATFORM/arch-$$ANDROID_ARCHITECTURE/usr/include
+ QMAKE_ANDROID_PLATFORM_LIBDIR = $$NDK_ROOT/platforms/$$ANDROID_PLATFORM/arch-$$ANDROID_ARCHITECTURE/usr/lib
+-ANDROID_SOURCES_CXX_STL_LIBDIR = $$NDK_ROOT/sources/cxx-stl$$ANDROID_CXXSTL_SUFFIX/gnu-libstdc++/libs/$$ANDROID_TARGET_ARCH
+-ANDROID_SOURCES_CXX_STL_INCDIR = $$NDK_ROOT/sources/cxx-stl$$ANDROID_CXXSTL_SUFFIX/gnu-libstdc++/include $$ANDROID_SOURCES_CXX_STL_LIBDIR/include
++ANDROID_SOURCES_CXX_STL_LIBDIR = $$NDK_ROOT/sources/cxx-stl/gnu-libstdc++/$$NDK_TOOLCHAIN_VERSION/libs/$$ANDROID_TARGET_ARCH
++ANDROID_SOURCES_CXX_STL_INCDIR = $$NDK_ROOT/sources/cxx-stl/gnu-libstdc++/$$NDK_TOOLCHAIN_VERSION/include $$ANDROID_SOURCES_CXX_STL_LIBDIR/include
+ # modifications to g++.conf
+ QMAKE_CC                = $$NDK_TOOLCHAIN_PATH/bin/$$NDK_TOOLS_PREFIX-gcc
+@@ -159,7 +159,7 @@ QMAKE_LFLAGS_NOUNDEF    =  -Wl,--no-undefined
+ QMAKE_LFLAGS_RPATH      =  -Wl,-rpath=
+-QMAKE_LIBS              = -lstdc++ -lsupc++ -llog -lz -lm -ldl -lc -lgcc
++QMAKE_LIBS              = -lgnustl_shared -lstdc++ -lsupc++ -llog -lz -lm -ldl -lc -lgcc
+ QMAKE_LIBS_X11          =
+ QMAKE_LIBS_X11SM        =
+ QMAKE_LIBS_QT_THREAD    =
+diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp
+index 9309db1..1df9f06 100644
+--- a/src/tools/moc/moc.cpp
++++ b/src/tools/moc/moc.cpp
+@@ -525,12 +525,18 @@ void Moc::parse()
+             case NAMESPACE: {
+                 int rewind = index;
+                 if (test(IDENTIFIER)) {
++                  QByteArray name = lexem();
++                  if (index + 1 < symbols.size() && symbols.at(index).token == IDENTIFIER &&
++                      symbols.at(index).lexem() == "_GLIBCXX_VISIBILITY" &&
++                      symbols.at(index+1).token == LPAREN) {
++                      until(RPAREN);
++                  }
+                     if (test(EQ)) {
+                         // namespace Foo = Bar::Baz;
+                         until(SEMIC);
+                     } else if (!test(SEMIC)) {
+                         NamespaceDef def;
+-                        def.name = lexem();
++                        def.name = name;
+                         next(LBRACE);
+                         def.begin = index - 1;
+                         until(RBRACE);
diff --git a/cross-compile/android/boost.patch b/cross-compile/android/boost.patch
new file mode 100644 (file)
index 0000000..31a5872
--- /dev/null
@@ -0,0 +1,23 @@
+diff -urp boost_1_55_0.orig/tools/build/v2/tools/builtin.jam boost_1_55_0/tools/build/v2/tools/builtin.jam
+--- boost_1_55_0.orig/tools/build/v2/tools/builtin.jam 2014-04-04 20:31:24.240657506 +0200
++++ boost_1_55_0/tools/build/v2/tools/builtin.jam      2014-04-04 20:31:38.951319126 +0200
+@@ -41,7 +41,7 @@ import generate ;
+ .os-names = aix bsd cygwin darwin freebsd hpux iphone linux netbsd openbsd osf
+-    qnx qnxnto sgi solaris unix unixware windows
++    qnx qnxnto sgi solaris unix unixware windows android
+     elf  # Not actually an OS -- used for targeting bare metal where object
+          # format is ELF.  This catches both -elf and -eabi gcc targets and well
+          # as other compilers targeting ELF. It is not clear how often we need
+diff -urp boost_1_55_0.orig/tools/build/v2/tools/gcc.jam boost_1_55_0/tools/build/v2/tools/gcc.jam
+--- boost_1_55_0.orig/tools/build/v2/tools/gcc.jam     2014-04-04 20:22:10.431667807 +0200
++++ boost_1_55_0/tools/build/v2/tools/gcc.jam  2014-04-04 20:35:34.859039773 +0200
+@@ -1032,6 +1032,7 @@ rule setup-threading ( targets * : sourc
+             case *bsd    : option = -pthread ;  # There is no -lrt on BSD.
+             case sgi     : # gcc on IRIX does not support multi-threading.
+             case darwin  : # No threading options.
++            case android : # No threading options.
+             case *       : option = -pthread ; libs = rt ;
+         }
index 81dc357f2e3143b63fc03981097907f085b0a60d..ade75f7d7098b96bcc669aa389786f04ac868969 100755 (executable)
 
 set -e
 
+# The path where Android NDK is located.
+ANDROID_NDK=/usr/local/android-ndk-r9d
+
+# The path where Android SDK is located.
+ANDROID_SDK=/usr/local/android
+
 # The path where your Android toolchain directory is located.
 TOOLCHAIN=$HOME/android/android-arm-toolchain
 # TOOLCHAIN=$HOME/android/android-mipsel-toolchain
@@ -56,6 +62,8 @@ VER_LIBZIP=0.11.1
 VER_LIBFTDI1=1.1
 VER_LIBUSBX=1.0.17
 VER_PYTHON=3.3.3
+VER_BOOST=1.55.0
+VER_QT=n0.31
 
 SF_MIRROR=switch.dl.sourceforge.net
 
@@ -254,3 +262,47 @@ make $PARALLEL V=1
 make install
 cd ..
 
+
+# Check if we have kit to build PulseView
+
+if [ -z "$ANDROID_NDK" -o ! -d "$ANDROID_NDK" ]; then
+  echo "Android NDK not available, not building PulseView"
+  exit 0
+fi
+
+if [ -z "$ANDROID_SDK" -o ! -d "$ANDROID_SDK"/platforms/android-4 -o \
+     ! -d "$ANDROID_SDK"/platforms/android-7 -o \
+     ! -d "$ANDROID_SDK"/platforms/android-8 -o \
+     ! -d "$ANDROID_SDK"/platforms/android-14 ]; then
+  echo "Android SDK with platforms 4 7 8 14 not available, not building PulseView"
+  exit 0
+fi
+
+ANDROID_TOOLS=${ANDROID_SDK}/tools
+ANDROID_BUILD_TOOLS=${ANDROID_SDK}/build-tools/19.0.1
+
+if [ ! -e "$ANDROID_TOOLS/android" -o ! -e "$ANDROID_BUILD_TOOLS/dx" ]; then
+  echo "Essential Android build tools not available, not building PulseView"
+  exit 0
+fi
+
+NDK_TOOLCHAIN_VERSION=`${TOOLCHAIN_TRIPLET}-gcc --version | head -1 | sed -e 's/.* \([0-9]\+\.[0-9.]\+\)\( \|.*\)$/\1/'`
+NDK_HOST=`"$ANDROID_NDK/ndk-build" -p 2>/dev/null | awk '$1 == "HOST_TAG" { print $3 }'`
+
+
+# boost (needed for PulseView)
+$WGET http://$SF_MIRROR/project/boost/boost/$VER_BOOST/boost_${VER_BOOST//./_}.tar.bz2
+tar xfj boost_${VER_BOOST//./_}.tar.bz2
+cd boost_${VER_BOOST//./_}
+patch -p1 < ../../boost.patch
+./bootstrap.sh --with-toolset=gcc --with-libraries=filesystem,system,thread --without-icu
+echo "using gcc : $NDK_TOOLCHAIN_VERSION : \"${TOOLCHAIN_TRIPLET}-g++\" : <cxxflags>\"-I$PREFIX/include -I${ANDROID_NDK}/sources/cxx-stl/stlport/stlport\" <linkflags>\"-L$PREFIX/lib\" ;" > user-config.jam
+./b2 -q -d+2 --user-config=user-config.jam toolset=gcc variant=release link=shared threading=multi runtime-link=shared target-os=android --prefix=$PREFIX --layout=system install
+cd ..
+
+# qt (needed for PulseView)
+$GIT_CLONE -b $VER_QT git://anongit.kde.org/android-qt.git
+cd android-qt
+patch -p1 < ../../android-qt.patch
+ANDROID_SDK_PLATFORM_TOOLS_PATH=$ANDROID_BUILD_TOOLS ANDROID_SDK_TOOLS_PATH=$ANDROID_TOOLS ./android/androidconfigbuild.sh -n $ANDROID_NDK -a $TARGET_ARCH -l 14 -q 1 -d 1 -i $PREFIX -k 1 -o $NDK_HOST -v $NDK_TOOLCHAIN_VERSION
+cd ..