move configure -redo handling (mostly) to qmake-based system

the qmake bootstrap uses some of the options, so the configures still
read config.opt for their own purposes, but the general handling is
entirely in the new system now.

Change-Id: I2c6c657d4da01c8d520ac74795454747bb224bdd
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
Oswald Buddenhagen 2016-11-15 20:49:43 +01:00
parent 24cb1580e2
commit 8ebc7e967c
6 changed files with 53 additions and 106 deletions

55
configure vendored
View File

@ -84,9 +84,8 @@ if [ x"$1" = x"-top-level" ]; then
shift shift
fi fi
CFG_REDO=no OPT_CMDLINE= # expanded version for the script
OPT_CMDLINE= # excluding -verbose (for config.opt) QMAKE_CMDLINE= # verbatim version for qmake call
QMAKE_CMDLINE= # including -verbose (for actual parsing)
set -f # suppress globbing in for loop set -f # suppress globbing in for loop
SAVED_IFS=$IFS SAVED_IFS=$IFS
IFS=' IFS='
@ -104,14 +103,8 @@ for i in "$@"; do
fi fi
for a in `cat $optfile`; do for a in `cat $optfile`; do
OPT_CMDLINE="$OPT_CMDLINE OPT_CMDLINE="$OPT_CMDLINE
$a"
QMAKE_CMDLINE="$QMAKE_CMDLINE
$a" $a"
done done
CFG_REDO=yes # suppress repeated config.opt writeout
continue
;;
-v|-verbose|--verbose|-no-v|-no-verbose|--no-verbose)
;; ;;
*) *)
OPT_CMDLINE="$OPT_CMDLINE OPT_CMDLINE="$OPT_CMDLINE
@ -122,7 +115,7 @@ $i"
$i" $i"
done done
set -- set --
for i in $QMAKE_CMDLINE; do for i in $OPT_CMDLINE; do
set -- "$@" "$i" set -- "$@" "$i"
done done
set +f set +f
@ -466,13 +459,11 @@ XPLATFORM_WATCHOS=no # Whether target platform is watchOS
XPLATFORM_ANDROID=no XPLATFORM_ANDROID=no
XPLATFORM_MINGW=no # Whether target platform is MinGW (win32-g++*) XPLATFORM_MINGW=no # Whether target platform is MinGW (win32-g++*)
PLATFORM= PLATFORM=
OPT_CONFIRM_LICENSE=no
OPT_SHADOW=maybe OPT_SHADOW=maybe
OPT_VERBOSE=no OPT_VERBOSE=no
OPT_HELP= OPT_HELP=
CFG_SILENT=no CFG_SILENT=no
OPT_MAC_SDK= OPT_MAC_SDK=
COMMERCIAL_USER=ask
CFG_DEV=no CFG_DEV=no
# initalize variables used for installation # initalize variables used for installation
@ -726,19 +717,6 @@ while [ "$#" -gt 0 ]; do
developer-build) developer-build)
CFG_DEV="yes" CFG_DEV="yes"
;; ;;
commercial)
COMMERCIAL_USER="yes"
;;
opensource)
COMMERCIAL_USER="no"
;;
confirm-license)
if [ "$VAL" = "yes" ]; then
OPT_CONFIRM_LICENSE="$VAL"
else
UNKNOWN_OPT=yes
fi
;;
h|help) h|help)
if [ "$VAL" = "yes" ]; then if [ "$VAL" = "yes" ]; then
OPT_HELP="$VAL" OPT_HELP="$VAL"
@ -1645,33 +1623,6 @@ fi
"$CFG_QMAKE_PATH" -qtconf "$QTCONFFILE" "$relpathMangled" -- "$@" || exit "$CFG_QMAKE_PATH" -qtconf "$QTCONFFILE" "$relpathMangled" -- "$@" || exit
#-------------------------------------------------------------------------------
# finally save the executed command to another script
#-------------------------------------------------------------------------------
if [ $CFG_REDO = no ]; then
if [ "$COMMERCIAL_USER" = "ask" ]; then
if grep '^QT_EDITION = OpenSource$' "$outpath/mkspecs/qconfig.pri" >/dev/null 2>&1; then
OPT_CMDLINE="$OPT_CMDLINE
-opensource"
else
OPT_CMDLINE="$OPT_CMDLINE
-commercial"
fi
fi
if [ "$OPT_CONFIRM_LICENSE" = "no" ]; then
OPT_CMDLINE="$OPT_CMDLINE
-confirm-license"
fi
# skip first line, as it's always empty due to unconditional field separation
echo "$OPT_CMDLINE" | tail -n +2 > config.opt
[ -f "config.status" ] && rm -f config.status
echo "#!/bin/sh" > config.status
echo "$relpathMangled/$relconf -redo \"\$@\"" >> config.status
chmod +x config.status
fi
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# final notes for the user # final notes for the user
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------

