forked from qt-creator/qt-creator
CMake: Unify mapping of type strings to CMakeConfigItem::Type
Change-Id: I29b905aac8965039369891e6aad7e356fa1dad8f Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
@@ -134,6 +134,23 @@ QStringList CMakeConfigItem::cmakeSplitValue(const QString &in, bool keepEmpty)
|
||||
return newArgs;
|
||||
}
|
||||
|
||||
CMakeConfigItem::Type CMakeConfigItem::typeStringToType(const QByteArray &type)
|
||||
{
|
||||
if (type == "BOOL")
|
||||
return CMakeConfigItem::BOOL;
|
||||
if (type == "STRING")
|
||||
return CMakeConfigItem::STRING;
|
||||
if (type == "FILEPATH")
|
||||
return CMakeConfigItem::FILEPATH;
|
||||
if (type == "PATH")
|
||||
return CMakeConfigItem::PATH;
|
||||
if (type == "STATIC")
|
||||
return CMakeConfigItem::STATIC;
|
||||
|
||||
QTC_CHECK(type == "INTERNAL");
|
||||
return CMakeConfigItem::INTERNAL;
|
||||
}
|
||||
|
||||
QString CMakeConfigItem::expandedValue(const ProjectExplorer::Kit *k) const
|
||||
{
|
||||
return expandedValue(k->macroExpander());
|
||||
@@ -195,20 +212,8 @@ CMakeConfigItem CMakeConfigItem::fromString(const QString &s)
|
||||
// Fill in item:
|
||||
CMakeConfigItem item;
|
||||
if (!key.isEmpty()) {
|
||||
CMakeConfigItem::Type t = CMakeConfigItem::STRING;
|
||||
if (type == QLatin1String("FILEPATH"))
|
||||
t = CMakeConfigItem::FILEPATH;
|
||||
else if (type == QLatin1String("PATH"))
|
||||
t = CMakeConfigItem::PATH;
|
||||
else if (type == QLatin1String("BOOL"))
|
||||
t = CMakeConfigItem::BOOL;
|
||||
else if (type == QLatin1String("INTERNAL"))
|
||||
t = CMakeConfigItem::INTERNAL;
|
||||
else if (type == QLatin1String("STATIC"))
|
||||
t = CMakeConfigItem::STATIC;
|
||||
|
||||
item.key = key.toUtf8();
|
||||
item.type = t;
|
||||
item.type = CMakeConfigItem::typeStringToType(type.toUtf8());
|
||||
item.value = value.toUtf8();
|
||||
}
|
||||
return item;
|
||||
|
||||
@@ -47,6 +47,7 @@ public:
|
||||
static QString expandedValueOf(const ProjectExplorer::Kit *k, const QByteArray &key,
|
||||
const QList<CMakeConfigItem> &input);
|
||||
static QStringList cmakeSplitValue(const QString &in, bool keepEmpty = false);
|
||||
static Type typeStringToType(const QByteArray &typeString);
|
||||
bool isNull() const { return key.isEmpty(); }
|
||||
|
||||
QString expandedValue(const ProjectExplorer::Kit *k) const;
|
||||
|
||||
@@ -143,20 +143,6 @@ static QByteArrayList splitCMakeCacheLine(const QByteArray &line) {
|
||||
<< line.mid(equalPos + 1);
|
||||
}
|
||||
|
||||
static CMakeConfigItem::Type fromByteArray(const QByteArray &type) {
|
||||
if (type == "BOOL")
|
||||
return CMakeConfigItem::BOOL;
|
||||
if (type == "STRING")
|
||||
return CMakeConfigItem::STRING;
|
||||
if (type == "FILEPATH")
|
||||
return CMakeConfigItem::FILEPATH;
|
||||
if (type == "PATH")
|
||||
return CMakeConfigItem::PATH;
|
||||
QTC_CHECK(type == "INTERNAL" || type == "STATIC");
|
||||
|
||||
return CMakeConfigItem::INTERNAL;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// TeaLeafReader:
|
||||
// --------------------------------------------------------------------
|
||||
@@ -305,10 +291,10 @@ CMakeConfig TeaLeafReader::parseConfiguration(const Utils::FileName &cacheFile,
|
||||
|
||||
if (key.endsWith("-ADVANCED") && value == "1") {
|
||||
advancedSet.insert(key.left(key.count() - 9 /* "-ADVANCED" */));
|
||||
} else if (key.endsWith("-STRINGS") && fromByteArray(type) == CMakeConfigItem::INTERNAL) {
|
||||
} else if (key.endsWith("-STRINGS") && CMakeConfigItem::typeStringToType(type) == CMakeConfigItem::INTERNAL) {
|
||||
valuesMap[key.left(key.count() - 8) /* "-STRINGS" */] = value;
|
||||
} else {
|
||||
CMakeConfigItem::Type t = fromByteArray(type);
|
||||
CMakeConfigItem::Type t = CMakeConfigItem::typeStringToType(type);
|
||||
result << CMakeConfigItem(key, t, documentation, value);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user