Skip to content

Commit

Permalink
configure: Separate host and build platform.
Browse files Browse the repository at this point in the history
This separation makes it possible to make a
canadian cross build of Qt on a linux build machine.
The canadian cross build requires an external Qt that
runs on the build system.

Change-Id: Ifd83a4c6376d3299647e74bb349a3452a6f433fc
Reviewed-by: Oswald Buddenhagen <[email protected]>
  • Loading branch information
davschul committed Oct 30, 2015
1 parent a2b58c1 commit c23a086
Show file tree
Hide file tree
Showing 9 changed files with 143 additions and 66 deletions.
6 changes: 4 additions & 2 deletions config.tests/unix/arch.test
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ SRCDIR=$3
OUTDIR=$4
RESULTFILE=$5
TARGET=$6
shift 6
QMAKE=$7
QTCONF=$8
shift 8

if [ "$TARGET" = "host" ]; then
VARPREFIX="CFG_HOST"
Expand Down Expand Up @@ -44,7 +46,7 @@ done
test -d "$OUTDIR/config.tests/arch" || mkdir -p "$OUTDIR/config.tests/arch"
cd "$OUTDIR/config.tests/arch"
[ -f Makefile ] && $MAKE distclean >/dev/null 2>&1
OUTDIR=$OUTDIR "$OUTDIR/bin/qmake" -nocache -spec "$QMKSPEC" "LIBS+=$LFLAGS" "QMAKE_CXXFLAGS+=$CXXFLAGS" "INCLUDEPATH+=$INCLUDEPATH" "CONFIG-=app_bundle" "$SRCDIR/config.tests/arch/arch$PROSUFFIX.pro" >/dev/null 2>&1 || echo "qmake is broken" >&2
OUTDIR=$OUTDIR "$QMAKE" -qtconf "$QTCONF" -nocache -spec "$QMKSPEC" "LIBS+=$LFLAGS" "QMAKE_CXXFLAGS+=$CXXFLAGS" "INCLUDEPATH+=$INCLUDEPATH" "CONFIG-=app_bundle" "$SRCDIR/config.tests/arch/arch$PROSUFFIX.pro" >/dev/null 2>&1 || echo "qmake is broken" >&2


ARCH=""
Expand Down
6 changes: 4 additions & 2 deletions config.tests/unix/compile.test
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ OUTDIR=$5
TEST=$6
EXE=`basename "$6"`
DESCRIPTION=$7
shift 7
QMAKE=$8
QTCONF=$9
shift 9
LFLAGS="$SYSROOT_FLAG"
INCLUDEPATH=""
CXXFLAGS="$SYSROOT_FLAG"
Expand Down Expand Up @@ -70,7 +72,7 @@ test -r Makefile && $MAKE distclean >/dev/null 2>&1
# Make sure output from possible previous tests is gone
rm -f "$EXE" "${EXE}.exe"

set -- "$OUTDIR/bin/qmake" -nocache -spec "$QMKSPEC" "CONFIG+=$QMAKE_CONFIG" "CONFIG+=android_app" "CONFIG-=debug_and_release app_bundle lib_bundle" "LIBS*=$LFLAGS" "LIBS+=$MAC_ARCH_LFLAGS" "INCLUDEPATH*=$INCLUDEPATH" "QMAKE_CXXFLAGS*=$CXXFLAGS" "QMAKE_CXXFLAGS+=$MAC_ARCH_CXXFLAGS" $QMAKE_ARGS "$SRCDIR/$TEST/$EXE.pro" -o "$OUTDIR/$TEST/Makefile"
set -- "$QMAKE" -qtconf "$QTCONF" -nocache -spec "$QMKSPEC" "CONFIG+=$QMAKE_CONFIG" "CONFIG+=android_app" "CONFIG-=debug_and_release app_bundle lib_bundle" "LIBS*=$LFLAGS" "LIBS+=$MAC_ARCH_LFLAGS" "INCLUDEPATH*=$INCLUDEPATH" "QMAKE_CXXFLAGS*=$CXXFLAGS" "QMAKE_CXXFLAGS+=$MAC_ARCH_CXXFLAGS" $QMAKE_ARGS "$SRCDIR/$TEST/$EXE.pro" -o "$OUTDIR/$TEST/Makefile"
if [ "$VERBOSE" = "yes" ]; then
OUTDIR=$OUTDIR "$@" && $MAKE && SUCCESS=yes
else
Expand Down
4 changes: 3 additions & 1 deletion config.tests/unix/ptrsize.test
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ QMKSPEC=$1
VERBOSE=$2
SRCDIR=$3
OUTDIR=$4
QMAKE=$5
QTCONF=$6