View File

@ -91,11 +91,14 @@ defineReplace(qtConfFunc_licenseCheck) {
val = $$lower($$prompt("Which edition of Qt do you want to use? ", false)) val = $$lower($$prompt("Which edition of Qt do you want to use? ", false))
equals(val, c) { equals(val, c) {
commercial = yes commercial = yes
QMAKE_SAVED_ARGS += -commercial
} else: equals(val, o) { } else: equals(val, o) {
commercial = no commercial = no
QMAKE_SAVED_ARGS += -opensource
} else { } else {
next() next()
} }
export(QMAKE_SAVED_ARGS)
break() break()
} }
} else { } else {
@ -206,6 +209,8 @@ defineReplace(qtConfFunc_licenseCheck) {
val = $$lower($$prompt("Do you accept the terms of $$affix license? ", false)) val = $$lower($$prompt("Do you accept the terms of $$affix license? ", false))
equals(val, y)|equals(val, yes) { equals(val, y)|equals(val, yes) {
logn() logn()
QMAKE_SAVED_ARGS += -confirm-license
export(QMAKE_SAVED_ARGS)
return(true) return(true)
} else: equals(val, n)|equals(val, no) { } else: equals(val, n)|equals(val, no) {
return(false) return(false)
@ -722,3 +727,22 @@ discard_from($$[QT_HOST_DATA/get]/mkspecs/qmodule.pri)
QMAKE_POST_CONFIGURE += \ QMAKE_POST_CONFIGURE += \
"include(\$\$[QT_HOST_DATA/get]/mkspecs/qconfig.pri)" \ "include(\$\$[QT_HOST_DATA/get]/mkspecs/qconfig.pri)" \
"include(\$\$[QT_HOST_DATA/get]/mkspecs/qmodule.pri)" "include(\$\$[QT_HOST_DATA/get]/mkspecs/qmodule.pri)"
defineTest(createConfigStatus) {
$$QMAKE_REDO_CONFIG: return()
cfg = $$relative_path($$_PRO_FILE_PWD_/configure, $$OUT_PWD)
ext =
equals(QMAKE_HOST.os, Windows) {
ext = .bat
cont = \
"$$system_quote($$system_path($$cfg)$$ext) -redo %*"
} else {
cont = \
"$${LITERAL_HASH}!/bin/sh" \
"exec $$system_quote($$cfg) -redo \"$@\""
}
write_file($$OUT_PWD/config.status$$ext, cont, exe)|error()
}
QMAKE_POST_CONFIGURE += \
"createConfigStatus()"

View File

@ -9,6 +9,8 @@
"recheck": { "type": "void", "name": "cache_use", "value": "positive" }, "recheck": { "type": "void", "name": "cache_use", "value": "positive" },
"recheck-all": { "type": "void", "name": "cache_use", "value": "none" }, "recheck-all": { "type": "void", "name": "cache_use", "value": "none" },
"redo": { "type": "redo" }
} }
}, },

View File

