diff options
Diffstat (limited to 'qmake/library/qmakeevaluator.cpp')
-rw-r--r-- | qmake/library/qmakeevaluator.cpp | 167 |
1 files changed, 99 insertions, 68 deletions
diff --git a/qmake/library/qmakeevaluator.cpp b/qmake/library/qmakeevaluator.cpp index 09ea231684..0df69890b3 100644 --- a/qmake/library/qmakeevaluator.cpp +++ b/qmake/library/qmakeevaluator.cpp @@ -44,6 +44,7 @@ #include "qmakeglobals.h" #include "qmakeparser.h" +#include "qmakevfs.h" #include "ioutils.h" #include <qbytearray.h> @@ -174,13 +175,13 @@ const ProKey &QMakeEvaluator::map(const ProKey &var) } -QMakeEvaluator::QMakeEvaluator(QMakeGlobals *option, - QMakeParser *parser, QMakeHandler *handler) +QMakeEvaluator::QMakeEvaluator(QMakeGlobals *option, QMakeParser *parser, QMakeVfs *vfs, + QMakeHandler *handler) : #ifdef PROEVALUATOR_DEBUG m_debugLevel(option->debugLevel), #endif - m_option(option), m_parser(parser), m_handler(handler) + m_option(option), m_parser(parser), m_handler(handler), m_vfs(vfs) { // So that single-threaded apps don't have to call initialize() for now. initStatics(); @@ -936,7 +937,7 @@ void QMakeEvaluator::visitProVariable( if (varName == statics.strTEMPLATE) setTemplate(); else if (varName == statics.strQMAKE_PLATFORM) - updateFeaturePaths(); + m_featureRoots = 0; #ifdef PROEVALUATOR_FULL else if (varName == statics.strREQUIRES) checkRequirements(values(varName)); @@ -1064,7 +1065,7 @@ bool QMakeEvaluator::prepareProject(const QString &inDir) superdir = m_outputDir; forever { QString superfile = superdir + QLatin1String("/.qmake.super"); - if (IoUtils::exists(superfile)) { + if (m_vfs->exists(superfile)) { m_superfile = QDir::cleanPath(superfile); break; } @@ -1079,10 +1080,10 @@ bool QMakeEvaluator::prepareProject(const QString &inDir) QString dir = m_outputDir; forever { conffile = sdir + QLatin1String("/.qmake.conf"); - if (!IoUtils::exists(conffile)) + if (!m_vfs->exists(conffile)) conffile.clear(); cachefile = dir + QLatin1String("/.qmake.cache"); - if (!IoUtils::exists(cachefile)) + if (!m_vfs->exists(cachefile)) cachefile.clear(); if (!conffile.isEmpty() || !cachefile.isEmpty()) { if (dir != sdir) @@ -1160,6 +1161,7 @@ bool QMakeEvaluator::loadSpecInternal() #endif valuesRef(ProKey("QMAKESPEC")) << ProString(m_qmakespec); m_qmakespecName = IoUtils::fileName(m_qmakespec).toString(); + // This also ensures that m_featureRoots is valid. if (evaluateFeatureFile(QLatin1String("spec_post.prf")) != ReturnTrue) return false; // The MinGW and x-build specs may change the separator; $$shell_{path,quote}() need it @@ -1173,7 +1175,9 @@ bool QMakeEvaluator::loadSpec() m_hostBuild ? m_option->qmakespec : m_option->xqmakespec); { - QMakeEvaluator evaluator(m_option, m_parser, m_handler); + QMakeEvaluator evaluator(m_option, m_parser, m_vfs, m_handler); + evaluator.m_sourceRoot = m_sourceRoot; + evaluator.m_buildRoot = m_buildRoot; if (!m_superfile.isEmpty()) { valuesRef(ProKey("_QMAKE_SUPER_CACHE_")) << ProString(m_superfile); if (evaluator.evaluateFile( @@ -1313,45 +1317,45 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::visitProFile( QMakeBaseEnv *baseEnv = *baseEnvPtr; #ifdef PROEVALUATOR_THREAD_SAFE - { - QMutexLocker locker(&baseEnv->mutex); - m_option->mutex.unlock(); - if (baseEnv->inProgress) { - QThreadPool::globalInstance()->releaseThread(); - baseEnv->cond.wait(&baseEnv->mutex); - QThreadPool::globalInstance()->reserveThread(); - if (!baseEnv->isOk) - return ReturnFalse; - } else + QMutexLocker locker(&baseEnv->mutex); + m_option->mutex.unlock(); + if (baseEnv->inProgress) { + QThreadPool::globalInstance()->releaseThread(); + baseEnv->cond.wait(&baseEnv->mutex); + QThreadPool::globalInstance()->reserveThread(); + if (!baseEnv->isOk) + return ReturnFalse; + } else #endif - if (!baseEnv->evaluator) { + if (!baseEnv->evaluator) { #ifdef PROEVALUATOR_THREAD_SAFE - baseEnv->inProgress = true; - locker.unlock(); + baseEnv->inProgress = true; + locker.unlock(); #endif - QMakeEvaluator *baseEval = new QMakeEvaluator(m_option, m_parser, m_handler); - baseEnv->evaluator = baseEval; - baseEval->m_superfile = m_superfile; - baseEval->m_conffile = m_conffile; - baseEval->m_cachefile = m_cachefile; - baseEval->m_sourceRoot = m_sourceRoot; - baseEval->m_buildRoot = m_buildRoot; - baseEval->m_hostBuild = m_hostBuild; - bool ok = baseEval->loadSpec(); + QMakeEvaluator *baseEval = new QMakeEvaluator(m_option, m_parser, m_vfs, m_handler); + baseEnv->evaluator = baseEval; + baseEval->m_superfile = m_superfile; + baseEval->m_conffile = m_conffile; + baseEval->m_cachefile = m_cachefile; + baseEval->m_sourceRoot = m_sourceRoot; + baseEval->m_buildRoot = m_buildRoot; + baseEval->m_hostBuild = m_hostBuild; + bool ok = baseEval->loadSpec(); #ifdef PROEVALUATOR_THREAD_SAFE - locker.relock(); - baseEnv->isOk = ok; - baseEnv->inProgress = false; - baseEnv->cond.wakeAll(); + locker.relock(); + baseEnv->isOk = ok; + baseEnv->inProgress = false; + baseEnv->cond.wakeAll(); #endif - if (!ok) - return ReturnFalse; - } -#ifdef PROEVALUATOR_THREAD_SAFE + if (!ok) + return ReturnFalse; } +#ifdef PROEVALUATOR_THREAD_SAFE + else if (!baseEnv->isOk) + return ReturnFalse; #endif initFrom(*baseEnv->evaluator); @@ -1429,6 +1433,7 @@ void QMakeEvaluator::updateMkspecPaths() ret << m_sourceRoot + concat; ret << m_option->propertyValue(ProKey("QT_HOST_DATA/get")) + concat; + ret << m_option->propertyValue(ProKey("QT_HOST_DATA/src")) + concat; ret.removeDuplicates(); m_mkspecPaths = ret; @@ -1450,10 +1455,14 @@ void QMakeEvaluator::updateFeaturePaths() m_option->dirlist_sep, QString::SkipEmptyParts); QStringList feature_bases; - if (!m_buildRoot.isEmpty()) + if (!m_buildRoot.isEmpty()) { + feature_bases << m_buildRoot + mkspecs_concat; feature_bases << m_buildRoot; - if (!m_sourceRoot.isEmpty()) + } + if (!m_sourceRoot.isEmpty()) { + feature_bases << m_sourceRoot + mkspecs_concat; feature_bases << m_sourceRoot; + } foreach (const QString &item, m_option->getPathListEnv(QLatin1String("QMAKEPATH"))) feature_bases << (item + mkspecs_concat); @@ -1477,8 +1486,8 @@ void QMakeEvaluator::updateFeaturePaths() } } - feature_bases << (m_option->propertyValue(ProKey("QT_HOST_DATA/get")).toQString(m_mtmp) - + mkspecs_concat); + feature_bases << (m_option->propertyValue(ProKey("QT_HOST_DATA/get")) + mkspecs_concat); + feature_bases << (m_option->propertyValue(ProKey("QT_HOST_DATA/src")) + mkspecs_concat); foreach (const QString &fb, feature_bases) { foreach (const ProString &sfx, values(ProKey("QMAKE_PLATFORM"))) @@ -1496,7 +1505,7 @@ void QMakeEvaluator::updateFeaturePaths() foreach (const QString &root, feature_roots) if (IoUtils::exists(root)) ret << root; - m_featureRoots = ret; + m_featureRoots = new QMakeFeatureRoots(ret); } ProString QMakeEvaluator::propertyValue(const ProKey &name) const @@ -1810,7 +1819,10 @@ ProString QMakeEvaluator::first(const ProKey &variableName) const QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateFile( const QString &fileName, QMakeHandler::EvalFileType type, LoadFlags flags) { - if (ProFile *pro = m_parser->parsedProFile(fileName, true)) { + QMakeParser::ParseFlags pflags = QMakeParser::ParseUseCache; + if (!(flags & LoadSilent)) + pflags |= QMakeParser::ParseReportMissing; + if (ProFile *pro = m_parser->parsedProFile(fileName, pflags)) { m_locationStack.push(m_current); VisitReturn ok = visitProFile(pro, type, flags); m_current = m_locationStack.pop(); @@ -1825,8 +1837,6 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateFile( #endif return ok; } else { - if (!(flags & LoadSilent) && !IoUtils::exists(fileName)) - evalError(fL1S("WARNING: Include file %1 not found").arg(fileName)); return ReturnFalse; } } @@ -1854,34 +1864,55 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateFeatureFile( if (!fn.endsWith(QLatin1String(".prf"))) fn += QLatin1String(".prf"); - if (m_featureRoots.isEmpty()) + if (!m_featureRoots) updateFeaturePaths(); - int start_root = 0; +#ifdef PROEVALUATOR_THREAD_SAFE + m_featureRoots->mutex.lock(); +#endif QString currFn = currentFileName(); - if (IoUtils::fileName(currFn) == IoUtils::fileName(fn)) { - for (int root = 0; root < m_featureRoots.size(); ++root) - if (currFn == m_featureRoots.at(root) + fn) { - start_root = root + 1; - break; + if (IoUtils::fileName(currFn) != IoUtils::fileName(fn)) + currFn.clear(); + // Null values cannot regularly exist in the hash, so they indicate that the value still + // needs to be determined. Failed lookups are represented via non-null empty strings. + QString *fnp = &m_featureRoots->cache[qMakePair(fn, currFn)]; + if (fnp->isNull()) { + int start_root = 0; + const QStringList &paths = m_featureRoots->paths; + if (!currFn.isEmpty()) { + QStringRef currPath = IoUtils::pathName(currFn); + for (int root = 0; root < paths.size(); ++root) + if (currPath == paths.at(root)) { + start_root = root + 1; + break; + } + } + for (int root = start_root; root < paths.size(); ++root) { + QString fname = paths.at(root) + fn; + if (IoUtils::exists(fname)) { + fn = fname; + goto cool; } - } - for (int root = start_root; root < m_featureRoots.size(); ++root) { - QString fname = m_featureRoots.at(root) + fn; - if (IoUtils::exists(fname)) { - fn = fname; - goto cool; } - } #ifdef QMAKE_BUILTIN_PRFS - fn.prepend(QLatin1String(":/qmake/features/")); - if (QFileInfo(fn).exists()) - goto cool; + fn.prepend(QLatin1String(":/qmake/features/")); + if (QFileInfo(fn).exists()) + goto cool; #endif - if (!silent) - evalError(fL1S("Cannot find feature %1").arg(fileName)); - return ReturnFalse; + fn = QLatin1String(""); // Indicate failed lookup. See comment above. - cool: + cool: + *fnp = fn; + } else { + fn = *fnp; + } +#ifdef PROEVALUATOR_THREAD_SAFE + m_featureRoots->mutex.unlock(); +#endif + if (fn.isEmpty()) { + if (!silent) + evalError(fL1S("Cannot find feature %1").arg(fileName)); + return ReturnFalse; + } ProStringList &already = valuesRef(ProKey("QMAKE_INTERNAL_INCLUDED_FEATURES")); ProString afn(fn); if (already.contains(afn)) { @@ -1908,7 +1939,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateFeatureFile( QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateFileInto( const QString &fileName, ProValueMap *values, LoadFlags flags) { - QMakeEvaluator visitor(m_option, m_parser, m_handler); + QMakeEvaluator visitor(m_option, m_parser, m_vfs, m_handler); visitor.m_caller = this; visitor.m_outputDir = m_outputDir; visitor.m_featureRoots = m_featureRoots; |