forked from qt-creator/qt-creator
change the way how loading of configs & features is controlled
make it an argument of the main entry point instead of a property
This commit is contained in:
@@ -1335,8 +1335,7 @@ void QtVersion::updateToolChainAndMkspec() const
|
|||||||
ProFileEvaluator evaluator(&option, &parser, &msgHandler);
|
ProFileEvaluator evaluator(&option, &parser, &msgHandler);
|
||||||
if (ProFile *pro = parser.parsedProFile(m_mkspecFullPath + "/qmake.conf")) {
|
if (ProFile *pro = parser.parsedProFile(m_mkspecFullPath + "/qmake.conf")) {
|
||||||
evaluator.setCumulative(false);
|
evaluator.setCumulative(false);
|
||||||
evaluator.setParsePreAndPostFiles(false);
|
evaluator.accept(pro, ProFileEvaluator::LoadProOnly);
|
||||||
evaluator.accept(pro);
|
|
||||||
pro->deref();
|
pro->deref();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -143,7 +143,8 @@ public:
|
|||||||
static ALWAYS_INLINE void skipHashStr(const ushort *&tokPtr);
|
static ALWAYS_INLINE void skipHashStr(const ushort *&tokPtr);
|
||||||
void skipExpression(const ushort *&tokPtr);
|
void skipExpression(const ushort *&tokPtr);
|
||||||
|
|
||||||
VisitReturn visitProFile(ProFile *pro, ProFileEvaluatorHandler::EvalFileType type);
|
VisitReturn visitProFile(ProFile *pro, ProFileEvaluatorHandler::EvalFileType type,
|
||||||
|
ProFileEvaluator::LoadFlags flags);
|
||||||
VisitReturn visitProBlock(ProFile *pro, const ushort *tokPtr);
|
VisitReturn visitProBlock(ProFile *pro, const ushort *tokPtr);
|
||||||
VisitReturn visitProBlock(const ushort *tokPtr);
|
VisitReturn visitProBlock(const ushort *tokPtr);
|
||||||
VisitReturn visitProLoop(const ProString &variable, const ushort *exprPtr,
|
VisitReturn visitProLoop(const ProString &variable, const ushort *exprPtr,
|
||||||
@@ -177,8 +178,10 @@ public:
|
|||||||
VisitReturn evaluateConditionalFunction(const ProString &function, const ProString &arguments);
|
VisitReturn evaluateConditionalFunction(const ProString &function, const ProString &arguments);
|
||||||
VisitReturn evaluateConditionalFunction(const ProString &function, const ushort *&tokPtr);
|
VisitReturn evaluateConditionalFunction(const ProString &function, const ushort *&tokPtr);
|
||||||
VisitReturn evaluateConditionalFunction(const ProString &function, const ProStringList &args);
|
VisitReturn evaluateConditionalFunction(const ProString &function, const ProStringList &args);
|
||||||
bool evaluateFileDirect(const QString &fileName, ProFileEvaluatorHandler::EvalFileType type);
|
bool evaluateFileDirect(const QString &fileName, ProFileEvaluatorHandler::EvalFileType type,
|
||||||
bool evaluateFile(const QString &fileName, ProFileEvaluatorHandler::EvalFileType type);
|
ProFileEvaluator::LoadFlags flags);
|
||||||
|
bool evaluateFile(const QString &fileName, ProFileEvaluatorHandler::EvalFileType type,
|
||||||
|
ProFileEvaluator::LoadFlags flags);
|
||||||
bool evaluateFeatureFile(const QString &fileName);
|
bool evaluateFeatureFile(const QString &fileName);
|
||||||
enum EvalIntoMode { EvalProOnly, EvalWithDefaults, EvalWithSetup };
|
enum EvalIntoMode { EvalProOnly, EvalWithDefaults, EvalWithSetup };
|
||||||
bool evaluateFileInto(const QString &fileName, ProFileEvaluatorHandler::EvalFileType type,
|
bool evaluateFileInto(const QString &fileName, ProFileEvaluatorHandler::EvalFileType type,
|
||||||
@@ -223,7 +226,6 @@ public:
|
|||||||
|
|
||||||
QStringList m_addUserConfigCmdArgs;
|
QStringList m_addUserConfigCmdArgs;
|
||||||
QStringList m_removeUserConfigCmdArgs;
|
QStringList m_removeUserConfigCmdArgs;
|
||||||
bool m_parsePreAndPostFiles;
|
|
||||||
|
|
||||||
ProFileOption *m_option;
|
ProFileOption *m_option;
|
||||||
ProFileParser *m_parser;
|
ProFileParser *m_parser;
|
||||||
@@ -434,7 +436,6 @@ ProFileEvaluator::Private::Private(ProFileEvaluator *q_, ProFileOption *option,
|
|||||||
|
|
||||||
// Configuration, more or less
|
// Configuration, more or less
|
||||||
m_cumulative = true;
|
m_cumulative = true;
|
||||||
m_parsePreAndPostFiles = true;
|
|
||||||
|
|
||||||
// Evaluator state
|
// Evaluator state
|
||||||
m_skipLevel = 0;
|
m_skipLevel = 0;
|
||||||
@@ -1116,17 +1117,12 @@ void ProFileEvaluator::Private::visitProVariable(
|
|||||||
}
|
}
|
||||||
|
|
||||||
ProFileEvaluator::Private::VisitReturn ProFileEvaluator::Private::visitProFile(
|
ProFileEvaluator::Private::VisitReturn ProFileEvaluator::Private::visitProFile(
|
||||||
ProFile *pro, ProFileEvaluatorHandler::EvalFileType type)
|
ProFile *pro, ProFileEvaluatorHandler::EvalFileType type,
|
||||||
|
ProFileEvaluator::LoadFlags flags)
|
||||||
{
|
{
|
||||||
m_handler->aboutToEval(currentProFile(), pro, type);
|
m_handler->aboutToEval(currentProFile(), pro, type);
|
||||||
m_profileStack.push(pro);
|
m_profileStack.push(pro);
|
||||||
if (m_profileStack.count() == 1) {
|
if (flags & LoadPreFiles) {
|
||||||
// Do this only for the initial profile we visit, since
|
|
||||||
// that is *the* profile. All the other times we reach this function will be due to
|
|
||||||
// include(file) or load(file)
|
|
||||||
|
|
||||||
if (m_parsePreAndPostFiles) {
|
|
||||||
|
|
||||||
#ifdef PROEVALUATOR_THREAD_SAFE
|
#ifdef PROEVALUATOR_THREAD_SAFE
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&m_option->mutex);
|
QMutexLocker locker(&m_option->mutex);
|
||||||
@@ -1222,11 +1218,14 @@ ProFileEvaluator::Private::VisitReturn ProFileEvaluator::Private::visitProFile(
|
|||||||
m_option->qmakespec = QDir::cleanPath(qmakespec);
|
m_option->qmakespec = QDir::cleanPath(qmakespec);
|
||||||
|
|
||||||
QString spec = m_option->qmakespec + QLatin1String("/qmake.conf");
|
QString spec = m_option->qmakespec + QLatin1String("/qmake.conf");
|
||||||
if (!evaluateFileDirect(spec, ProFileEvaluatorHandler::EvalConfigFile)) {
|
if (!evaluateFileDirect(spec, ProFileEvaluatorHandler::EvalConfigFile,
|
||||||
|
ProFileEvaluator::LoadProOnly)) {
|
||||||
m_handler->configError(
|
m_handler->configError(
|
||||||
fL1S("Could not read qmake configuration file %1").arg(spec));
|
fL1S("Could not read qmake configuration file %1").arg(spec));
|
||||||
} else if (!m_option->cachefile.isEmpty()) {
|
} else if (!m_option->cachefile.isEmpty()) {
|
||||||
evaluateFileDirect(m_option->cachefile, ProFileEvaluatorHandler::EvalConfigFile);
|
evaluateFileDirect(m_option->cachefile,
|
||||||
|
ProFileEvaluatorHandler::EvalConfigFile,
|
||||||
|
ProFileEvaluator::LoadProOnly);
|
||||||
}
|
}
|
||||||
m_option->qmakespec_name = IoUtils::fileName(m_option->qmakespec).toString();
|
m_option->qmakespec_name = IoUtils::fileName(m_option->qmakespec).toString();
|
||||||
if (m_option->qmakespec_name == QLatin1String("default")) {
|
if (m_option->qmakespec_name == QLatin1String("default")) {
|
||||||
@@ -1281,12 +1280,10 @@ ProFileEvaluator::Private::VisitReturn ProFileEvaluator::Private::visitProFile(
|
|||||||
foreach (const QString &remove, m_removeUserConfigCmdArgs)
|
foreach (const QString &remove, m_removeUserConfigCmdArgs)
|
||||||
removeAll(&tmp, ProString(remove, NoHash));
|
removeAll(&tmp, ProString(remove, NoHash));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
visitProBlock(pro, pro->tokPtr());
|
visitProBlock(pro, pro->tokPtr());
|
||||||
|
|
||||||
if (m_profileStack.count() == 1) {
|
if (flags & LoadPostFiles) {
|
||||||
if (m_parsePreAndPostFiles) {
|
|
||||||
evaluateFeatureFile(QLatin1String("default_post.prf"));
|
evaluateFeatureFile(QLatin1String("default_post.prf"));
|
||||||
|
|
||||||
QSet<QString> processed;
|
QSet<QString> processed;
|
||||||
@@ -1308,7 +1305,6 @@ ProFileEvaluator::Private::VisitReturn ProFileEvaluator::Private::visitProFile(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
m_profileStack.pop();
|
m_profileStack.pop();
|
||||||
m_handler->doneWithEval(currentProFile());
|
m_handler->doneWithEval(currentProFile());
|
||||||
|
|
||||||
@@ -2683,7 +2679,8 @@ ProFileEvaluator::Private::VisitReturn ProFileEvaluator::Private::evaluateCondit
|
|||||||
fn.detach();
|
fn.detach();
|
||||||
bool ok;
|
bool ok;
|
||||||
if (parseInto.isEmpty()) {
|
if (parseInto.isEmpty()) {
|
||||||
ok = evaluateFile(fn, ProFileEvaluatorHandler::EvalIncludeFile);
|
ok = evaluateFile(fn, ProFileEvaluatorHandler::EvalIncludeFile,
|
||||||
|
ProFileEvaluator::LoadProOnly);
|
||||||
} else {
|
} else {
|
||||||
QHash<ProString, ProStringList> symbols;
|
QHash<ProString, ProStringList> symbols;
|
||||||
if ((ok = evaluateFileInto(fn, ProFileEvaluatorHandler::EvalAuxFile,
|
if ((ok = evaluateFileInto(fn, ProFileEvaluatorHandler::EvalAuxFile,
|
||||||
@@ -2965,11 +2962,12 @@ ProStringList ProFileEvaluator::Private::values(const ProString &variableName) c
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ProFileEvaluator::Private::evaluateFileDirect(
|
bool ProFileEvaluator::Private::evaluateFileDirect(
|
||||||
const QString &fileName, ProFileEvaluatorHandler::EvalFileType type)
|
const QString &fileName, ProFileEvaluatorHandler::EvalFileType type,
|
||||||
|
ProFileEvaluator::LoadFlags flags)
|
||||||
{
|
{
|
||||||
if (ProFile *pro = m_parser->parsedProFile(fileName, true)) {
|
if (ProFile *pro = m_parser->parsedProFile(fileName, true)) {
|
||||||
m_locationStack.push(m_current);
|
m_locationStack.push(m_current);
|
||||||
bool ok = (visitProFile(pro, type) == ReturnTrue);
|
bool ok = (visitProFile(pro, type, flags) == ReturnTrue);
|
||||||
m_current = m_locationStack.pop();
|
m_current = m_locationStack.pop();
|
||||||
pro->deref();
|
pro->deref();
|
||||||
return ok;
|
return ok;
|
||||||
@@ -2979,7 +2977,8 @@ bool ProFileEvaluator::Private::evaluateFileDirect(
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ProFileEvaluator::Private::evaluateFile(
|
bool ProFileEvaluator::Private::evaluateFile(
|
||||||
const QString &fileName, ProFileEvaluatorHandler::EvalFileType type)
|
const QString &fileName, ProFileEvaluatorHandler::EvalFileType type,
|
||||||
|
ProFileEvaluator::LoadFlags flags)
|
||||||
{
|
{
|
||||||
if (fileName.isEmpty())
|
if (fileName.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
@@ -2988,7 +2987,7 @@ bool ProFileEvaluator::Private::evaluateFile(
|
|||||||
evalError(fL1S("circular inclusion of %1").arg(fileName));
|
evalError(fL1S("circular inclusion of %1").arg(fileName));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return evaluateFileDirect(fileName, type);
|
return evaluateFileDirect(fileName, type, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ProFileEvaluator::Private::evaluateFeatureFile(const QString &fileName)
|
bool ProFileEvaluator::Private::evaluateFeatureFile(const QString &fileName)
|
||||||
@@ -3033,7 +3032,8 @@ bool ProFileEvaluator::Private::evaluateFeatureFile(const QString &fileName)
|
|||||||
m_cumulative = false;
|
m_cumulative = false;
|
||||||
|
|
||||||
// The path is fully normalized already.
|
// The path is fully normalized already.
|
||||||
bool ok = evaluateFileDirect(fn, ProFileEvaluatorHandler::EvalFeatureFile);
|
bool ok = evaluateFileDirect(fn, ProFileEvaluatorHandler::EvalFeatureFile,
|
||||||
|
ProFileEvaluator::LoadProOnly);
|
||||||
|
|
||||||
m_cumulative = cumulative;
|
m_cumulative = cumulative;
|
||||||
return ok;
|
return ok;
|
||||||
@@ -3045,14 +3045,14 @@ bool ProFileEvaluator::Private::evaluateFileInto(
|
|||||||
{
|
{
|
||||||
ProFileEvaluator visitor(m_option, m_parser, m_handler);
|
ProFileEvaluator visitor(m_option, m_parser, m_handler);
|
||||||
visitor.d->m_cumulative = false;
|
visitor.d->m_cumulative = false;
|
||||||
visitor.d->m_parsePreAndPostFiles = (mode == EvalWithSetup);
|
|
||||||
visitor.d->m_outputDir = m_outputDir;
|
visitor.d->m_outputDir = m_outputDir;
|
||||||
// visitor.d->m_valuemapStack.top() = *values;
|
// visitor.d->m_valuemapStack.top() = *values;
|
||||||
if (funcs)
|
if (funcs)
|
||||||
visitor.d->m_functionDefs = *funcs;
|
visitor.d->m_functionDefs = *funcs;
|
||||||
if (mode == EvalWithDefaults)
|
if (mode == EvalWithDefaults)
|
||||||
visitor.d->evaluateFeatureFile(QLatin1String("default_pre.prf"));
|
visitor.d->evaluateFeatureFile(QLatin1String("default_pre.prf"));
|
||||||
if (!visitor.d->evaluateFile(fileName, type))
|
if (!visitor.d->evaluateFile(fileName, type,
|
||||||
|
(mode == EvalWithSetup) ? ProFileEvaluator::LoadAll : ProFileEvaluator::LoadProOnly))
|
||||||
return false;
|
return false;
|
||||||
*values = visitor.d->m_valuemapStack.top();
|
*values = visitor.d->m_valuemapStack.top();
|
||||||
// if (funcs)
|
// if (funcs)
|
||||||
@@ -3196,9 +3196,9 @@ ProFileEvaluator::TemplateType ProFileEvaluator::templateType() const
|
|||||||
return TT_Unknown;
|
return TT_Unknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ProFileEvaluator::accept(ProFile *pro)
|
bool ProFileEvaluator::accept(ProFile *pro, LoadFlags flags)
|
||||||
{
|
{
|
||||||
return d->visitProFile(pro, ProFileEvaluatorHandler::EvalProjectFile);
|
return d->visitProFile(pro, ProFileEvaluatorHandler::EvalProjectFile, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ProFileEvaluator::propertyValue(const QString &name) const
|
QString ProFileEvaluator::propertyValue(const QString &name) const
|
||||||
@@ -3222,9 +3222,4 @@ void ProFileEvaluator::setConfigCommandLineArguments(const QStringList &addUserC
|
|||||||
d->m_removeUserConfigCmdArgs = removeUserConfigCmdArgs;
|
d->m_removeUserConfigCmdArgs = removeUserConfigCmdArgs;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProFileEvaluator::setParsePreAndPostFiles(bool on)
|
|
||||||
{
|
|
||||||
d->m_parsePreAndPostFiles = on;
|
|
||||||
}
|
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|||||||
@@ -113,9 +113,15 @@ public:
|
|||||||
// -nocache, -cache, -spec, QMAKESPEC
|
// -nocache, -cache, -spec, QMAKESPEC
|
||||||
// -set persistent value
|
// -set persistent value
|
||||||
void setConfigCommandLineArguments(const QStringList &addUserConfigCmdArgs, const QStringList &removeUserConfigCmdArgs);
|
void setConfigCommandLineArguments(const QStringList &addUserConfigCmdArgs, const QStringList &removeUserConfigCmdArgs);
|
||||||
void setParsePreAndPostFiles(bool on); // Default is true
|
|
||||||
|
|
||||||
bool accept(ProFile *pro);
|
enum LoadFlag {
|
||||||
|
LoadProOnly = 0,
|
||||||
|
LoadPreFiles = 1,
|
||||||
|
LoadPostFiles = 2,
|
||||||
|
LoadAll = LoadPreFiles|LoadPostFiles
|
||||||
|
};
|
||||||
|
Q_DECLARE_FLAGS(LoadFlags, LoadFlag)
|
||||||
|
bool accept(ProFile *pro, LoadFlags flags = LoadAll);
|
||||||
|
|
||||||
bool contains(const QString &variableName) const;
|
bool contains(const QString &variableName) const;
|
||||||
QString value(const QString &variableName) const;
|
QString value(const QString &variableName) const;
|
||||||
@@ -133,6 +139,8 @@ private:
|
|||||||
friend struct ProFileOption;
|
friend struct ProFileOption;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Q_DECLARE_OPERATORS_FOR_FLAGS(ProFileEvaluator::LoadFlags)
|
||||||
|
|
||||||
// This struct is from qmake, but we are not using everything.
|
// This struct is from qmake, but we are not using everything.
|
||||||
struct ProFileOption
|
struct ProFileOption
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user