diff options
author | Oswald Buddenhagen <oswald.buddenhagen@digia.com> | 2013-11-07 20:40:00 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-11-14 19:26:20 +0100 |
commit | ff31d87cc883dcf17ab459a15eac04e074d9614a (patch) | |
tree | cb85d3f6bc9f115045d745c6c40e077344a49c6a /qmake/library/qmakeevaluator.cpp | |
parent | 72075656cfeac570ce002c517a22b1c5d7bc0dd0 (diff) |
support a cache that is really just a cache
unlike .qmake.cache & co., the presence of this file has no magic
effects on where mkspecs, modules and other things are searched.
as the obvious name "cache" is of course already taken, we call it
"stash".
the file is searched up to the super cache (if present), otherwise up to
the normal cache/conf (if present), otherwise up to the root.
if it's not found, it is created next to the super cache (if present),
otherwise next to the cache/conf (if present), otherwise in the current
output directory.
note that the cache really should be created and populated by the
top-level project if there are subprojects: otherwise, if there is an
"anchor" (super/cache/conf), subprojects would race for updating the
cache and make a mess. without an "anchor", each subproject would just
create its own cache, kind of defeating its purpose. this is no
different from the existing "cache", but it's worth mentioning that
removing the "anchoring" function does not remove the "nesting order"
constraint.
Task-number: QTBUG-31340
Change-Id: I786d40cef40d14582a0dd4a9407863001bec4c98
Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
Diffstat (limited to 'qmake/library/qmakeevaluator.cpp')
-rw-r--r-- | qmake/library/qmakeevaluator.cpp | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/qmake/library/qmakeevaluator.cpp b/qmake/library/qmakeevaluator.cpp index 3415724c5e..f46eb75670 100644 --- a/qmake/library/qmakeevaluator.cpp +++ b/qmake/library/qmakeevaluator.cpp @@ -79,19 +79,19 @@ QT_BEGIN_NAMESPACE #define fL1S(s) QString::fromLatin1(s) -QMakeBaseKey::QMakeBaseKey(const QString &_root, bool _hostBuild) - : root(_root), hostBuild(_hostBuild) +QMakeBaseKey::QMakeBaseKey(const QString &_root, const QString &_stash, bool _hostBuild) + : root(_root), stash(_stash), hostBuild(_hostBuild) { } uint qHash(const QMakeBaseKey &key) { - return qHash(key.root) ^ (uint)key.hostBuild; + return qHash(key.root) ^ qHash(key.stash) ^ (uint)key.hostBuild; } bool operator==(const QMakeBaseKey &one, const QMakeBaseKey &two) { - return one.root == two.root && one.hostBuild == two.hostBuild; + return one.root == two.root && one.stash == two.stash && one.hostBuild == two.hostBuild; } QMakeBaseEnv::QMakeBaseEnv() @@ -1139,6 +1139,19 @@ bool QMakeEvaluator::prepareProject(const QString &inDir) dir = qdfi.path(); } + dir = m_outputDir; + forever { + QString stashfile = dir + QLatin1String("/.qmake.stash"); + if (dir == (!superdir.isEmpty() ? superdir : m_buildRoot) || m_vfs->exists(stashfile)) { + m_stashfile = QDir::cleanPath(stashfile); + break; + } + QFileInfo qdfi(dir); + if (qdfi.isRoot()) + break; + dir = qdfi.path(); + } + return true; } @@ -1253,6 +1266,12 @@ bool QMakeEvaluator::loadSpec() m_cachefile, QMakeHandler::EvalConfigFile, LoadProOnly) != ReturnTrue) return false; } + if (!m_stashfile.isEmpty() && m_vfs->exists(m_stashfile)) { + valuesRef(ProKey("_QMAKE_STASH_")) << ProString(m_stashfile); + if (evaluateFile( + m_stashfile, QMakeHandler::EvalConfigFile, LoadProOnly) != ReturnTrue) + return false; + } return true; } @@ -1330,7 +1349,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::visitProFile( #ifdef PROEVALUATOR_THREAD_SAFE m_option->mutex.lock(); #endif - QMakeBaseEnv **baseEnvPtr = &m_option->baseEnvs[QMakeBaseKey(m_buildRoot, m_hostBuild)]; + QMakeBaseEnv **baseEnvPtr = &m_option->baseEnvs[QMakeBaseKey(m_buildRoot, m_stashfile, m_hostBuild)]; if (!*baseEnvPtr) *baseEnvPtr = new QMakeBaseEnv; QMakeBaseEnv *baseEnv = *baseEnvPtr; @@ -1357,6 +1376,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::visitProFile( baseEval->m_superfile = m_superfile; baseEval->m_conffile = m_conffile; baseEval->m_cachefile = m_cachefile; + baseEval->m_stashfile = m_stashfile; baseEval->m_sourceRoot = m_sourceRoot; baseEval->m_buildRoot = m_buildRoot; baseEval->m_hostBuild = m_hostBuild; |