forked from qt-creator/qt-creator
make qmake property map ProString-based
Change-Id: I3c25642b885171a47e8fd27e39e5d470d9f24db3 Reviewed-by: Daniel Teske <daniel.teske@nokia.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
This commit is contained in:
@@ -944,7 +944,7 @@ QtSupport::ProFileReader *Qt4Project::createProFileReader(Qt4ProFileNode *qt4Pro
|
||||
? SysRootProfileInformation::sysRoot(p).toString() : QString();
|
||||
|
||||
if (qtVersion && qtVersion->isValid())
|
||||
m_qmakeGlobals->properties = qtVersion->versionInfo();
|
||||
m_qmakeGlobals->setProperties(qtVersion->versionInfo());
|
||||
m_qmakeGlobals->sysroot = systemRoot;
|
||||
|
||||
Utils::Environment::const_iterator eit = env.constBegin(), eend = env.constEnd();
|
||||
|
@@ -720,7 +720,7 @@ void BaseQtVersion::ensureMkSpecParsed() const
|
||||
return;
|
||||
|
||||
QMakeGlobals option;
|
||||
option.properties = versionInfo();
|
||||
option.setProperties(versionInfo());
|
||||
ProMessageHandler msgHandler(true);
|
||||
ProFileCacheManager::instance()->incRefCount();
|
||||
QMakeParser parser(ProFileCacheManager::instance()->cache(), &msgHandler);
|
||||
|
@@ -77,7 +77,7 @@ BaseQtVersion *QtVersionFactory::createQtVersionFromQMakePath(const Utils::FileN
|
||||
Utils::FileName mkspec = BaseQtVersion::mkspecFromVersionInfo(versionInfo);
|
||||
|
||||
QMakeGlobals globals;
|
||||
globals.properties = versionInfo;
|
||||
globals.setProperties(versionInfo);
|
||||
ProMessageHandler msgHandler(true);
|
||||
ProFileCacheManager::instance()->incRefCount();
|
||||
QMakeParser parser(ProFileCacheManager::instance()->cache(), &msgHandler);
|
||||
|
@@ -193,7 +193,7 @@ bool ProFileEvaluator::accept(ProFile *pro, QMakeEvaluator::LoadFlags flags)
|
||||
|
||||
QString ProFileEvaluator::propertyValue(const QString &name) const
|
||||
{
|
||||
return d->propertyValue(name, false);
|
||||
return d->m_option->propertyValue(ProString(name)).toQString();
|
||||
}
|
||||
|
||||
#ifdef PROEVALUATOR_CUMULATIVE
|
||||
|
@@ -89,6 +89,7 @@ public:
|
||||
bool operator!=(const ProString &other) const { return !(*this == other); }
|
||||
bool operator!=(const QString &other) const { return !(*this == other); }
|
||||
bool operator!=(const QLatin1String &other) const { return !(*this == other); }
|
||||
bool isNull() const { return m_string.isNull(); }
|
||||
bool isEmpty() const { return !m_length; }
|
||||
int size() const { return m_length; }
|
||||
const QChar *constData() const { return m_string.constData() + m_offset; }
|
||||
@@ -154,6 +155,7 @@ enum ProToken {
|
||||
// - name length (1)
|
||||
// - name (name length; unterminated)
|
||||
TokProperty, // qmake property expansion
|
||||
// - hash (2)
|
||||
// - name length (1)
|
||||
// - name (name length; unterminated)
|
||||
TokEnvVar, // environment variable expansion
|
||||
|
@@ -409,8 +409,7 @@ void QMakeEvaluator::evaluateExpression(
|
||||
addStrList(values(map(getHashStr(tokPtr))), tok, ret, pending, joined);
|
||||
break;
|
||||
case TokProperty:
|
||||
addStr(ProString(propertyValue(
|
||||
getStr(tokPtr).toQString(m_tmp1), true), NoHash).setSource(currentProFile()),
|
||||
addStr(propertyValue(getHashStr(tokPtr)).setSource(currentProFile()),
|
||||
ret, pending, joined);
|
||||
break;
|
||||
case TokEnvVar:
|
||||
@@ -446,12 +445,12 @@ void QMakeEvaluator::skipExpression(const ushort *&pTokPtr)
|
||||
default:
|
||||
switch (tok & TokMask) {
|
||||
case TokLiteral:
|
||||
case TokProperty:
|
||||
case TokEnvVar:
|
||||
skipStr(tokPtr);
|
||||
break;
|
||||
case TokHashLiteral:
|
||||
case TokVariable:
|
||||
case TokProperty:
|
||||
skipHashStr(tokPtr);
|
||||
break;
|
||||
case TokFuncName:
|
||||
@@ -1237,7 +1236,7 @@ QStringList QMakeEvaluator::qmakeMkspecPaths() const
|
||||
if (!m_sourceRoot.isEmpty())
|
||||
ret << m_sourceRoot + concat;
|
||||
|
||||
ret << propertyValue(QLatin1String("QT_INSTALL_DATA"), false) + concat;
|
||||
ret << m_option->propertyValue(ProString("QT_INSTALL_DATA")) + concat;
|
||||
|
||||
ret.removeDuplicates();
|
||||
return ret;
|
||||
@@ -1253,7 +1252,7 @@ QStringList QMakeEvaluator::qmakeFeaturePaths() const
|
||||
foreach (const QString &f, m_option->getPathListEnv(QLatin1String("QMAKEFEATURES")))
|
||||
feature_roots += f;
|
||||
|
||||
feature_roots += propertyValue(QLatin1String("QMAKEFEATURES"), false).split(
|
||||
feature_roots += m_option->propertyValue(ProString("QMAKEFEATURES")).toQString(m_mtmp).split(
|
||||
m_option->dirlist_sep, QString::SkipEmptyParts);
|
||||
|
||||
QStringList feature_bases;
|
||||
@@ -1281,7 +1280,8 @@ QStringList QMakeEvaluator::qmakeFeaturePaths() const
|
||||
}
|
||||
}
|
||||
|
||||
feature_bases << (propertyValue(QLatin1String("QT_INSTALL_DATA"), false) + mkspecs_concat);
|
||||
feature_bases << (m_option->propertyValue(ProString("QT_INSTALL_DATA")).toQString(m_mtmp)
|
||||
+ mkspecs_concat);
|
||||
|
||||
foreach (const QString &fb, feature_bases) {
|
||||
foreach (const ProString &sfx, values(ProString("QMAKE_PLATFORM")))
|
||||
@@ -1302,17 +1302,14 @@ QStringList QMakeEvaluator::qmakeFeaturePaths() const
|
||||
return ret;
|
||||
}
|
||||
|
||||
QString QMakeEvaluator::propertyValue(const QString &name, bool complain) const
|
||||
ProString QMakeEvaluator::propertyValue(const ProString &name) const
|
||||
{
|
||||
if (m_option->properties.contains(name))
|
||||
return m_option->properties.value(name);
|
||||
if (name == QLatin1String("QMAKE_MKSPECS"))
|
||||
return qmakeMkspecPaths().join(m_option->dirlist_sep);
|
||||
if (name == QLatin1String("QMAKE_VERSION"))
|
||||
return QLatin1String("1.0"); //### FIXME
|
||||
if (complain)
|
||||
evalError(fL1S("Querying unknown property %1").arg(name));
|
||||
return QString();
|
||||
return ProString(qmakeMkspecPaths().join(m_option->dirlist_sep), NoHash);
|
||||
ProString ret = m_option->propertyValue(name);
|
||||
if (ret.isNull())
|
||||
evalError(fL1S("Querying unknown property %1").arg(name.toQString(m_mtmp)));
|
||||
return ret;
|
||||
}
|
||||
|
||||
ProFile *QMakeEvaluator::currentProFile() const
|
||||
@@ -1527,7 +1524,7 @@ ProStringList QMakeEvaluator::expandVariableReferences(
|
||||
if (var_type == ENVIRON) {
|
||||
replacement = split_value_list(m_option->getEnv(var.toQString(m_tmp1)));
|
||||
} else if (var_type == PROPERTY) {
|
||||
replacement << ProString(propertyValue(var.toQString(m_tmp1), true), NoHash);
|
||||
replacement << propertyValue(var);
|
||||
} else if (var_type == FUNCTION) {
|
||||
replacement += evaluateExpandFunction(var, args);
|
||||
} else if (var_type == VAR) {
|
||||
|
@@ -84,7 +84,7 @@ public:
|
||||
ProStringList values(const ProString &variableName) const;
|
||||
ProStringList &valuesRef(const ProString &variableName);
|
||||
ProString first(const ProString &variableName) const;
|
||||
QString propertyValue(const QString &val, bool complain) const;
|
||||
ProString propertyValue(const ProString &val) const;
|
||||
|
||||
enum VisitReturn {
|
||||
ReturnFalse,
|
||||
@@ -210,6 +210,7 @@ public:
|
||||
ProStringList m_returnValue;
|
||||
QStack<ProValueMap> m_valuemapStack; // VariableName must be us-ascii, the content however can be non-us-ascii.
|
||||
QString m_tmp1, m_tmp2, m_tmp3, m_tmp[2]; // Temporaries for efficient toQString
|
||||
mutable QString m_mtmp;
|
||||
|
||||
QMakeGlobals *m_option;
|
||||
QMakeParser *m_parser;
|
||||
|
@@ -210,27 +210,35 @@ bool QMakeGlobals::initProperties(const QString &qmake)
|
||||
if (line.endsWith('\r'))
|
||||
line.chop(1);
|
||||
QString name = QString::fromLatin1(line.left(off));
|
||||
QString value = QDir::fromNativeSeparators(
|
||||
QString::fromLocal8Bit(line.mid(off + 1)));
|
||||
properties.insert(name, value);
|
||||
ProString value = ProString(QDir::fromNativeSeparators(
|
||||
QString::fromLocal8Bit(line.mid(off + 1))), ProStringConstants::NoHash);
|
||||
properties.insert(ProString(name), value);
|
||||
if (name.startsWith(QLatin1String("QT_")) && !name.contains(QLatin1Char('/'))) {
|
||||
if (name.startsWith(QLatin1String("QT_INSTALL_"))) {
|
||||
properties.insert(name + QLatin1String("/raw"), value);
|
||||
properties.insert(name + QLatin1String("/get"), value);
|
||||
properties.insert(ProString(name + QLatin1String("/raw")), value);
|
||||
properties.insert(ProString(name + QLatin1String("/get")), value);
|
||||
if (name == QLatin1String("QT_INSTALL_PREFIX")
|
||||
|| name == QLatin1String("QT_INSTALL_DATA")
|
||||
|| name == QLatin1String("QT_INSTALL_BINS")) {
|
||||
name.replace(3, 7, QLatin1String("HOST"));
|
||||
properties.insert(name, value);
|
||||
properties.insert(name + QLatin1String("/get"), value);
|
||||
properties.insert(ProString(name), value);
|
||||
properties.insert(ProString(name + QLatin1String("/get")), value);
|
||||
}
|
||||
} else if (name.startsWith(QLatin1String("QT_HOST_"))) {
|
||||
properties.insert(name + QLatin1String("/get"), value);
|
||||
properties.insert(ProString(name + QLatin1String("/get")), value);
|
||||
}
|
||||
}
|
||||
}
|
||||
properties.insert(ProString("QMAKE_VERSION"), ProString("2.01a", ProStringConstants::NoHash));
|
||||
return true;
|
||||
}
|
||||
#else
|
||||
void QMakeGlobals::setProperties(const QHash<QString, QString> &props)
|
||||
{
|
||||
QHash<QString, QString>::ConstIterator it = props.constBegin(), eit = props.constEnd();
|
||||
for (; it != eit; ++it)
|
||||
properties.insert(ProString(it.key()), ProString(it.value(), ProStringConstants::NoHash));
|
||||
}
|
||||
#endif
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
@@ -80,7 +80,6 @@ public:
|
||||
QString dirlist_sep;
|
||||
QString qmakespec;
|
||||
QString cachefile;
|
||||
QHash<QString, QString> properties;
|
||||
#ifndef QT_BOOTSTRAPPED
|
||||
QProcessEnvironment environment;
|
||||
#endif
|
||||
@@ -92,7 +91,10 @@ public:
|
||||
void setCommandLineArguments(const QStringList &args);
|
||||
#ifdef PROEVALUATOR_INIT_PROPS
|
||||
bool initProperties(const QString &qmake);
|
||||
#else
|
||||
void setProperties(const QHash<QString, QString> &props);
|
||||
#endif
|
||||
ProString propertyValue(const ProString &name) const { return properties.value(name); }
|
||||
|
||||
QString expandEnvVars(const QString &str) const;
|
||||
|
||||
@@ -101,6 +103,7 @@ private:
|
||||
QStringList getPathListEnv(const QString &var) const;
|
||||
|
||||
QString precmds, postcmds;
|
||||
QHash<ProString, ProString> properties;
|
||||
|
||||
#ifdef PROEVALUATOR_THREAD_SAFE
|
||||
QMutex mutex;
|
||||
|
@@ -450,7 +450,7 @@ bool QMakeParser::read(ProFile *pro, const QString &in)
|
||||
tok = TokVariable;
|
||||
c = *cur;
|
||||
if (c == '[') {
|
||||
ptr += 2;
|
||||
ptr += 4;
|
||||
tok = TokProperty;
|
||||
term = ']';
|
||||
c = *++cur;
|
||||
@@ -488,18 +488,19 @@ bool QMakeParser::read(ProFile *pro, const QString &in)
|
||||
wordCount++;
|
||||
}
|
||||
tlen = ptr - xprPtr;
|
||||
if (rtok == TokVariable) {
|
||||
if (!resolveVariable(xprPtr, tlen, needSep, &ptr,
|
||||
&buf, &xprBuff, &tokPtr, &tokBuff, cur, in)) {
|
||||
if (rtok != TokVariable
|
||||
|| !resolveVariable(xprPtr, tlen, needSep, &ptr,
|
||||
&buf, &xprBuff, &tokPtr, &tokBuff, cur, in)) {
|
||||
if (rtok == TokVariable || rtok == TokProperty) {
|
||||
xprPtr[-4] = tok;
|
||||
uint hash = ProString::hash((const QChar *)xprPtr, tlen);
|
||||
xprPtr[-3] = (ushort)hash;
|
||||
xprPtr[-2] = (ushort)(hash >> 16);
|
||||
xprPtr[-1] = tlen;
|
||||
} else {
|
||||
xprPtr[-2] = tok;
|
||||
xprPtr[-1] = tlen;
|
||||
}
|
||||
} else {
|
||||
xprPtr[-2] = tok;
|
||||
xprPtr[-1] = tlen;
|
||||
}
|
||||
if ((tok & TokMask) == TokFuncName) {
|
||||
cur++;
|
||||
|
Reference in New Issue
Block a user