clean up qconfig/qmodule.pri handling in configure

instead of saving the files away and restoring them afterwards, use the
new and shiny discard_from() function to throw away everything the files
might contain.

strictly speaking, this is not precise, as the pris may also use *=, -=,
and possibly other operations which cannot be trivially undone, but the
purpose is essentially to discard the special outputs of some features
which may affect subsequent tests, for which this is sufficient.

as a side effect, the failure to load qmodule.pri is not fatal any more
(like for qconfig.pri), to save the pointless effort of ensuring that it
exists.

Change-Id: I07625b60c4f2e27b21206b2c16d24ab111737395
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
Oswald Buddenhagen 2016-08-23 14:22:19 +02:00
parent 12bb328bb0
commit d76a756b03
4 changed files with 5 additions and 48 deletions

19
configure vendored
View File

@ -1886,14 +1886,6 @@ config.input.qt_licheck = $Licheck
config.input.qt_release_date = $ReleaseDate
EOF
# create a clean qmodule/qconfig.pri for running the tests
# .qmake.cache loads qt_build_parts which requires that qmodule.pri exists
for arg in qconfig qmodule; do
file="$outpath/mkspecs/$arg.pri"
[ ! -f "$file.old" ] && [ -f "$file" ] && mv "$file" "$file.old"
: > "$file"
done
# recreate command line for qmake
set -f
SAVED_IFS=$IFS
@ -1909,17 +1901,6 @@ IFS=$SAVED_IFS
$CFG_QMAKE_PATH -o Makefile.cfg -qtconf "$QTCONFFILE" $relpath/configure.pri -- "$@" || exit 101
rm Makefile.cfg
# Re-use old file if unchanged, to avoid needless rebuilds
for arg in qconfig qmodule; do
file="$outpath/mkspecs/$arg.pri"
if cmp -s "$file" "$file.old"; then
rm -f "$file"
mv "$file.old" "$file"
else
rm -f "$file.old"
fi
done
#-------------------------------------------------------------------------------
# give feedback on configuration
#-------------------------------------------------------------------------------

View File

@ -773,6 +773,10 @@ defineTest(qtConfReport_buildMode) {
qtConfReportPadded($$1, $$build_mode)
}
# ensure pristine environment for configuration
discard_from($$[QT_HOST_DATA/get]/mkspecs/qconfig.pri)
discard_from($$[QT_HOST_DATA/get]/mkspecs/qmodule.pri)
# load and process input from configure
exists("$$OUT_PWD/config.tests/configure.cfg") {
include("$$OUT_PWD/config.tests/configure.cfg")

View File

@ -12,7 +12,7 @@
!contains(QMAKE_INTERNAL_INCLUDED_FILES, .*qmodule\\.pri) {
QMAKE_QT_MODULE = $$[QT_HOST_DATA/get]/mkspecs/qmodule.pri
!exists($$QMAKE_QT_MODULE)|!include($$QMAKE_QT_MODULE, "", true) {
error("Cannot load qmodule.pri!")
debug(1, "Cannot load qmodule.pri!")
} else {
debug(1, "Loaded qmodule.pri from ($$QMAKE_QT_MODULE)")
}

View File

@ -999,21 +999,6 @@ void Configure::buildQmake()
void Configure::configure()
{
static const char * const files[] = { "qmodule", "qconfig" };
for (int i = 0; i < 2; i++) {
QFile file(buildPath + "/mkspecs/" + files[i] + ".pri");
QString oldfn = file.fileName() + ".old";
if (file.exists() && !QFileInfo::exists(oldfn))
QFile::rename(file.fileName(), oldfn);
if (!file.open(QFile::WriteOnly | QFile::Text)) {
cout << "Failed to create file " << qPrintable(file.fileName()) << endl;
dictionary[ "DONE" ] = "error";
return;
}
file.close();
}
FileWriter ci(buildPath + "/config.tests/configure.cfg");
ci << "# Feature defaults set by configure command line\n"
<< "config.input.qt_edition = " << dictionary["EDITION"] << "\n"
@ -1034,19 +1019,6 @@ void Configure::configure()
cout << "Qmake failed, return code " << exitCode << endl << endl;
dictionary[ "DONE" ] = "error";
}
for (int i = 0; i < 2; i++) {
QFile file(buildPath + "/mkspecs/" + files[i] + ".pri");
QFile oldFile(file.fileName() + ".old");
if (oldFile.open(QIODevice::ReadOnly | QIODevice::Text)
&& file.open(QIODevice::ReadOnly | QIODevice::Text)
&& oldFile.readAll() == file.readAll()) {
file.remove();
oldFile.rename(file.fileName());
} else {
oldFile.remove();
}
}
}
void Configure::generateMakefiles()