Commit e3c1e7ad authored by Tobias Hunger's avatar Tobias Hunger
Browse files

CMake: Unify mapping of type strings to CMakeConfigItem::Type



Change-Id: I29b905aac8965039369891e6aad7e356fa1dad8f
Reviewed-by: Tim Jenssen's avatarTim Jenssen <tim.jenssen@qt.io>
parent 4c1a7515
......@@ -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);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment