diff mbox

[14/15] qt5-sdk-script/setup.sh: Better error detection, Win aware, and more

Message ID CFDF955F78BEAB47A018765A600E2BDC938F05C8@VMPREVAS1.prevas.se
State Accepted
Delegated to: Christian Sørensen
Headers show

Commit Message

christian.braunersorensen@prevas.dk July 25, 2014, 10:27 a.m. UTC
Hi Svend Aaage

Thanks for the patch!

Merged to master.

/Christian
diff mbox

Patch

diff --git a/recipes/sdk/qt5-sdk-script/setup.sh b/recipes/sdk/qt5-sdk-script/setup.sh
index b2d41d9..6539e0f 100755
--- a/recipes/sdk/qt5-sdk-script/setup.sh
+++ b/recipes/sdk/qt5-sdk-script/setup.sh
@@ -1,18 +1,62 @@ 
 #!/bin/bash
-MACHINE_ARCH=${CROSS_COMPILE::-1}
+# Script used to setup the enviroment for Qmake
+# Preconditions:
+#  The following environemt settings are needed prior to invoking the script:
+#  * CROSS_COMPILE must be set, e.g.  CROSS_COMPILE=arm-cortexa9neont-linux-gnueabi-
+#  * Host executeable must be in the path (<sdk_folder>/bin)
+#
+# Note: The script can be run on Windows too with MSYS installed
+# The script generates a qt.conf file which will be placed in <sdk_folder>
+
+CURRENT_OS=$(uname)
+
+echo "Script detected it is running on:"
+if [[ $CURRENT_OS == Linux* ]] ; then
+    echo "Linux"
+else
+    echo "Windows"
+fi
+
+echo "CROSS_COMPILE is '$CROSS_COMPILE'"
+if [ -z $CROSS_COMPILE ]; then
+    echo "Error: 'CROSS_COMPILE' must be set!"  >&2
+    exit 1
+fi
+
+# Determine the tools dir
+GCC_TO_USE=$(which ${CROSS_COMPILE}gcc)
+if [ -z $GCC_TO_USE ]; then
+    echo "Error: Cannot find the cross compiler directory!"  >&2
+    exit 1
+fi
+
+export TOOL=$(dirname $(which ${CROSS_COMPILE}gcc))"/../"
+if [ ! -d $TOOL ]; then
+    echo "Error: Tool dir '$TOOL' does not exist!"  >&2
+    exit 1
+fi
+
+# Strip off the last character
+MACHINE_ARCH=${CROSS_COMPILE:0:$((${#CROSS_COMPILE}-1))}
+echo "Machine arch is: $MACHINE_ARCH"
+
+SYS_REL_TOOL=${MACHINE_ARCH}/sysroot
+export SYS=${TOOL}/${SYS_REL_TOOL}
+
+if [ ! -d $SYS ]; then
+    echo "Error: Sysroot dir '$SYS' does not exist!"  >&2
+    exit 1
+fi

 export AR=${CROSS_COMPILE}ar
 export CC=${CROSS_COMPILE}gcc
 export CXX=${CROSS_COMPILE}g++
 export STRIP=${CROSS_COMPILE}strip

-export TOOL=$(dirname $(which ${CROSS_COMPILE}gcc))"/../"
-export SYS=${TOOL}${MACHINE_ARCH}/sysroot/
-export PKG_CONFIG_LIBDIR=${SYS}usr/lib/pkgconfig
-export PKG_CONFIG_PATH=${SYS}usr/lib/pkgconfig
+export PKG_CONFIG_LIBDIR=${SYS}/usr/lib/pkgconfig
+export PKG_CONFIG_PATH=${SYS}/usr/lib/pkgconfig
 export PKG_CONFIG_SYSROOT_DIR=${SYS}

-export QMAKESPEC="${SYS}usr/share/qt5/mkspecs/linux-oe-g++"
 export OE_QMAKE_UIC="${TOOL}bin/uic"
 export OE_QMAKE_MOC="${TOOL}bin/moc"
 export OE_QMAKE_RCC="${TOOL}bin/rcc"
@@ -23,15 +67,32 @@  export OE_QMAKE_CXX="${CXX}"
 export OE_QMAKE_AR="${AR}"
 export OE_QMAKE_STRIP="${STRIP}"

-echo "[Paths]" > qt.conf
-echo "Prefix = /usr" >> qt.conf
-echo "Headers = ${SYS}usr/include/qt5" >> qt.conf
-echo "Libraries = ${SYS}usr/lib" >> qt.conf
-echo "ArchData = ${SYS}usr/lib" >> qt.conf
-echo "Data = ${SYS}usr/share" >> qt.conf
-echo "Plugins = ${SYS}usr/lib/qt5/plugins" >> qt.conf
-echo "HostBinaries = ${TOOL}bin" >> qt.conf
-echo "HostData = ${SYS}usr/share/qt5/" >> qt.conf
-echo "HostSpec = ${SYS}usr/share/qt5/mkspecs/linux-oe-g++" >> qt.conf
-echo "TargetSpec = ${SYS}usr/share/qt5/mkspecs/linux-oe-g++" >> qt.conf
-export QT_CONF_PATH="${TOOL}qt.conf"
+# Must we differentiate here?
+if [[ $CURRENT_OS == Linux* ]] ; then
+  export QMAKESPEC="${SYS}usr/share/qt5/mkspecs/linux-oe-g++"
+else
+  export QMAKESPEC="linux-oe-g++"
+fi
+
+QT_CONF_FILE=${TOOL}/qt.conf
+touch ${QT_CONF_FILE} || exit 1
+
+echo "[Paths]" > ${QT_CONF_FILE}
+# Give prefix relative to the tools dir
+echo "Prefix = ../" >> ${QT_CONF_FILE}
+echo "Headers = ${SYS_REL_TOOL}/usr/include/qt5" >> ${QT_CONF_FILE}
+echo "Libraries = ${SYS_REL_TOOL}/usr/lib" >> ${QT_CONF_FILE}
+echo "ArchData = ${SYS_REL_TOOL}/usr/lib" >> ${QT_CONF_FILE}
+echo "Data = ${SYS_REL_TOOL}/usr/share" >> ${QT_CONF_FILE}
+echo "Plugins = ${SYS_REL_TOOL}/usr/lib/qt5/plugins" >> ${QT_CONF_FILE}
+echo "HostBinaries = bin" >> ${QT_CONF_FILE}
+echo "HostData = ${SYS_REL_TOOL}/usr/share/qt5" >> ${QT_CONF_FILE}
+if [[ $CURRENT_OS == Linux* ]] ; then
+    echo "HostSpec = ${SYS_REL_TOOL}/usr/share/qt5/mkspecs/linux-oe-g++" >> ${QT_CONF_FILE}
+else
+    echo "HostSpec = ${SYS_REL_TOOL}/usr/share/qt5/mkspecs/win32-g++" >> ${QT_CONF_FILE}
+fi
+echo "TargetSpec = ${SYS_REL_TOOL}/usr/share/qt5/mkspecs/linux-oe-g++" >> ${QT_CONF_FILE}
+
+# Set the paths to the config file
+export QT_CONF_PATH="${QT_CONF_FILE}"