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