LFLAGS=$SYSROOT_FLAG
CXXFLAGS=$SYSROOT_FLAG
Expand All @@ -13,7 +15,7 @@ CXXFLAGS=$SYSROOT_FLAG

# build and run a test program
test -d "$OUTDIR/config.tests/unix/ptrsize" || mkdir -p "$OUTDIR/config.tests/unix/ptrsize"
"$OUTDIR/bin/qmake" -nocache -spec "$QMKSPEC" "CONFIG-=app_bundle" "QMAKE_LFLAGS*=$LFLAGS" "QMAKE_CXXFLAGS*=$CXXFLAGS" "$SRCDIR/config.tests/unix/ptrsize/ptrsizetest.pro" -o "$OUTDIR/config.tests/unix/ptrsize/Makefile" >/dev/null 2>&1
"$QMAKE" -qtconf "$QTCONF" -nocache -spec "$QMKSPEC" "CONFIG-=app_bundle" "QMAKE_LFLAGS*=$LFLAGS" "QMAKE_CXXFLAGS*=$CXXFLAGS" "$SRCDIR/config.tests/unix/ptrsize/ptrsizetest.pro" -o "$OUTDIR/config.tests/unix/ptrsize/Makefile" >/dev/null 2>&1
cd "$OUTDIR/config.tests/unix/ptrsize"

if [ "$VERBOSE" = "yes" ]; then
Expand Down
98 changes: 79 additions & 19 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,11 @@ QT_CONFIG=
SUPPORTED=
QMAKE_VARS_FILE=.qmake.vars
DEVICE_VARS_FILE=.device.vars
HOST_VARS_FILE=.host.vars

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

#-------------------------------------------------------------------------------
# utility functions
Expand Down Expand Up @@ -195,15 +197,15 @@ expandQMakeConf()
echo "WARNING: Unable to find file $conf_file" >&2
continue
fi
expandQMakeConf "$conf_file"
expandQMakeConf "$conf_file" "$2"
;;
*load\(device_config\)*)
conf_file="$DEVICE_VARS_FILE"
conf_file="$2"
if [ ! -f "$conf_file" ]; then
echo "WARNING: Unable to find file $conf_file" >&2
continue
fi
expandQMakeConf "$conf_file"
expandQMakeConf "$conf_file" "$2"
;;
*)
echo "$line"
Expand Down Expand Up @@ -336,7 +338,7 @@ macSDKify()
getQMakeConf()
{
if [ -z "$specvals" ]; then
specvals=`expandQMakeConf "$QMAKESPEC/qmake.conf" | extractQMakeVariables "host_build"`
specvals=`expandQMakeConf "$QMAKESPEC/qmake.conf" "$HOST_VARS_FILE" | extractQMakeVariables "host_build"`
if [ "$BUILD_ON_MAC" = "yes" ]; then specvals=$(macSDKify "$specvals"); fi
fi
getSingleQMakeVariable "$1" "$specvals"
Expand All @@ -345,7 +347,7 @@ getQMakeConf()
getXQMakeConf()
{
if [ -z "$xspecvals" ]; then
xspecvals=`expandQMakeConf "$XQMAKESPEC/qmake.conf" | extractQMakeVariables "!host_build"`
xspecvals=`expandQMakeConf "$XQMAKESPEC/qmake.conf" "$DEVICE_VARS_FILE" | extractQMakeVariables "!host_build"`
if [ "$XPLATFORM_MAC" = "yes" ]; then xspecvals=$(macSDKify "$xspecvals"); fi
fi
getSingleQMakeVariable "$1" "$xspecvals"
Expand Down Expand Up @@ -477,6 +479,23 @@ resolveDeviceMkspec()
fi
}

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

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

#-------------------------------------------------------------------------------
# operating system detection
#-------------------------------------------------------------------------------
Expand All @@ -502,12 +521,10 @@ BUILD_ON_MAC=no
if [ -d /System/Library/Frameworks/Carbon.framework ]; then
BUILD_ON_MAC=yes
fi
BUILD_ON_MSYS=no
HOST_DIRLIST_SEP=":"
DEV_NULL=/dev/null
if [ "$OSTYPE" = "msys" ]; then
HOST_DIRLIST_SEP=";"
BUILD_ON_MSYS=yes
DEV_NULL=/tmp/empty-file
echo "" > $DEV_NULL
relpath=`(cd "$relpath"; pwd -W)`
Expand Down Expand Up @@ -918,6 +935,7 @@ while [ "$#" -gt 0 ]; do
-hostlibdir| \
-extprefix| \
-sysroot| \
-external-hostbindir| \
-depths| \
-make| \
-nomake| \
Expand All @@ -926,6 +944,7 @@ while [ "$#" -gt 0 ]; do
-xplatform| \
-device| \
-device-option| \
-host-option| \
-sdk| \
-arch| \
-host-arch| \
Expand Down Expand Up @@ -1245,6 +1264,10 @@ while [ "$#" -gt 0 ]; do
gcc-sysroot)
CFG_GCC_SYSROOT="$VAL"
;;
external-hostbindir)
CFG_HOST_QT_TOOLS_PATH="$VAL"
HostVar set HOST_QT_TOOLS "$VAL"
;;
bindir)
QT_INSTALL_BINS="$VAL"
;;
Expand Down Expand Up @@ -1419,6 +1442,11 @@ while [ "$#" -gt 0 ]; do
DEV_VAL=`echo $VAL | cut -d '=' -f 2-`
DeviceVar set $DEV_VAR "$DEV_VAL"
;;
host-option)
HOST_VAR=`echo $VAL | cut -d '=' -f 1`
HOST_VAL=`echo $VAL | cut -d '=' -f 2-`
HostVar set $HOST_VAR "$HOST_VAL"
;;
qpa)
QT_QPA_DEFAULT_PLATFORM="$VAL"
;;
Expand Down Expand Up @@ -2644,6 +2672,8 @@ Additional options:
-device-option <key=value> ... Add device specific options for the device mkspec
(experimental)
-host-option <key=value> ..... Add host specific options for the host mkspec
* -no-separate-debug-info . Do not store debug information in a separate file.
-separate-debug-info .... Strip debug information into a separate file.
Expand Down Expand Up @@ -2675,6 +2705,9 @@ Additional options:
-sysroot <dir> ...... Sets <dir> as the target compiler's and qmake's sysroot and also sets pkg-config paths.
-no-gcc-sysroot ..... When using -sysroot, it disables the passing of --sysroot to the compiler
-external-hostbindir <path> .. Path to Qt tools built for this machine. Use this when -platform
does not match the current system, i.e., to make a Canadian Cross Build.
-no-feature-<feature> Do not compile in <feature>.
-feature-<feature> .. Compile in <feature>. The available features
are described in src/corelib/global/qfeatures.txt
Expand Down Expand Up @@ -4008,7 +4041,8 @@ if true; then ###[ '!' -f "$outpath/bin/qmake" ];
EXTRA_LFLAGS="\$(QMAKE_LFLAGS_RPATH)\"$rpath\" $EXTRA_LFLAGS"
done
fi
if [ "$BUILD_ON_MSYS" = "yes" ]; then
case `basename "$PLATFORM"` in
win32-g++*)
EXTRA_CFLAGS="-DUNICODE"
EXTRA_CXXFLAGS="-DUNICODE"
EXTRA_OBJS="qfilesystemengine_win.o \
Expand All @@ -4027,7 +4061,8 @@ if true; then ###[ '!' -f "$outpath/bin/qmake" ];
\"\$(SOURCE_PATH)/tools/shared/windows/registry.cpp\""
EXTRA_LFLAGS="-static -s -lole32 -luuid -ladvapi32 -lkernel32"
EXEEXT=".exe"
else
;;
*)
EXTRA_OBJS="qfilesystemengine_unix.o \
qfilesystemiterator_unix.o \
qfsfileengine_unix.o \
Expand All @@ -4037,7 +4072,8 @@ if true; then ###[ '!' -f "$outpath/bin/qmake" ];
\"\$(SOURCE_PATH)/src/corelib/io/qfsfileengine_unix.cpp\" \
\"\$(SOURCE_PATH)/src/corelib/tools/qlocale_unix.cpp\""
EXEEXT=
fi
;;
esac
if [ "$BUILD_ON_MAC" = "yes" ]; then
echo "COCOA_LFLAGS =-framework Foundation -framework CoreServices" >>"$mkfile"
echo "CARBON_LFLAGS =-framework ApplicationServices" >>"$mkfile"
Expand All @@ -4058,6 +4094,7 @@ if true; then ###[ '!' -f "$outpath/bin/qmake" ];
if [ '!' -z "$D_FLAGS" ]; then
EXTRA_CFLAGS="$EXTRA_CFLAGS $D_FLAGS"
fi

echo >>"$mkfile"
adjrelpath=`echo "$relpath" | sed 's/ /\\\\\\\\ /g'`
adjoutpath=`echo "$outpath" | sed 's/ /\\\\\\\\ /g'`
Expand Down Expand Up @@ -4127,14 +4164,26 @@ QTCONFFILE="$outpath/bin/qt.conf"
cat > "$QTCONFFILE" <<EOF
[EffectivePaths]
Prefix=..
[Paths]
Prefix=$QT_EXT_PREFIX
TargetSpec=$XQMAKESPEC
HostSpec=$QMAKESPEC
EOF
if [ -n "$CFG_SYSROOT" ]; then
cat >> "$QTCONFFILE" <<EOF
Sysroot=$CFG_SYSROOT
EOF
fi
if [ x"$relpath" != x"$outpath" ]; then
cat >> "$QTCONFFILE" <<EOF
[EffectiveSourcePaths]
Prefix=$relpath
EOF
fi

[ -z "$CFG_HOST_QT_TOOLS_PATH" ] && CFG_HOST_QT_TOOLS_PATH="$outpath/bin"
CFG_QMAKE_PATH="$CFG_HOST_QT_TOOLS_PATH/qmake"

#-------------------------------------------------------------------------------
# write out device config before we run the test.
#-------------------------------------------------------------------------------
Expand All @@ -4146,10 +4195,21 @@ else
DEVICE_VARS_FILE="$DEVICE_VARS_OUTFILE"
fi

#-------------------------------------------------------------------------------
# write out host config.
#-------------------------------------------------------------------------------
HOST_VARS_OUTFILE="$outpath/mkspecs/qhost.pri"
if cmp -s "$HOST_VARS_FILE" "$HOST_VARS_OUTFILE"; then
rm -f "$HOST_VARS_FILE"
else
mv -f $HOST_VARS_FILE "$HOST_VARS_OUTFILE"
HOST_VARS_FILE="$HOST_VARS_OUTFILE"
fi

#-------------------------------------------------------------------------------
# Verify makespec
#-------------------------------------------------------------------------------
QMAKE_OUTPUT=`"$outpath/bin/qmake" -E -nocache -spec "$XQMAKESPEC" "QT=" $DEV_NULL 2>&1`
QMAKE_OUTPUT=`"$CFG_QMAKE_PATH" -qtconf "$QTCONFFILE" -E -nocache -spec "$XQMAKESPEC" "QT=" $DEV_NULL 2>&1`
if [ $? != "0" ]; then
echo "Failed to process makespec for platform '$XPLATFORM'"
if [ "$OPT_VERBOSE" = "yes" ]; then
Expand All @@ -4165,7 +4225,7 @@ fi
#-------------------------------------------------------------------------------
if [ -z "$PKG_CONFIG" ]; then
# See if PKG_CONFIG is set in the mkspec:
PKG_CONFIG="`"$outpath/bin/qmake" -E -nocache -spec "$XQMAKESPEC" "CONFIG=" $DEV_NULL 2>&1 | sed -n -e 's,^PKG_CONFIG = \(.*\),\1,p'`"
PKG_CONFIG="`"$CFG_QMAKE_PATH" -qtconf "$QTCONFFILE" -E -nocache -spec "$XQMAKESPEC" "CONFIG=" $DEV_NULL 2>&1 | sed -n -e 's,^PKG_CONFIG = \(.*\),\1,p'`"
[ -n "$PKG_CONFIG" ] && [ "$OPT_VERBOSE" = "yes" ] && echo "Found pkg-config from mkspec: $PKG_CONFIG"
fi
if [ -z "$PKG_CONFIG" ]; then
Expand Down Expand Up @@ -4240,7 +4300,7 @@ compileTest()
if [ "$CFG_SHARED" = "no" ]; then
test_config="$QMAKE_CONFIG static"
fi
"$unixtests/compile.test" "$XQMAKESPEC" "$test_config" $OPT_VERBOSE "$relpath" "$outpath" "$path" "$name" $I_FLAGS $D_FLAGS $L_FLAGS "$@"
"$unixtests/compile.test" "$XQMAKESPEC" "$test_config" $OPT_VERBOSE "$relpath" "$outpath" "$path" "$name" "$CFG_QMAKE_PATH" "$QTCONFFILE" $I_FLAGS $D_FLAGS $L_FLAGS "$@"
}

compileTestWithPkgConfig()
Expand Down Expand Up @@ -4289,7 +4349,7 @@ compileTestWithPkgConfig()