@ -177,6 +177,17 @@ defineTest(qtConfCommandline_addString) {
export(config.input.$$opt) export(config.input.$$opt)
} }
defineTest(qtConfCommandline_redo) {
!exists($$OUT_PWD/config.opt) {
qtConfAddError("No config.opt present - cannot redo configuration.")
return()
}
QMAKE_EXTRA_ARGS = $$cat($$OUT_PWD/config.opt, lines) $$QMAKE_EXTRA_ARGS
export(QMAKE_EXTRA_ARGS)
QMAKE_REDO_CONFIG = true
export(QMAKE_REDO_CONFIG)
}
defineTest(qtConfParseCommandLine) { defineTest(qtConfParseCommandLine) {
customCalls = customCalls =
for (cc, allConfigs) { for (cc, allConfigs) {
@ -1752,6 +1763,8 @@ for(ever) {
for (currentConfig, allConfigs): \ for (currentConfig, allConfigs): \
qtConfSetupLibraries() qtConfSetupLibraries()
QMAKE_SAVED_ARGS = $$QMAKE_EXTRA_ARGS
QMAKE_REDO_CONFIG = false
qtConfParseCommandLine() qtConfParseCommandLine()
!isEmpty(_QMAKE_SUPER_CACHE_): \ !isEmpty(_QMAKE_SUPER_CACHE_): \
@ -1829,13 +1842,17 @@ for (currentConfig, allConfigs) {
!isEmpty(QT_CONFIGURE_SKIPPED_MODULES): \ !isEmpty(QT_CONFIGURE_SKIPPED_MODULES): \
qtConfAddNote("The following modules are not being compiled in this configuration:" $$QT_CONFIGURE_SKIPPED_MODULES) qtConfAddNote("The following modules are not being compiled in this configuration:" $$QT_CONFIGURE_SKIPPED_MODULES)
logn("Done running configuration tests.")
logn()
!$$QMAKE_REDO_CONFIG {
write_file($$OUT_PWD/config.opt, QMAKE_SAVED_ARGS)|error()
}
# these come from the pri files loaded above. # these come from the pri files loaded above.
for (p, QMAKE_POST_CONFIGURE): \ for (p, QMAKE_POST_CONFIGURE): \
eval($$p) eval($$p)
logn("Done running configuration tests.")
logn()
logn("Configure summary:") logn("Configure summary:")
logn() logn()
qtConfPrintReport() qtConfPrintReport()

View File

@ -107,10 +107,6 @@ Configure::Configure(int& argc, char** argv)
//Only used when cross compiling. //Only used when cross compiling.
dictionary[ "QT_INSTALL_SETTINGS" ] = "/etc/xdg"; dictionary[ "QT_INSTALL_SETTINGS" ] = "/etc/xdg";
dictionary[ "REDO" ] = "no";
dictionary[ "BUILDTYPE" ] = "none";
QString tmp = dictionary[ "QMAKESPEC" ]; QString tmp = dictionary[ "QMAKESPEC" ];
if (tmp.contains("\\")) { if (tmp.contains("\\")) {
tmp = tmp.mid(tmp.lastIndexOf("\\") + 1); tmp = tmp.mid(tmp.lastIndexOf("\\") + 1);
@ -145,6 +141,7 @@ void Configure::parseCmdLine()
sourcePathMangled = QFileInfo(sourcePath).path(); sourcePathMangled = QFileInfo(sourcePath).path();
buildPathMangled = QFileInfo(buildPath).path(); buildPathMangled = QFileInfo(buildPath).path();
} }
qmakeCmdLine = configCmdLine;
int argCount = configCmdLine.size(); int argCount = configCmdLine.size();
int i = 0; int i = 0;
@ -152,7 +149,6 @@ void Configure::parseCmdLine()
// Look first for -redo // Look first for -redo
for (int k = 0 ; k < argCount; ++k) { for (int k = 0 ; k < argCount; ++k) {
if (configCmdLine.at(k) == "-redo") { if (configCmdLine.at(k) == "-redo") {
dictionary["REDO"] = "yes";
configCmdLine.removeAt(k); configCmdLine.removeAt(k);
if (!reloadCmdLine(k)) { if (!reloadCmdLine(k)) {
dictionary["DONE"] = "error"; dictionary["DONE"] = "error";
@ -178,13 +174,7 @@ void Configure::parseCmdLine()
} }
for (; i<configCmdLine.size(); ++i) { for (; i<configCmdLine.size(); ++i) {
if (configCmdLine.at(i) == "-opensource") { if (configCmdLine.at(i) == "-platform") {
dictionary[ "BUILDTYPE" ] = "opensource";
}
else if (configCmdLine.at(i) == "-commercial") {
dictionary[ "BUILDTYPE" ] = "commercial";
}
else if (configCmdLine.at(i) == "-platform") {
++i; ++i;
if (i == argCount) if (i == argCount)
break; break;
@ -207,10 +197,6 @@ void Configure::parseCmdLine()
else if (configCmdLine.at(i) == "-no-syncqt") else if (configCmdLine.at(i) == "-no-syncqt")
dictionary[ "SYNCQT" ] = "no"; dictionary[ "SYNCQT" ] = "no";
else if (configCmdLine.at(i) == "-confirm-license") {
dictionary["LICENSE_CONFIRMED"] = "yes";
}
// Directories ---------------------------------------------- // Directories ----------------------------------------------
else if (configCmdLine.at(i) == "-prefix") { else if (configCmdLine.at(i) == "-prefix") {
++i; ++i;
@ -871,7 +857,7 @@ void Configure::configure()
QStringList args; QStringList args;
args << buildPath + "/bin/qmake" args << buildPath + "/bin/qmake"
<< sourcePathMangled << sourcePathMangled
<< "--" << configCmdLine; << "--" << qmakeCmdLine;
QString pwd = QDir::currentPath(); QString pwd = QDir::currentPath();
QDir::setCurrent(buildPathMangled); QDir::setCurrent(buildPathMangled);
@ -880,9 +866,6 @@ void Configure::configure()
dictionary[ "DONE" ] = "error"; dictionary[ "DONE" ] = "error";
} }
QDir::setCurrent(pwd); QDir::setCurrent(pwd);
if ((dictionary["REDO"] != "yes") && (dictionary["DONE"] != "error"))
saveCmdLine();
} }
bool Configure::reloadCmdLine(int idx) bool Configure::reloadCmdLine(int idx)
@ -904,35 +887,6 @@ bool Configure::reloadCmdLine(int idx)
return true; return true;
} }
void Configure::saveCmdLine()
{
if (dictionary[ "REDO" ] != "yes") {
if (dictionary["BUILDTYPE"] == "none") {
bool openSource = false;
QFile inFile(buildPath + "/mkspecs/qconfig.pri");
if (inFile.open(QFile::ReadOnly | QFile::Text)) {
QTextStream inStream(&inFile);
while (!inStream.atEnd()) {
if (inStream.readLine() == "QT_EDITION = OpenSource")
openSource = true;
}
}
configCmdLine.append(openSource ? "-opensource" : "-commercial");
}
if (dictionary["LICENSE_CONFIRMED"] != "yes")
configCmdLine.append("-confirm-license");
QFile outFile(buildPathMangled + "/config.opt");
if (outFile.open(QFile::WriteOnly | QFile::Text)) {
QTextStream outStream(&outFile);
for (QStringList::Iterator it = configCmdLine.begin(); it != configCmdLine.end(); ++it) {
outStream << (*it) << endl;
}
outStream.flush();
outFile.close();
}
}
}
bool Configure::isDone() bool Configure::isDone()
{ {
return !dictionary["DONE"].isEmpty(); return !dictionary["DONE"].isEmpty();

View File

@ -63,7 +63,7 @@ private:
// Our variable dictionaries // Our variable dictionaries
QMap<QString,QString> dictionary; QMap<QString,QString> dictionary;
QStringList configCmdLine; QStringList configCmdLine, qmakeCmdLine;
QString outputLine; QString outputLine;
@ -80,7 +80,6 @@ private:
QString formatPath(const QString &path); QString formatPath(const QString &path);
bool reloadCmdLine(int idx); bool reloadCmdLine(int idx);
void saveCmdLine();
}; };
class FileWriter : public QTextStream class FileWriter : public QTextStream