Skip to content

Instantly share code, notes, and snippets.

@RazZziel

RazZziel/.gitignore

Last active Feb 15, 2016
Embed
What would you like to do?
Update to Qt 5.4.0 and parametrize Qt version
rootfs_files_after.txt
rootfs_files_before.txt
libiconv-*.*
mariadb_client-*-src*
qtbase-opensource-src-*
openssl-*
#!/bin/bash
# Based on http://qt-project.org/wiki/Build_Qt5_mysql_plugin_for_Android
export ANDROID_NDK_ROOT="$HOME/Applications/android-ndk-r9/"
export QT_ROOT="$HOME/Qt/5.5/"
SR="$ANDROID_NDK_ROOT/platforms/android-9/arch-arm/"
BR="$ANDROID_NDK_ROOT/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86/bin/arm-linux-androideabi-"
here="$(dirname "$0")"
find "$SR" "$QT_ROOT" > "$here/rootfs_files_before.txt" || exit 1
checkChanges() {
find "$SR" "$QT_ROOT" > "$here/rootfs_files_after.txt" || exit 1
echo "Changes:"
diff -u "$here/rootfs_files_before.txt" "$here/rootfs_files_after.txt"
}
trap checkChanges EXIT
# OpenSSL
pkg=openssl-1.0.2e.tar.gz
dir=$(basename $pkg .tar.gz)
if [ ! -d $dir ]; then
wget -c http://www.openssl.org/source/$pkg
tar -xf $pkg || exit 1
fi
pushd $dir
RANLIB="$BR"ranlib CC="$BR"gcc ./Configure android-armv7 --prefix=$SR/usr
ANDROID_DEV=$SR/usr make #|| exit 1
ANDROID_DEV=$SR/usr make || exit 1
make install_sw || exit 1
popd
# libiconv
pkg=libiconv-1.14.tar.gz
dir=$(basename $pkg .tar.gz)
if [ ! -d $dir ]; then
wget -c http://ftp.gnu.org/pub/gnu/libiconv/$pkg
tar -xf $pkg || exit 1
fi
pushd $dir
STRIP="$BR"strip RANLIB="$BR"ranlib OBJDUMP="$BR"objdump AR="$BR"ar CC="$BR"gcc CFLAGS=--sysroot=$SR CPP="$BR"cpp CPPFLAGS=$CFLAGS ./configure --host=arm --prefix=$SR/usr --with-sysroot=$SR
make || exit 1
make install || exit 1
popd
# mariadbclient
version=2.0.0
pkg=mariadb_client-$version-src.tar.gz
url=https://downloads.mariadb.org/f/client-native-$version/src/$pkg
# FIXME: This one fails to build, linker errors
#version=2.1.0
#pkg=mariadb-connector-c-$version-src.tar.gz
#url=https://downloads.mariadb.org/f/connector-c-$version/source-tgz/$pkg
dir=$(basename $pkg .tar.gz)
if [ ! -d $dir ]; then
wget -c $url
tar -xf $pkg || exit 1
fi
pushd $dir
sed -i -e "s|ADD_SUBDIRECTORY(unittest/libmariadb)|#ADD_SUBDIRECTORY(unittest/libmariadb)|" CMakeLists.txt
sed -i -e "N; s|typedef unsigned short ushort;\n#endif|#endif\ntypedef unsigned short ushort;|" include/my_global.h
sed -i -e "N; s|SET_TARGET_PROPERTIES(libmariadb PROPERTIES VERSION.*||" libmariadb/CMakeLists.txt
sed -i -e "N; s|SOVERSION \${CPACK_PACKAGE_VERSION_MAJOR})||" libmariadb/CMakeLists.txt # Pig disgusting: the previous multiline thingie should've done it
sed -i -e "N; s|\${CPACK_PACKAGE_VERSION_MAJOR}||" libmariadb/CMakeLists.txt # Pig disgusting: what the fuck
mkdir build
pushd build
PKG_CONFIG_PATH=$SR/usr/lib/pkgconfig cmake \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_FLAGS=--sysroot="$SR" \
-DCMAKE_INSTALL_PREFIX="$SR/usr" \
-DCMAKE_C_COMPILER="$BR"gcc \
-DCMAKE_LINKER="$BR"ld \
-DCMAKE_AR="$BR"ar \
-DCMAKE_NM="$BR"nm \
-DCMAKE_OBJCOPY="$BR"objcopy \
-DCMAKE_OBJDUMP="$BR"objdump \
-DCMAKE_RANLIB="$BR"ranlib \
-DCMAKE_STRIP="$BR"strip \
-DICONV_INCLUDE_DIR="$SR/usr/include" \
-DICONV_LIBRARIES="$SR/usr/lib/libiconv.a" \
-DWITH_EXTERNAL_ZLIB=ON \
-DZLIB_INCLUDE_DIR="$SR/usr/include" \
-DZLIB_LIBRARY="$SR/usr/lib/libz.so" ../ || exit 1
make install || exit 1
popd
# ???
pwd
cp build/libmariadb/*.{a,so} "$SR/usr/lib/mariadb/" || exit 1
popd
# qt
qmake="$QT_ROOT/android_armv7/bin/qmake"
[ ! -f "$qmake" ] && { echo "Could not find qmake in '$qmake'"; exit 1; }
[ ! -x "$qmake" ] && { echo "Qmake is not executable in '$qmake'"; exit 1; }
qtVersion=$(qmake -query QT_VERSION)
pkg=qtbase-opensource-src-$qtVersion.tar.gz
dir=$(basename $pkg .tar.gz)
if [ ! -d $dir ]; then
wget -c http://download.qt-project.org/official_releases/qt/${qtVersion%.*}/$qtVersion/submodules/$pkg
tar -xf $pkg || exit 1
fi
pushd $dir/src/plugins/sqldrivers/mysql/
$qmake "INCLUDEPATH+=$SR/usr/include/mariadb" "LIBS+=$SR/usr/lib/mariadb/libmariadbclient.a $SR/usr/lib/libssl.a $SR/usr/lib/libcrypto.a $SR/usr/lib/libiconv.a" "LIBPATH+=$SR/usr/lib/mariadb" -o Makefile mysql.pro
make || exit 1
make install || exit 1
popd
echo
echo "BOOYAH!!!"
echo
rm -rf \
rootfs_files_after.txt \
rootfs_files_before.txt \
libiconv-*.* \
mariadb_client-*-src* \
qtbase-opensource-src-* \
openssl-*
@Lagui-dev

This comment has been minimized.

Copy link

@Lagui-dev Lagui-dev commented Jan 7, 2016

Hi Raziel,

Can you make the same to compile under Microsoft Windows ?
Regards,
CoyoteBE

@RazZziel

This comment has been minimized.

Copy link
Owner Author

@RazZziel RazZziel commented Jan 19, 2016

@coyotebe I'm afraid I can't, it'd be too different, I'm sorry :\

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment