replace mechanism to override variables from the mkspecs

it is sometimes desirable to override values from the mkspec without
modifying (or wrapping) the spec itself. linux distributors do this on a
regular basis.

so far, we'd pick up CFLAGS, etc. from the environment, in a somewhat
autoconf-like fashion. however, over time, this approach proved
problematic: the concept doesn't mix particularly well with mkspecs to
start with, is unexpected (and therefore causes frustration), and
doesn't mix well with cross-building (at least the way it was realized).
ironically, it was implemented this way (quite a while ago) upon my
explicit request ...

the new mechanism uses explicit variable manipulations on the configure
command line, just like qmake itself understands. as it happens, this is
again quite similar to autoconf-generated configure scripts. however,
this time around we don't pretend to be actually autoconf-like, so we
also don't try to map any variable names (some of which have different
semantics anyway).

this commit also eliminates the last use of the QMakeVar() function,
so delete it and the underlying infrastructure.

Task-number: QTBUG-32530
Task-number: QTBUG-42962
Change-Id: Id31a6b80e1add08ca21f5b178614bda530d12374
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
Oswald Buddenhagen 2016-07-06 13:58:53 +02:00
parent 9172143f52
commit fd3e12e7a6
5 changed files with 46 additions and 72 deletions

View File

@ -4,6 +4,9 @@ Configure understands variable assignments like VAR=value on the command line.
These override any values possibly obtained from pkg-config. The variables
are mentioned in the descriptions of the options they relate to.
It is also possible to manipulate any QMAKE_* variable, to amend the values
from the mkspec for the build of Qt itself, e.g., QMAKE_CXXFLAGS+=-g3.
Top-level installation directories:
-prefix <dir> ...... The deployment directory, as seen on the target device.
[/usr/local/Qt-$QT_VERSION, $PWD if -developer-build]

66
configure vendored
View File

@ -92,11 +92,9 @@ $i"
done
# initialize global variables
QMAKE_VARS_FILE=.qmake.vars
DEVICE_VARS_FILE=.device.vars
HOST_VARS_FILE=.host.vars
:> "$QMAKE_VARS_FILE"
:> "$DEVICE_VARS_FILE"
:> "$HOST_VARS_FILE"
@ -124,29 +122,6 @@ makeabs()
echo "$RES" | sed 's,//,/,g; s,/$,,'
}
# Adds a new qmake variable to the cache
# Usage: QMakeVar mode varname contents
# where mode is one of: set, add, del
QMakeVar()
{
case "$1" in
set)
eq="="
;;
add)
eq="+="
;;
del)
eq="-="
;;
*)
echo >&2 "BUG: wrong command to QMakeVar: $1"
;;
esac
echo "$2" "$eq" "$3" >> "$QMAKE_VARS_FILE"
}
# Helper function for getQMakeConf. It parses include statements in
# qmake.conf and prints out the expanded file
expandQMakeConf()
@ -445,32 +420,10 @@ fi
# initalize variables
#-------------------------------------------------------------------------------
SYSTEM_VARIABLES="AR RANLIB STRIP OBJDUMP LD CC CXX CFLAGS CXXFLAGS LDFLAGS"
for varname in $SYSTEM_VARIABLES; do
qmakevarname="${varname}"
qmakecmdargs=""
# use LDFLAGS for autoconf compat, but qmake uses QMAKE_LFLAGS
if [ "${varname}" = "LDFLAGS" ]; then
qmakevarname="LFLAGS"
elif [ "${varname}" = "LD" ]; then
qmakevarname="LINK"
elif [ "${varname}" = "AR" ]; then
# QMAKE_AR needs to be set to "/path/to/ar cqs" but the
# environment variable will be set to the command only so we
# need to append " cqs" for autoconf compatibility
qmakecmdargs=" cqs"
fi
cmd=`echo \
'if [ -n "\$'${varname}'" ]; then
QMakeVar set QMAKE_'${qmakevarname}' "\$'${varname}${qmakecmdargs}'"
fi'`
eval "$cmd"
done
# Use CC/CXX to run config.tests
mkdir -p "$outpath/config.tests"
rm -f "$outpath/config.tests/.qmake.cache"
cp "$QMAKE_VARS_FILE" "$outpath/config.tests/.qmake.cache"
: > "$outpath/config.tests/.qmake.cache"
# QTDIR may be set and point to an old or system-wide Qt installation
unset QTDIR
@ -1956,14 +1909,6 @@ else
echo
fi
if [ "$OPT_VERBOSE" = "yes" ]; then
echo $ECHO_N "qmake vars .......... $ECHO_C"
cat "$QMAKE_VARS_FILE" | tr '\n' ' '
echo
fi
rm -f "$QMAKE_VARS_FILE" 2>/dev/null
#-------------------------------------------------------------------------------
# build makefiles based on the configuration
#-------------------------------------------------------------------------------
@ -1986,15 +1931,6 @@ rm -f "$QMAKE_VARS_FILE" 2>/dev/null
if [ `basename $0` != "config.status" ]; then
CONFIG_STATUS="$relpath/$relconf$OPT_CMDLINE"
# add the system variables
for varname in $SYSTEM_VARIABLES; do
cmd=`echo \
'if [ -n "\$'${varname}'" ]; then
CONFIG_STATUS="'${varname}'='"'\\\$${varname}'"' \$CONFIG_STATUS"
fi'`
eval "$cmd"
done
echo "$CONFIG_STATUS" | grep '\-confirm\-license' >/dev/null 2>&1 || CONFIG_STATUS="$CONFIG_STATUS -confirm-license"
[ -f "$outpath/config.status" ] && rm -f "$outpath/config.status"