# Use config.tests/arch/arch.pro to have the compiler tell us what the target architecture is
OUTFILE=$outpath/arch.result
"$unixtests/arch.test" "$XQMAKESPEC" $OPT_VERBOSE "$relpath" "$outpath" "$OUTFILE" "target" $I_FLAGS $D_FLAGS $L_FLAGS
"$unixtests/arch.test" "$XQMAKESPEC" $OPT_VERBOSE "$relpath" "$outpath" "$OUTFILE" "target" $CFG_QMAKE_PATH $QTCONFFILE $I_FLAGS $D_FLAGS $L_FLAGS
if [ $? -eq 0 ]; then
eval `cat "$OUTFILE"`
else
Expand All @@ -4302,7 +4362,7 @@ rm -f "$OUTFILE" 2>/dev/null

if [ "$QMAKESPEC" != "$XQMAKESPEC" ]; then
# Do the same test again, using the host compiler
SYSROOT_FLAG= "$unixtests/arch.test" "$QMAKESPEC" $OPT_VERBOSE "$relpath" "$outpath" "$OUTFILE" "host" $I_FLAGS $D_FLAGS $L_FLAGS
SYSROOT_FLAG= "$unixtests/arch.test" "$QMAKESPEC" $OPT_VERBOSE "$relpath" "$outpath" "$OUTFILE" "host" $CFG_QMAKE_PATH $QTCONFFILE $I_FLAGS $D_FLAGS $L_FLAGS
if [ $? -eq 0 ]; then
eval `cat "$OUTFILE"`
else
Expand Down Expand Up @@ -4553,7 +4613,7 @@ fi

# detect mips_dsp support
if [ "$CFG_ARCH" = "mips" ] && [ "${CFG_MIPS_DSP}" = "auto" ]; then
if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/mips_dsp "mips_dsp" $L_FLAGS $I_FLAGS $D_FLAGS $l_FLAGS; then
if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/mips_dsp "mips_dsp" "$CFG_QMAKE_PATH" "$QTCONFFILE" $L_FLAGS $I_FLAGS $D_FLAGS $l_FLAGS; then
CFG_MIPS_DSP=yes
else
CFG_MIPS_DSP=no
Expand All @@ -4564,7 +4624,7 @@ fi

# detect mips_dspr2 support
if [ "$CFG_ARCH" = "mips" ] && [ "${CFG_MIPS_DSPR2}" = "auto" ]; then
if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/mips_dspr2 "mips_dspr2" $L_FLAGS $I_FLAGS $D_FLAGS $l_FLAGS; then
if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/mips_dspr2 "mips_dspr2" "$CFG_QMAKE_PATH" "$QTCONFFILE" $L_FLAGS $I_FLAGS $D_FLAGS $l_FLAGS; then
CFG_MIPS_DSPR2=yes
else
CFG_MIPS_DSPR2=no
Expand Down Expand Up @@ -6767,7 +6827,7 @@ if [ "$XPLATFORM_MAC" = "yes" ]; then
#endif
EOF
else
"$unixtests/ptrsize.test" "$XQMAKESPEC" $OPT_VERBOSE "$relpath" "$outpath" >&3
"$unixtests/ptrsize.test" "$XQMAKESPEC" $OPT_VERBOSE "$relpath" "$outpath" "$CFG_QMAKE_PATH" "$QTCONFFILE" >&3
echo "#define QT_POINTER_SIZE $?"
fi

Expand Down Expand Up @@ -7437,7 +7497,7 @@ rm -f "$QMAKE_VARS_FILE" 2>/dev/null
cd ..
fi

"$outpath/bin/qmake" "$relpathMangled"
"$CFG_QMAKE_PATH" -qtconf "$QTCONFFILE" "$relpathMangled"

) || exit

Expand Down
15 changes: 7 additions & 8 deletions mkspecs/features/device_config.prf
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
# This file is loaded by some qmakespecs to get early configuration data.

# Load generated qdevice.pri
DEVICE_PRI = $$[QT_HOST_DATA/get]/mkspecs/qdevice.pri
host_build: \
PRI_FILE_NAME = qhost.pri
else: \
PRI_FILE_NAME = qdevice.pri
DEVICE_PRI = $$[QT_HOST_DATA/get]/mkspecs/$$PRI_FILE_NAME
exists($$DEVICE_PRI):include($$DEVICE_PRI)
unset(DEVICE_PRI)

host_build {
CROSS_COMPILE =
} else: isEmpty(CROSS_COMPILE) {
#this variable can be persisted via qmake -set CROSS_COMPILE /foo
CROSS_COMPILE = $$[CROSS_COMPILE]
}
# this variable can be persisted via qmake -set CROSS_COMPILE /foo
!host_build:isEmpty(CROSS_COMPILE): CROSS_COMPILE = $$[CROSS_COMPILE]

# Provide a function to be used by mkspecs
defineTest(deviceSanityCheckCompiler) {
Expand Down
Loading

0 comments on commit c23a086

Please sign in to comment.