summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@qt.io>2019-05-31 15:06:14 +0200
committerJoerg Bornemann <joerg.bornemann@qt.io>2019-06-04 21:19:37 +0200
commit224a60989ed95e8b91ac88a12666af6e5a66e619 (patch)
tree72d3f4b192d9e647ca44ea2ec9ed5243acdc64c3
parentff4ef79e0ddc1310262d2db60e6f9ba51df9dc6c (diff)
Fix determination of source and build roots
QMake searches a .qmake.conf file to determine the source root of the project, and a .qmake.cache to determine the build root. If a .qmake.conf exists but no .qmake.cache in the build directory is found, a build root would be set that is only valid if the build directory is at the same depth as the source directory. The invalid build root resulted in the creation of .qmake.cache files at "interesting" locations (e.g. high up in the directory tree), a potential cause for even more interesting build failures in the future. Fix this by splitting up the loop that determined build and source root. Both are now determined independently of each other. Fixes: QTBUG-76140 Change-Id: Ib5c922b87879fcf2f076298a69abcdbc4e8587b3 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
-rw-r--r--qmake/library/qmakeevaluator.cpp39
1 files changed, 26 insertions, 13 deletions
diff --git a/qmake/library/qmakeevaluator.cpp b/qmake/library/qmakeevaluator.cpp
index 432339d48e..09c1f80222 100644
--- a/qmake/library/qmakeevaluator.cpp
+++ b/qmake/library/qmakeevaluator.cpp
@@ -1128,35 +1128,48 @@ bool QMakeEvaluator::prepareProject(const QString &inDir)
}
superdir = qdfi.path();
}
- QString sdir = inDir;
QString dir = m_outputDir;
forever {
- conffile = sdir + QLatin1String("/.qmake.conf");
- if (!m_vfs->exists(conffile, flags))
- conffile.clear();
cachefile = dir + QLatin1String("/.qmake.cache");
if (!m_vfs->exists(cachefile, flags))
cachefile.clear();
- if (!conffile.isEmpty() || !cachefile.isEmpty()) {
- if (dir != sdir)
- m_sourceRoot = sdir;
+ if (!cachefile.isEmpty()) {
m_buildRoot = dir;
break;
}
if (dir == superdir)
goto no_cache;
- QFileInfo qsdfi(sdir);
QFileInfo qdfi(dir);
- if (qsdfi.isRoot() || qdfi.isRoot())
- goto no_cache;
- sdir = qsdfi.path();
+ if (qdfi.isRoot()) {
+ cachefile.clear();
+ break;
+ }
dir = qdfi.path();
}
+ QString sdir = inDir;
+ forever {
+ conffile = sdir + QLatin1String("/.qmake.conf");
+ if (!m_vfs->exists(conffile, flags))
+ conffile.clear();
+ if (!conffile.isEmpty()) {
+ if (sdir != m_buildRoot)
+ m_sourceRoot = sdir;
+ break;
+ }
+ QFileInfo qsdfi(sdir);
+ if (qsdfi.isRoot()) {
+ conffile.clear();
+ break;
+ }
+ sdir = qsdfi.path();
+ }
} else {
m_buildRoot = QFileInfo(cachefile).path();
}
- m_conffile = QDir::cleanPath(conffile);
- m_cachefile = QDir::cleanPath(cachefile);
+ if (!conffile.isEmpty())
+ m_conffile = QDir::cleanPath(conffile);
+ if (!cachefile.isEmpty())
+ m_cachefile = QDir::cleanPath(cachefile);
}
no_cache: