Skip to content

Commit

Permalink
move configure -redo handling (mostly) to qmake-based system
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
ossilator committed Dec 13, 2016
1 parent 24cb158 commit 8ebc7e9
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 106 deletions.
55 changes: 3 additions & 52 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,8 @@ if [ x"$1" = x"-top-level" ]; then
shift
fi

CFG_REDO=no
OPT_CMDLINE= # excluding -verbose (for config.opt)
QMAKE_CMDLINE= # including -verbose (for actual parsing)
OPT_CMDLINE= # expanded version for the script
QMAKE_CMDLINE= # verbatim version for qmake call
set -f # suppress globbing in for loop
SAVED_IFS=$IFS
IFS='
Expand All @@ -104,14 +103,8 @@ for i in "$@"; do
fi
for a in `cat $optfile`; do
OPT_CMDLINE="$OPT_CMDLINE
$a"
QMAKE_CMDLINE="$QMAKE_CMDLINE
$a"
done
CFG_REDO=yes # suppress repeated config.opt writeout
continue
;;
-v|-verbose|--verbose|-no-v|-no-verbose|--no-verbose)
;;
*)
OPT_CMDLINE="$OPT_CMDLINE
Expand All @@ -122,7 +115,7 @@ $i"
$i"
done
set --
for i in $QMAKE_CMDLINE; do
for i in $OPT_CMDLINE; do
set -- "$@" "$i"
done
set +f
Expand Down Expand Up @@ -466,13 +459,11 @@ XPLATFORM_WATCHOS=no # Whether target platform is watchOS
XPLATFORM_ANDROID=no
XPLATFORM_MINGW=no # Whether target platform is MinGW (win32-g++*)
PLATFORM=
OPT_CONFIRM_LICENSE=no
OPT_SHADOW=maybe
OPT_VERBOSE=no
OPT_HELP=
CFG_SILENT=no
OPT_MAC_SDK=
COMMERCIAL_USER=ask
CFG_DEV=no

# initalize variables used for installation
Expand Down Expand Up @@ -726,19 +717,6 @@ while [ "$#" -gt 0 ]; do
developer-build)
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)
if [ "$VAL" = "yes" ]; then
OPT_HELP="$VAL"
Expand Down Expand Up @@ -1645,33 +1623,6 @@ fi

