diff --git a/src/plugins/qtsupport/baseqtversion.cpp b/src/plugins/qtsupport/baseqtversion.cpp index 92f55eaece8..957e6936486 100644 --- a/src/plugins/qtsupport/baseqtversion.cpp +++ b/src/plugins/qtsupport/baseqtversion.cpp @@ -758,10 +758,7 @@ void BaseQtVersion::ensureMkSpecParsed() const ProFileCacheManager::instance()->incRefCount(); QMakeParser parser(ProFileCacheManager::instance()->cache(), &msgHandler); ProFileEvaluator evaluator(&option, &parser, &msgHandler); - if (ProFile *pro = parser.parsedProFile(mkspecPath().toString() + QLatin1String("/qmake.conf"))) { - evaluator.accept(pro, QMakeEvaluator::LoadProOnly); - pro->deref(); - } + evaluator.loadNamedSpec(mkspecPath().toString(), false); parseMkSpec(&evaluator); diff --git a/src/plugins/qtsupport/qtversionfactory.cpp b/src/plugins/qtsupport/qtversionfactory.cpp index 8335c0e7d05..05cd57e87a1 100644 --- a/src/plugins/qtsupport/qtversionfactory.cpp +++ b/src/plugins/qtsupport/qtversionfactory.cpp @@ -69,10 +69,7 @@ BaseQtVersion *QtVersionFactory::createQtVersionFromQMakePath(const Utils::FileN ProFileCacheManager::instance()->incRefCount(); QMakeParser parser(ProFileCacheManager::instance()->cache(), &msgHandler); ProFileEvaluator evaluator(&globals, &parser, &msgHandler); - if (ProFile *pro = parser.parsedProFile(mkspec.toString() + QLatin1String("/qmake.conf"))) { - evaluator.accept(pro, QMakeEvaluator::LoadProOnly); - pro->deref(); - } + evaluator.loadNamedSpec(mkspec.toString(), false); QList factories = ExtensionSystem::PluginManager::getObjects(); qSort(factories.begin(), factories.end(), &sortByPriority); diff --git a/src/shared/proparser/profileevaluator.cpp b/src/shared/proparser/profileevaluator.cpp index 2b8e5e46511..6e1ad8af863 100644 --- a/src/shared/proparser/profileevaluator.cpp +++ b/src/shared/proparser/profileevaluator.cpp @@ -184,6 +184,15 @@ ProFileEvaluator::TemplateType ProFileEvaluator::templateType() const return TT_Unknown; } +bool ProFileEvaluator::loadNamedSpec(const QString &specDir, bool hostSpec) +{ + d->m_qmakespec = specDir; + d->m_hostBuild = hostSpec; + + d->updateMkspecPaths(); + return d->loadSpecInternal(); +} + bool ProFileEvaluator::accept(ProFile *pro, QMakeEvaluator::LoadFlags flags) { return d->visitProFile(pro, QMakeHandler::EvalProjectFile, flags) == QMakeEvaluator::ReturnTrue; diff --git a/src/shared/proparser/profileevaluator.h b/src/shared/proparser/profileevaluator.h index 531f85e45a7..3d6f9179113 100644 --- a/src/shared/proparser/profileevaluator.h +++ b/src/shared/proparser/profileevaluator.h @@ -69,6 +69,8 @@ public: #endif void setOutputDir(const QString &dir); // Default is empty + bool loadNamedSpec(const QString &specDir, bool hostSpec); + bool accept(ProFile *pro, QMakeEvaluator::LoadFlags flags = QMakeEvaluator::LoadAll); bool contains(const QString &variableName) const; diff --git a/src/shared/proparser/qmakeevaluator.cpp b/src/shared/proparser/qmakeevaluator.cpp index b017dcdcadb..0bc68838dc3 100644 --- a/src/shared/proparser/qmakeevaluator.cpp +++ b/src/shared/proparser/qmakeevaluator.cpp @@ -1032,6 +1032,33 @@ bool QMakeEvaluator::prepareProject(const QString &inDir) return true; } +bool QMakeEvaluator::loadSpecInternal() +{ + if (!evaluateFeatureFile(QLatin1String("spec_pre.prf"))) + return false; + QString spec = m_qmakespec + QLatin1String("/qmake.conf"); + if (!evaluateFileDirect(spec, QMakeHandler::EvalConfigFile, LoadProOnly)) { + evalError(fL1S("Could not read qmake configuration file %1.").arg(spec)); + return false; + } +#ifdef Q_OS_UNIX + m_qmakespecFull = QFileInfo(m_qmakespec).canonicalFilePath(); +#else + // We can't resolve symlinks as they do on Unix, so configure.exe puts + // the source of the qmake.conf at the end of the default/qmake.conf in + // the QMAKESPEC_ORIGINAL variable. + const ProString &orig_spec = first(ProKey("QMAKESPEC_ORIGINAL")); + m_qmakespecFull = orig_spec.isEmpty() ? m_qmakespec : orig_spec.toQString(); +#endif + valuesRef(ProKey("QMAKESPEC")) << ProString(m_qmakespecFull); + m_qmakespecName = IoUtils::fileName(m_qmakespecFull).toString(); + if (!evaluateFeatureFile(QLatin1String("spec_post.prf"))) + return false; + // The MinGW and x-build specs may change the separator; $$shell_{path,quote}() need it + m_dirSep = first(ProKey("QMAKE_DIR_SEP")); + return true; +} + bool QMakeEvaluator::loadSpec() { QString qmakespec = m_option->expandEnvVars( @@ -1085,29 +1112,9 @@ bool QMakeEvaluator::loadSpec() && !evaluateFileDirect(m_superfile, QMakeHandler::EvalConfigFile, LoadProOnly)) { return false; } - if (!evaluateFeatureFile(QLatin1String("spec_pre.prf"))) - return false; - QString spec = m_qmakespec + QLatin1String("/qmake.conf"); - if (!evaluateFileDirect(spec, QMakeHandler::EvalConfigFile, LoadProOnly)) { - evalError(fL1S("Could not read qmake configuration file %1.").arg(spec)); - return false; - } -#ifdef Q_OS_UNIX - m_qmakespecFull = QFileInfo(m_qmakespec).canonicalFilePath(); -#else - // We can't resolve symlinks as they do on Unix, so configure.exe puts - // the source of the qmake.conf at the end of the default/qmake.conf in - // the QMAKESPEC_ORIGINAL variable. - const ProString &orig_spec = first(ProKey("QMAKESPEC_ORIGINAL")); - m_qmakespecFull = orig_spec.isEmpty() ? m_qmakespec : orig_spec.toQString(); -#endif - valuesRef(ProKey("QMAKESPEC")) << ProString(m_qmakespecFull); - m_qmakespecName = IoUtils::fileName(m_qmakespecFull).toString(); - if (!evaluateFeatureFile(QLatin1String("spec_post.prf"))) + if (!loadSpecInternal()) return false; updateFeaturePaths(); // The spec extends the feature search path, so rebuild the cache. - // The MinGW and x-build specs may change the separator; $$shell_{path,quote}() need it - m_dirSep = first(ProKey("QMAKE_DIR_SEP")); if (!m_conffile.isEmpty() && !evaluateFileDirect(m_conffile, QMakeHandler::EvalConfigFile, LoadProOnly)) { return false; diff --git a/src/shared/proparser/qmakeevaluator.h b/src/shared/proparser/qmakeevaluator.h index 970a18b0115..92d6cc329f0 100644 --- a/src/shared/proparser/qmakeevaluator.h +++ b/src/shared/proparser/qmakeevaluator.h @@ -116,6 +116,7 @@ public: void loadDefaults(); bool prepareProject(const QString &inDir); + bool loadSpecInternal(); bool loadSpec(); void initFrom(const QMakeEvaluator &other); void setupProject();