Skip to content

Commit

Permalink
device: Add -device and -device-option to configure
Browse files Browse the repository at this point in the history
For some reference platforms and SDKs we will need to pass in
extra paths. Currently users have to modify the mkspec to adjust
paths or set environment variables that will be picked up.

This change introduces the -device <name> and -device-option
<key=value> option. The key value pairs will be written to a
qdevice.pri and can be used by the qmake.conf of the device spec.

The reason to not save the key value pairs in qconfig.pri is
becase of the fact that the device spec loads the qdevice.pri
earlier than the qconfig.pri. qdevice.pri allows the mkspec
to set the compiler flags and qconfig.pri allows configure to
add to those compiler flags.

Done-with: Holger Freyther

Change-Id: I931a197b8be72397e1eedfee09502eefc01c9d4f
Reviewed-by: Oswald Buddenhagen <[email protected]>
Reviewed-by: Girish Ramakrishnan <[email protected]>
Reviewed-by: Johannes Zellner <[email protected]>
Reviewed-by: Donald Carr <[email protected]>
  • Loading branch information
Girish Ramakrishnan authored and Qt by Nokia committed Mar 27, 2012
1 parent 4c655be commit 84e98fd
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ configure.cache
config.status
mkspecs/default
mkspecs/qconfig.pri
mkspecs/qdevice.pri
moc_*.cpp
qmake/qmake.exe
qmake/Makefile.bak
Expand Down
2 changes: 1 addition & 1 deletion config.tests/unix/compile.test
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ test -r Makefile && $MAKE distclean >/dev/null 2>&1
# Make sure output from possible previous tests is gone
rm -f "$EXE" "${EXE}.exe"

"$OUTDIR/bin/qmake" -nocache -spec "$QMKSPEC" "CONFIG+=$QMAKE_CONFIG" "CONFIG-=debug_and_release" "LIBS*=$LFLAGS" "LIBS+=$MAC_ARCH_LFLAGS" "INCLUDEPATH*=$INCLUDEPATH" "QMAKE_CXXFLAGS*=$CXXFLAGS" "QMAKE_CXXFLAGS+=$MAC_ARCH_CXXFLAGS" "QT_BUILD_TREE=$OUTDIR" "$SRCDIR/$TEST/$EXE.pro" -o "$OUTDIR/$TEST/Makefile"
OUTDIR=$OUTDIR "$OUTDIR/bin/qmake" -nocache -spec "$QMKSPEC" "CONFIG+=$QMAKE_CONFIG" "CONFIG-=debug_and_release" "LIBS*=$LFLAGS" "LIBS+=$MAC_ARCH_LFLAGS" "INCLUDEPATH*=$INCLUDEPATH" "QMAKE_CXXFLAGS*=$CXXFLAGS" "QMAKE_CXXFLAGS+=$MAC_ARCH_CXXFLAGS" "QT_BUILD_TREE=$OUTDIR" "$SRCDIR/$TEST/$EXE.pro" -o "$OUTDIR/$TEST/Makefile"

if [ "$VERBOSE" = "yes" ]; then
$MAKE
Expand Down
47 changes: 44 additions & 3 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,10 @@ QTCONFIG_CONFIG=
QT_CONFIG=
SUPPORTED=
QMAKE_VARS_FILE=.qmake.vars
DEVICE_VARS_FILE=.device.vars

:> "$QMAKE_VARS_FILE"
:> "$DEVICE_VARS_FILE"

#-------------------------------------------------------------------------------
# utility functions
Expand Down Expand Up @@ -223,6 +225,23 @@ linkerSupportsFlag()
compilerSupportsFlag "$lflags" >/dev/null 2>&1
}

#-------------------------------------------------------------------------------
# device options
#-------------------------------------------------------------------------------
DeviceVar()
{
case "$1" in
set)
eq="="
;;
*)
echo >&2 "BUG: wrong command to QMakeVar: $1"
;;
esac

echo "$2" "$eq" "$3" >> "$DEVICE_VARS_FILE"
}

#-------------------------------------------------------------------------------
# operating system detection
#-------------------------------------------------------------------------------
Expand Down Expand Up @@ -910,7 +929,7 @@ while [ "$#" -gt 0 ]; do
shift
VAL=$1
;;
-prefix|-docdir|-headerdir|-plugindir|-importdir|-datadir|-libdir|-bindir|-translationdir|-sysconfdir|-examplesdir|-testsdir|-depths|-make|-nomake|-platform|-xplatform|-sdk|-arch|-host-arch|-mysql_config|-sysroot|-hostdatadir|-hostbindir)
-prefix|-docdir|-headerdir|-plugindir|-importdir|-datadir|-libdir|-bindir|-translationdir|-sysconfdir|-examplesdir|-testsdir|-depths|-make|-nomake|-platform|-xplatform|-device|-device-option|-sdk|-arch|-host-arch|-mysql_config|-sysroot|-hostdatadir|-hostbindir)
VAR=`echo $1 | sed "s,^-\(.*\),\1,"`
shift
VAL="$1"
Expand Down Expand Up @@ -1306,6 +1325,14 @@ while [ "$#" -gt 0 ]; do
XPLATFORM="$VAL"
case `basename "$XPLATFORM"` in win32-g++*) XPLATFORM_MINGW=yes;; esac
;;
device)
XPLATFORM="devices/$VAL"
;;
device-option)
DEV_VAR=`echo $VAL | sed "s,^\(.*\)=.*,\1,"`
DEV_VAL=`echo $VAL | sed "s,^.*=\(.*\),\1,"`
DeviceVar set $DEV_VAR $DEV_VAL
;;
debug-and-release)
if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
CFG_DEBUG_RELEASE="$VAL"
Expand Down Expand Up @@ -2456,6 +2483,15 @@ if [ "$CFG_RTOS_ENABLED" = "no" ]; then
esac
fi

#-------------------------------------------------------------------------------
# write out device config before we run the test.
#-------------------------------------------------------------------------------
if cmp -s "$DEVICE_VARS_FILE" "$outpath/mkspecs/qdevice.pri"; then
rm -f "$DEVICE_VARS_FILE"
else
mv -f $DEVICE_VARS_FILE "$outpath/mkspecs/qdevice.pri"
fi

