From 05798f87cb6c0bbb47ee31ebd9eb7fbb7fb1d4a0 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 8 Jun 2012 18:01:37 +0200 Subject: [PATCH] factor out QMakeEvaluator::prepareProject() Change-Id: I99a5b0b9ef3080ebc5d0546c3bf17c8806a52c72 Reviewed-by: Daniel Teske --- src/shared/proparser/qmakeevaluator.cpp | 71 +++++++++++++------------ src/shared/proparser/qmakeevaluator.h | 1 + 2 files changed, 39 insertions(+), 33 deletions(-) diff --git a/src/shared/proparser/qmakeevaluator.cpp b/src/shared/proparser/qmakeevaluator.cpp index 0a66b42b340..e697cddb792 100644 --- a/src/shared/proparser/qmakeevaluator.cpp +++ b/src/shared/proparser/qmakeevaluator.cpp @@ -820,6 +820,43 @@ void QMakeEvaluator::visitProVariable( } } +void QMakeEvaluator::prepareProject() +{ + // ### init QMAKE_QMAKE, QMAKE_SH + // ### init QMAKE_EXT_{C,H,CPP,OBJ} + // ### init TEMPLATE_PREFIX + + if (m_option->do_cache) { + QString qmake_cache = m_option->cachefile; + if (qmake_cache.isEmpty() && !m_outputDir.isEmpty()) { //find it as it has not been specified + QDir dir(m_outputDir); + forever { + qmake_cache = dir.path() + QLatin1String("/.qmake.cache"); + if (IoUtils::exists(qmake_cache)) + break; + if (!dir.cdUp() || dir.isRoot()) { + qmake_cache.clear(); + break; + } + } + } + if (!qmake_cache.isEmpty()) { + ProValueMap cache_valuemap; + if (evaluateFileInto(qmake_cache, QMakeHandler::EvalConfigFile, + &cache_valuemap, EvalProOnly)) { + if (m_option->qmakespec.isEmpty()) { + const ProStringList &vals = cache_valuemap.value(ProString("QMAKESPEC")); + if (!vals.isEmpty()) + m_option->qmakespec = vals.first().toQString(); + } + } else { + qmake_cache.clear(); + } + } + m_option->cachefile = qmake_cache; + } +} + void QMakeEvaluator::loadSpec() { QString qmakespec = m_option->expandEnvVars(m_option->qmakespec); @@ -910,39 +947,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::visitProFile( m_cumulative = false; #endif - // ### init QMAKE_QMAKE, QMAKE_SH - // ### init QMAKE_EXT_{C,H,CPP,OBJ} - // ### init TEMPLATE_PREFIX - - if (m_option->do_cache) { - QString qmake_cache = m_option->cachefile; - if (qmake_cache.isEmpty() && !m_outputDir.isEmpty()) { //find it as it has not been specified - QDir dir(m_outputDir); - forever { - qmake_cache = dir.path() + QLatin1String("/.qmake.cache"); - if (IoUtils::exists(qmake_cache)) - break; - if (!dir.cdUp() || dir.isRoot()) { - qmake_cache.clear(); - break; - } - } - } - if (!qmake_cache.isEmpty()) { - ProValueMap cache_valuemap; - if (evaluateFileInto(qmake_cache, QMakeHandler::EvalConfigFile, - &cache_valuemap, EvalProOnly)) { - if (m_option->qmakespec.isEmpty()) { - const ProStringList &vals = cache_valuemap.value(ProString("QMAKESPEC")); - if (!vals.isEmpty()) - m_option->qmakespec = vals.first().toQString(); - } - } else { - qmake_cache.clear(); - } - } - m_option->cachefile = qmake_cache; - } + prepareProject(); loadSpec(); diff --git a/src/shared/proparser/qmakeevaluator.h b/src/shared/proparser/qmakeevaluator.h index 557206d7656..258e449063e 100644 --- a/src/shared/proparser/qmakeevaluator.h +++ b/src/shared/proparser/qmakeevaluator.h @@ -101,6 +101,7 @@ public: static ALWAYS_INLINE void skipHashStr(const ushort *&tokPtr); void skipExpression(const ushort *&tokPtr); + void prepareProject(); void loadSpec(); void visitCmdLine(const QString &cmds); VisitReturn visitProFile(ProFile *pro, QMakeHandler::EvalFileType type,