"$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
#-------------------------------------------------------------------------------
Expand Down
24 changes: 24 additions & 0 deletions configure.pri
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,14 @@ defineReplace(qtConfFunc_licenseCheck) {
val = $$lower($$prompt("Which edition of Qt do you want to use? ", false))
equals(val, c) {
commercial = yes
QMAKE_SAVED_ARGS += -commercial
} else: equals(val, o) {
commercial = no
QMAKE_SAVED_ARGS += -opensource
} else {
next()
}
export(QMAKE_SAVED_ARGS)
break()
}
} else {
Expand Down Expand Up @@ -206,6 +209,8 @@ defineReplace(qtConfFunc_licenseCheck) {
val = $$lower($$prompt("Do you accept the terms of $$affix license? ", false))
equals(val, y)|equals(val, yes) {
logn()
QMAKE_SAVED_ARGS += -confirm-license
export(QMAKE_SAVED_ARGS)
return(true)
} else: equals(val, n)|equals(val, no) {
return(false)
Expand Down Expand Up @@ -722,3 +727,22 @@ discard_from($$[QT_HOST_DATA/get]/mkspecs/qmodule.pri)
QMAKE_POST_CONFIGURE += \
"include(\$\$[QT_HOST_DATA/get]/mkspecs/qconfig.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()"
2 changes: 2 additions & 0 deletions mkspecs/features/data/configure.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

"recheck": { "type": "void", "name": "cache_use", "value": "positive" },
"recheck-all": { "type": "void", "name": "cache_use", "value": "none" },

"redo": { "type": "redo" }
}

},
Expand Down
23 changes: 20 additions & 3 deletions mkspecs/features/qt_configure.prf
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,17 @@ defineTest(qtConfCommandline_addString) {
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) {
customCalls =
for (cc, allConfigs) {
Expand Down Expand Up @@ -1752,6 +1763,8 @@ for(ever) {
for (currentConfig, allConfigs): \
qtConfSetupLibraries()

QMAKE_SAVED_ARGS = $$QMAKE_EXTRA_ARGS
QMAKE_REDO_CONFIG = false
qtConfParseCommandLine()

!isEmpty(_QMAKE_SUPER_CACHE_): \
Expand Down Expand Up @@ -1829,13 +1842,17 @@ for (currentConfig, allConfigs) {
!isEmpty(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.
for (p, QMAKE_POST_CONFIGURE): \
eval($$p)

logn("Done running configuration tests.")
logn()

logn("Configure summary:")
logn()
qtConfPrintReport()
52 changes: 3 additions & 49 deletions tools/configure/configureapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,6 @@ Configure::Configure(int& argc, char** argv)
//Only used when cross compiling.
dictionary[ "QT_INSTALL_SETTINGS" ] = "/etc/xdg";

dictionary[ "REDO" ] = "no";

dictionary[ "BUILDTYPE" ] = "none";

QString tmp = dictionary[ "QMAKESPEC" ];
if (tmp.contains("\\")) {
tmp = tmp.mid(tmp.lastIndexOf("\\") + 1);
Expand Down Expand Up @@ -145,14 +141,14 @@ void Configure::parseCmdLine()
sourcePathMangled = QFileInfo(sourcePath).path();
buildPathMangled = QFileInfo(buildPath).path();
}
qmakeCmdLine = configCmdLine;

int argCount = configCmdLine.size();
int i = 0;

// Look first for -redo
for (int k = 0 ; k < argCount; ++k) {
if (configCmdLine.at(k) == "-redo") {
dictionary["REDO"] = "yes";
configCmdLine.removeAt(k);
if (!reloadCmdLine(k)) {
dictionary["DONE"] = "error";
Expand All @@ -178,13 +174,7 @@ void Configure::parseCmdLine()
}

for (; i<configCmdLine.size(); ++i) {
if (configCmdLine.at(i) == "-opensource") {
dictionary[ "BUILDTYPE" ] = "opensource";
}
else if (configCmdLine.at(i) == "-commercial") {
dictionary[ "BUILDTYPE" ] = "commercial";
}
else if (configCmdLine.at(i) == "-platform") {
if (configCmdLine.at(i) == "-platform") {
++i;
if (i == argCount)
break;
Expand All @@ -207,10 +197,6 @@ void Configure::parseCmdLine()
else if (configCmdLine.at(i) == "-no-syncqt")
dictionary[ "SYNCQT" ] = "no";

else if (configCmdLine.at(i) == "-confirm-license") {
dictionary["LICENSE_CONFIRMED"] = "yes";
}

// Directories ----------------------------------------------
else if (configCmdLine.at(i) == "-prefix") {
++i;
Expand Down Expand Up @@ -871,7 +857,7 @@ void Configure::configure()
QStringList args;
args << buildPath + "/bin/qmake"
<< sourcePathMangled
<< "--" << configCmdLine;
<< "--" << qmakeCmdLine;

QString pwd = QDir::currentPath();
QDir::setCurrent(buildPathMangled);
Expand All @@ -880,9 +866,6 @@ void Configure::configure()
dictionary[ "DONE" ] = "error";
}
QDir::setCurrent(pwd);

if ((dictionary["REDO"] != "yes") && (dictionary["DONE"] != "error"))
saveCmdLine();
}

bool Configure::reloadCmdLine(int idx)
Expand All @@ -904,35 +887,6 @@ bool Configure::reloadCmdLine(int idx)
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()
{
return !dictionary["DONE"].isEmpty();
Expand Down
3 changes: 1 addition & 2 deletions tools/configure/configureapp.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class Configure

// Our variable dictionaries
QMap<QString,QString> dictionary;
QStringList configCmdLine;
QStringList configCmdLine, qmakeCmdLine;

QString outputLine;

Expand All @@ -80,7 +80,6 @@ class Configure
QString formatPath(const QString &path);

bool reloadCmdLine(int idx);
void saveCmdLine();
};

class FileWriter : public QTextStream
Expand Down

0 comments on commit 8ebc7e9

Please sign in to comment.