#-------------------------------------------------------------------------------
# tests that don't need qmake (must be run before displaying help)
#-------------------------------------------------------------------------------
Expand Down Expand Up @@ -2929,6 +2965,7 @@ Usage: $relconf [-h] [-prefix <dir>] [-prefix-install] [-bindir <dir>] [-libdir
[-no-openssl] [-openssl] [-openssl-linked]
[-no-gtkstyle] [-gtkstyle]
[-qt-pcre] [-system-pcre]
[-device <name>] [-device-option <key=value>]
[additional platform specific options (see below)]
Expand Down Expand Up @@ -3192,6 +3229,10 @@ Additional options:
-force-asserts ........ Force Q_ASSERT to be enabled even in release builds.
-device <name> ............... Cross-compile for device <name> (experimental)
-device-option <key=value> ... Add device specific options for the device mkspec
(experimental)
EOF

if [ "$CFG_SEPARATE_DEBUG_INFO" = "auto" ]; then
Expand Down Expand Up @@ -3925,12 +3966,12 @@ fi # Build qmake
#-------------------------------------------------------------------------------

# Use config.tests/arch/arch.pro to has the compiler tell us what the target architecture is
CFG_ARCH=`"$outpath/bin/qmake" -spec "$XQMAKESPEC" -o /dev/null "$relpath/config.tests/arch/arch.pro" 2>&1 | sed -n -e 's,^Project MESSAGE:.*Architecture: \([a-zA-Z0-9_]*\).*,\1,p'`
CFG_ARCH=`OUTDIR="$outpath" "$outpath/bin/qmake" -spec "$XQMAKESPEC" -o /dev/null "$relpath/config.tests/arch/arch.pro" 2>&1 | sed -n -e 's,^Project MESSAGE:.*Architecture: \([a-zA-Z0-9_]*\).*,\1,p'`

[ -z "$CFG_ARCH" ] && CFG_ARCH="unknown"
if [ "$QMAKESPEC" != "$XQMAKESPEC" ]; then
# Do the same test again, using the host compiler
CFG_HOST_ARCH=`"$outpath/bin/qmake" -spec "$QMAKESPEC" -o /dev/null "$relpath/config.tests/arch/arch.pro" 2>&1 | sed -n -e 's,^Project MESSAGE:.*Architecture: \([a-zA-Z0-9_]*\).*,\1,p'`
CFG_HOST_ARCH=`OUTDIR="$outpath" "$outpath/bin/qmake" -spec "$QMAKESPEC" -o /dev/null "$relpath/config.tests/arch/arch.pro" 2>&1 | sed -n -e 's,^Project MESSAGE:.*Architecture: \([a-zA-Z0-9_]*\).*,\1,p'`
[ -z "$CFG_HOST_ARCH" ] && CFG_HOST_ARCH="unknown"
else
# not cross compiling, host == target
Expand Down
27 changes: 27 additions & 0 deletions mkspecs/features/device_config.prf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Load generated qdevice.pri
exists($$_QMAKE_CACHE_) {
# set in default_pre, so it's the first place to check for qdevice.pri
DIR = $$fromfile($$_QMAKE_CACHE_, QT_BUILD_TREE)
!isEmpty(DIR):DEVICE_PRI = $$DIR/mkspecs/qdevice.pri
}

isEmpty(DEVICE_PRI) {
# OUTDIR environ is set by configure (arch detection) and compile.test
DIR = $$(OUTDIR)
!isEmpty(DIR):DEVICE_PRI = $$DIR/mkspecs/qdevice.pri
}

isEmpty(DEVICE_PRI) {
DIR = $$[QT_HOST_DATA]
!isEmpty(DIR):DEVICE_PRI = $$DIR/mkspecs/qdevice.pri
}

isEmpty(DEVICE_PRI) {
error(Could not locate qdevice.pri)
}

exists($$DEVICE_PRI):include($$DEVICE_PRI)

unset(DEVICE_PRI)
unset(DIR)

4 changes: 3 additions & 1 deletion qtbase.pro
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ unix {
$(DEL_FILE) src/corelib/global/qconfig.h; \
$(DEL_FILE) src/corelib/global/qconfig.cpp; \
$(DEL_FILE) mkspecs/qconfig.pri; \
$(DEL_FILE) mkspecs/qdevice.pri; \
$(DEL_FILE) mkspecs/qmodule.pri; \
$(DEL_FILE) .qmake.cache; \
(cd qmake && $(MAKE) distclean);
Expand All @@ -80,6 +81,7 @@ win32 {
confclean.commands += -$(DEL_FILE) src\\corelib\\global\\qconfig.h $$escape_expand(\\n\\t) \
-$(DEL_FILE) src\\corelib\\global\\qconfig.cpp $$escape_expand(\\n\\t) \
-$(DEL_FILE) mkspecs\\qconfig.pri $$escape_expand(\\n\\t) \
-$(DEL_FILE) mkspecs\\qdevice.pri $$escape_expand(\\n\\t) \
-$(DEL_FILE) mkspecs\\qmodule.pri $$escape_expand(\\n\\t) \
-$(DEL_FILE) .qmake.cache $$escape_expand(\\n\\t) \
(cd qmake && $(MAKE) distclean)
Expand Down Expand Up @@ -115,7 +117,7 @@ INSTALLS += configtests

#mkspecs
mkspecs.path = $$[QT_HOST_DATA]/mkspecs
mkspecs.files = $$OUT_PWD/mkspecs/qconfig.pri $$OUT_PWD/mkspecs/qmodule.pri $$files($$PWD/mkspecs/*)
mkspecs.files = $$OUT_PWD/mkspecs/qconfig.pri $$OUT_PWD/mkspecs/qmodule.pri $$OUT_PWD/mkspecs/qdevice.pri $$files($$PWD/mkspecs/*)
mkspecs.files -= $$PWD/mkspecs/modules
unix {
DEFAULT_QMAKESPEC = $$QMAKESPEC
Expand Down

0 comments on commit 84e98fd

Please sign in to comment.