View File

@ -17,6 +17,7 @@
"SYBASE_LIBS": "tds.libs",
"ZLIB_LIBS": "zlib.libs"
},
"custom": "qmakeArgs",
"options": {
"prefix": "string",
"hostprefix": "string",
@ -762,7 +763,7 @@
"testTypeDependencies": {
"linkerSupportsFlag": [ "use_gold_linker" ],
"compile": [ "shared", "use_gold_linker", "compiler-flags", "gcc-sysroot" ],
"compile": [ "shared", "use_gold_linker", "compiler-flags", "gcc-sysroot", "qmakeargs" ],
"detectPkgConfig": [ "cross_compile" ],
"library": [ "pkg-config" ],
"getPkgConfigVariable": [ "pkg-config" ],
@ -1229,6 +1230,10 @@
"output": [ "gccSysroot" ],
"condition": "input.sysroot != ''"
},
"qmakeargs": {
"output": [ "qmakeArgs" ],
"condition": "input.qmakeArgs != ''"
},
"use_gold_linker": {
"description": "Using gold linker",
"condition": "tests.use_gold_linker",

View File

@ -1,5 +1,14 @@
# custom command line handling
defineTest(qtConfCommandline_qmakeArgs) {
contains(1, QMAKE_[A-Z_]+ *[-+]?=.*) {
config.input.qmakeArgs += $$1
export(config.input.qmakeArgs)
return(true)
}
return(false)
}
defineTest(qtConfCommandline_cxxstd) {
arg = $${1}
val = $${2}
@ -560,11 +569,6 @@ defineTest(qtConfOutput_extraFeatures) {
}
defineTest(qtConfOutputPostProcess_privatePro) {
config.output.privatePro += $$cat($$OUT_PWD/.qmake.vars, lines)
export(config.output.privatePro)
}
defineTest(qtConfOutput_compilerFlags) {
# this output also exports the variables locally, so that subsequent compiler tests can use them
@ -610,7 +614,7 @@ defineTest(qtConfOutput_gccSysroot) {
# This variable also needs to be exported immediately, so the compilation tests
# can pick it up.
EXTRA_QMAKE_ARGS = \
EXTRA_QMAKE_ARGS += \
"\"QMAKE_CFLAGS += --sysroot=$$config.input.sysroot\"" \
"\"QMAKE_CXXFLAGS += --sysroot=$$config.input.sysroot\"" \
"\"QMAKE_LFLAGS += --sysroot=$$config.input.sysroot\""
@ -626,6 +630,19 @@ defineTest(qtConfOutput_gccSysroot) {
export(config.output.publicPro)
}
defineTest(qtConfOutput_qmakeArgs) {
!$${2}: return()
config.output.privatePro = "!host_build {"
for (a, config.input.qmakeArgs) {
config.output.privatePro += " $$a"
EXTRA_QMAKE_ARGS += $$system_quote($$a)
}
config.output.privatePro += "}"
export(EXTRA_QMAKE_ARGS)
export(config.output.privatePro)
}
defineTest(qtConfOutputPostProcess_publicPro) {
qt_version = $$[QT_VERSION]
output = \

View File

@ -174,6 +174,14 @@ defineTest(qtConfCommandline_addString) {
}
defineTest(qtConfParseCommandLine) {
custom = $$config.commandline.custom
customCall =
!isEmpty(custom) {
customCall = qtConfCommandline_$$custom
!defined($$customCall, test): \
error("Custom command line callback '$$custom' is undefined.")
}
for (ever) {
c = $$qtConfGetNextCommandlineArg()
isEmpty(c): break()
@ -190,6 +198,11 @@ defineTest(qtConfParseCommandLine) {
next()
}
!isEmpty(customCall) {
$${customCall}($$c): \
next()
}
contains(c, "([A-Z_]+)=(.*)") {
opt = $$replace(c, "^([A-Z_]+)=(.*)", "\\1")
val = $$replace(c, "^([A-Z_]+)=(.*)", "\\2")