forked from qt-creator/qt-creator
SdkTool: Use slightly less repetitive approach for operation interface
Change-Id: I4d1d205c610df39be6a810dfda3049ae14a06806 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -97,7 +97,7 @@ int AddAbiFlavor::execute() const
|
|||||||
if (map.isEmpty())
|
if (map.isEmpty())
|
||||||
map = initializeAbiFlavors();
|
map = initializeAbiFlavors();
|
||||||
|
|
||||||
QVariantMap result = addAbiFlavor(map, m_oses, m_flavor);
|
QVariantMap result = addAbiFlavor(map);
|
||||||
|
|
||||||
if (result.isEmpty() || result == map)
|
if (result.isEmpty() || result == map)
|
||||||
return 2;
|
return 2;
|
||||||
@@ -113,7 +113,7 @@ bool AddAbiFlavor::test() const
|
|||||||
|| !map.contains(QLatin1String(VERSION)))
|
|| !map.contains(QLatin1String(VERSION)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
map = addAbiFlavor(map, {"linux", "windows"}, "foo");
|
map = AddAbiFlavorData{{"linux", "windows"}, "foo"}.addAbiFlavor(map);
|
||||||
|
|
||||||
if (map.count() != 2
|
if (map.count() != 2
|
||||||
|| !map.contains(QLatin1String(VERSION))
|
|| !map.contains(QLatin1String(VERSION))
|
||||||
@@ -126,7 +126,7 @@ bool AddAbiFlavor::test() const
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Ignore known flavors:
|
// Ignore known flavors:
|
||||||
const QVariantMap result = addAbiFlavor(map, {"linux"}, "foo");
|
const QVariantMap result = AddAbiFlavorData({{"linux"}, "foo"}).addAbiFlavor(map);;
|
||||||
|
|
||||||
if (map != result)
|
if (map != result)
|
||||||
return false;
|
return false;
|
||||||
@@ -135,37 +135,35 @@ bool AddAbiFlavor::test() const
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QVariantMap AddAbiFlavor::addAbiFlavor(const QVariantMap &map,
|
QVariantMap AddAbiFlavorData::addAbiFlavor(const QVariantMap &map) const
|
||||||
const QStringList &oses,
|
|
||||||
const QString &flavor)
|
|
||||||
{
|
{
|
||||||
// Sanity check: Is flavor already set in abi file?
|
// Sanity check: Is flavor already set in abi file?
|
||||||
if (exists(map, flavor)) {
|
if (exists(map, m_flavor)) {
|
||||||
std::cerr << "Error: flavor " << qPrintable(flavor) << " already defined as extra ABI flavor." << std::endl;
|
std::cerr << "Error: flavor " << qPrintable(m_flavor) << " already defined as extra ABI flavor." << std::endl;
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariantMap result = map;
|
QVariantMap result = map;
|
||||||
QVariantMap flavorMap = map.value(QLatin1String(FLAVORS)).toMap();
|
QVariantMap flavorMap = map.value(QLatin1String(FLAVORS)).toMap();
|
||||||
flavorMap.insert(flavor, oses);
|
flavorMap.insert(m_flavor, m_oses);
|
||||||
result.insert(QLatin1String(FLAVORS), flavorMap);
|
result.insert(QLatin1String(FLAVORS), flavorMap);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariantMap AddAbiFlavor::initializeAbiFlavors()
|
QVariantMap AddAbiFlavorData::initializeAbiFlavors()
|
||||||
{
|
{
|
||||||
QVariantMap map;
|
QVariantMap map;
|
||||||
map.insert(QLatin1String(VERSION), 1);
|
map.insert(QLatin1String(VERSION), 1);
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AddAbiFlavor::exists(const QString &flavor)
|
bool AddAbiFlavorData::exists(const QString &flavor)
|
||||||
{
|
{
|
||||||
QVariantMap map = load(QLatin1String(ABI_FILE_ID));
|
QVariantMap map = Operation::load(QLatin1String(ABI_FILE_ID));
|
||||||
return exists(map, flavor);
|
return exists(map, flavor);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AddAbiFlavor::exists(const QVariantMap &map, const QString &flavor)
|
bool AddAbiFlavorData::exists(const QVariantMap &map, const QString &flavor)
|
||||||
{
|
{
|
||||||
const QVariantMap flavorMap = map.value(QLatin1String(FLAVORS)).toMap();
|
const QVariantMap flavorMap = map.value(QLatin1String(FLAVORS)).toMap();
|
||||||
return flavorMap.contains(flavor);
|
return flavorMap.contains(flavor);
|
||||||
|
@@ -27,32 +27,32 @@
|
|||||||
|
|
||||||
#include "operation.h"
|
#include "operation.h"
|
||||||
|
|
||||||
#include <QString>
|
class AddAbiFlavorData
|
||||||
|
|
||||||
class AddAbiFlavor : public Operation
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QString name() const;
|
QVariantMap addAbiFlavor(const QVariantMap &map) const;
|
||||||
QString helpText() const;
|
|
||||||
QString argumentsHelpText() const;
|
|
||||||
|
|
||||||
bool setArguments(const QStringList &args);
|
|
||||||
|
|
||||||
int execute() const;
|
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
|
||||||
bool test() const;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static QVariantMap addAbiFlavor(const QVariantMap &map,
|
|
||||||
const QStringList &oses, const QString &flavor);
|
|
||||||
|
|
||||||
static QVariantMap initializeAbiFlavors();
|
static QVariantMap initializeAbiFlavors();
|
||||||
|
|
||||||
static bool exists(const QString &flavor);
|
static bool exists(const QString &flavor);
|
||||||
static bool exists(const QVariantMap &map, const QString &flavor);
|
static bool exists(const QVariantMap &map, const QString &flavor);
|
||||||
|
|
||||||
private:
|
|
||||||
QStringList m_oses;
|
QStringList m_oses;
|
||||||
QString m_flavor;
|
QString m_flavor;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class AddAbiFlavor : public Operation, public AddAbiFlavorData
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
QString name() const final;
|
||||||
|
QString helpText() const final;
|
||||||
|
QString argumentsHelpText() const final;
|
||||||
|
|
||||||
|
bool setArguments(const QStringList &args) final;
|
||||||
|
|
||||||
|
int execute() const final;
|
||||||
|
|
||||||
|
#ifdef WITH_TESTS
|
||||||
|
bool test() const final;
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
@@ -122,7 +122,7 @@ int AddCMakeOperation::execute() const
|
|||||||
if (map.isEmpty())
|
if (map.isEmpty())
|
||||||
map = initializeCMake();
|
map = initializeCMake();
|
||||||
|
|
||||||
QVariantMap result = addCMake(map, m_id, m_displayName, m_path, m_extra);
|
QVariantMap result = addCMake(map);
|
||||||
if (result.isEmpty() || map == result)
|
if (result.isEmpty() || map == result)
|
||||||
return 2;
|
return 2;
|
||||||
|
|
||||||
@@ -135,8 +135,7 @@ bool AddCMakeOperation::test() const
|
|||||||
QVariantMap map = initializeCMake();
|
QVariantMap map = initializeCMake();
|
||||||
|
|
||||||
// Add toolchain:
|
// Add toolchain:
|
||||||
map = addCMake(map, "testId", "name", "/tmp/test",
|
map = AddCMakeData{"testId", "name", "/tmp/test", {{"ExtraKey", QVariant("ExtraValue")}}}.addCMake(map);
|
||||||
KeyValuePairList() << KeyValuePair("ExtraKey", QVariant("ExtraValue")));
|
|
||||||
if (map.value(COUNT).toInt() != 1
|
if (map.value(COUNT).toInt() != 1
|
||||||
|| !map.contains(QString::fromLatin1(PREFIX) + '0'))
|
|| !map.contains(QString::fromLatin1(PREFIX) + '0'))
|
||||||
return false;
|
return false;
|
||||||
@@ -150,14 +149,14 @@ bool AddCMakeOperation::test() const
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Ignore same Id:
|
// Ignore same Id:
|
||||||
QVariantMap unchanged = addCMake(map, "testId", "name2", "/tmp/test2",
|
QVariantMap unchanged = AddCMakeData{"testId", "name2", "/tmp/test2", {{"ExtraKey", QVariant("ExtraValue2")}}}
|
||||||
KeyValuePairList() << KeyValuePair("ExtraKey", QVariant("ExtraValue2")));
|
.addCMake(map);
|
||||||
if (!unchanged.isEmpty())
|
if (!unchanged.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// add 2nd cmake
|
// add 2nd cmake
|
||||||
map = addCMake(map, "{some-cm-id}", "name", "/tmp/test",
|
map = AddCMakeData{"{some-cm-id}", "name", "/tmp/test", {{"ExtraKey", QVariant("ExtraValue")}}}
|
||||||
KeyValuePairList() << KeyValuePair("ExtraKey", QVariant("ExtraValue")));
|
.addCMake(map);
|
||||||
if (map.value(COUNT).toInt() != 2
|
if (map.value(COUNT).toInt() != 2
|
||||||
|| !map.contains(QString::fromLatin1(PREFIX) + '0')
|
|| !map.contains(QString::fromLatin1(PREFIX) + '0')
|
||||||
|| !map.contains(QString::fromLatin1(PREFIX) + '1'))
|
|| !map.contains(QString::fromLatin1(PREFIX) + '1'))
|
||||||
@@ -183,13 +182,11 @@ bool AddCMakeOperation::test() const
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QVariantMap AddCMakeOperation::addCMake(const QVariantMap &map, const QString &id,
|
QVariantMap AddCMakeData::addCMake(const QVariantMap &map) const
|
||||||
const QString &displayName, const QString &path,
|
|
||||||
const KeyValuePairList &extra)
|
|
||||||
{
|
{
|
||||||
// Sanity check: Does the Id already exist?
|
// Sanity check: Does the Id already exist?
|
||||||
if (exists(map, id)) {
|
if (exists(map, m_id)) {
|
||||||
std::cerr << "Error: Id " << qPrintable(id) << " already defined for tool chains." << std::endl;
|
std::cerr << "Error: Id " << qPrintable(m_id) << " already defined for tool chains." << std::endl;
|
||||||
return QVariantMap();
|
return QVariantMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -206,20 +203,20 @@ QVariantMap AddCMakeOperation::addCMake(const QVariantMap &map, const QString &i
|
|||||||
const QString cm = QString::fromLatin1(PREFIX) + QString::number(count);
|
const QString cm = QString::fromLatin1(PREFIX) + QString::number(count);
|
||||||
|
|
||||||
KeyValuePairList data;
|
KeyValuePairList data;
|
||||||
data << KeyValuePair({cm, ID_KEY}, QVariant(id));
|
data << KeyValuePair({cm, ID_KEY}, QVariant(m_id));
|
||||||
data << KeyValuePair({cm, DISPLAYNAME_KEY}, QVariant(displayName));
|
data << KeyValuePair({cm, DISPLAYNAME_KEY}, QVariant(m_displayName));
|
||||||
data << KeyValuePair({cm, AUTODETECTED_KEY}, QVariant(true));
|
data << KeyValuePair({cm, AUTODETECTED_KEY}, QVariant(true));
|
||||||
data << KeyValuePair({cm, PATH_KEY}, Utils::FilePath::fromUserInput(path).toVariant());
|
data << KeyValuePair({cm, PATH_KEY}, Utils::FilePath::fromUserInput(m_path).toVariant());
|
||||||
KeyValuePairList extraList;
|
KeyValuePairList extraList;
|
||||||
foreach (const KeyValuePair &pair, extra)
|
foreach (const KeyValuePair &pair, m_extra)
|
||||||
extraList << KeyValuePair(QStringList({cm}) << pair.key, pair.value);
|
extraList << KeyValuePair(QStringList({cm}) << pair.key, pair.value);
|
||||||
data.append(extraList);
|
data.append(extraList);
|
||||||
data << KeyValuePair(COUNT, QVariant(count + 1));
|
data << KeyValuePair(COUNT, QVariant(count + 1));
|
||||||
|
|
||||||
return AddKeysOperation::addKeys(result, data);
|
return AddKeysData{data}.addKeys(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariantMap AddCMakeOperation::initializeCMake()
|
QVariantMap AddCMakeData::initializeCMake()
|
||||||
{
|
{
|
||||||
QVariantMap map;
|
QVariantMap map;
|
||||||
map.insert(COUNT, 0);
|
map.insert(COUNT, 0);
|
||||||
@@ -227,7 +224,7 @@ QVariantMap AddCMakeOperation::initializeCMake()
|
|||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AddCMakeOperation::exists(const QVariantMap &map, const QString &id)
|
bool AddCMakeData::exists(const QVariantMap &map, const QString &id)
|
||||||
{
|
{
|
||||||
QStringList valueKeys = FindValueOperation::findValue(map, id);
|
QStringList valueKeys = FindValueOperation::findValue(map, id);
|
||||||
// support old settings using QByteArray for id's
|
// support old settings using QByteArray for id's
|
||||||
@@ -241,7 +238,7 @@ bool AddCMakeOperation::exists(const QVariantMap &map, const QString &id)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AddCMakeOperation::exists(const QString &id)
|
bool AddCMakeData::exists(const QString &id)
|
||||||
{
|
{
|
||||||
QVariantMap map = Operation::load("cmaketools");
|
QVariantMap map = Operation::load("cmaketools");
|
||||||
return exists(map, id);
|
return exists(map, id);
|
||||||
|
@@ -27,34 +27,34 @@
|
|||||||
|
|
||||||
#include "operation.h"
|
#include "operation.h"
|
||||||
|
|
||||||
#include <QString>
|
class AddCMakeData
|
||||||
|
|
||||||
class AddCMakeOperation : public Operation
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QString name() const;
|
QVariantMap addCMake(const QVariantMap &map) const;
|
||||||
QString helpText() const;
|
|
||||||
QString argumentsHelpText() const;
|
|
||||||
|
|
||||||
bool setArguments(const QStringList &args);
|
|
||||||
|
|
||||||
int execute() const;
|
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
|
||||||
bool test() const;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static QVariantMap addCMake(const QVariantMap &map, const QString &id,
|
|
||||||
const QString &displayName, const QString &path,
|
|
||||||
const KeyValuePairList &extra);
|
|
||||||
|
|
||||||
static QVariantMap initializeCMake();
|
static QVariantMap initializeCMake();
|
||||||
|
|
||||||
static bool exists(const QString &id);
|
static bool exists(const QString &id);
|
||||||
static bool exists(const QVariantMap &map, const QString &id);
|
static bool exists(const QVariantMap &map, const QString &id);
|
||||||
|
|
||||||
private:
|
|
||||||
QString m_id;
|
QString m_id;
|
||||||
QString m_displayName;
|
QString m_displayName;
|
||||||
QString m_path;
|
QString m_path;
|
||||||
KeyValuePairList m_extra;
|
KeyValuePairList m_extra;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class AddCMakeOperation : public Operation, public AddCMakeData
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
QString name() const final;
|
||||||
|
QString helpText() const final;
|
||||||
|
QString argumentsHelpText() const final;
|
||||||
|
|
||||||
|
bool setArguments(const QStringList &args) final;
|
||||||
|
|
||||||
|
int execute() const final;
|
||||||
|
|
||||||
|
#ifdef WITH_TESTS
|
||||||
|
bool test() const final;
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
@@ -144,8 +144,7 @@ int AddDebuggerOperation::execute() const
|
|||||||
if (map.isEmpty())
|
if (map.isEmpty())
|
||||||
map = initializeDebuggers();
|
map = initializeDebuggers();
|
||||||
|
|
||||||
QVariantMap result = addDebugger(map, m_id, m_displayName, m_engine, m_binary, m_abis,
|
QVariantMap result = addDebugger(map);
|
||||||
m_extra);
|
|
||||||
|
|
||||||
if (result.isEmpty() || map == result)
|
if (result.isEmpty() || map == result)
|
||||||
return 2;
|
return 2;
|
||||||
@@ -169,13 +168,10 @@ bool AddDebuggerOperation::test() const
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QVariantMap AddDebuggerOperation::addDebugger(const QVariantMap &map,
|
QVariantMap AddDebuggerData::addDebugger(const QVariantMap &map) const
|
||||||
const QString &id, const QString &displayName,
|
|
||||||
int engine, const QString &binary,
|
|
||||||
const QStringList &abis, const KeyValuePairList &extra)
|
|
||||||
{
|
{
|
||||||
// Sanity check: Make sure autodetection source is not in use already:
|
// Sanity check: Make sure autodetection source is not in use already:
|
||||||
QStringList valueKeys = FindValueOperation::findValue(map, QVariant(id));
|
QStringList valueKeys = FindValueOperation::findValue(map, QVariant(m_id));
|
||||||
bool hasId = false;
|
bool hasId = false;
|
||||||
foreach (const QString &k, valueKeys) {
|
foreach (const QString &k, valueKeys) {
|
||||||
if (k.endsWith(QString(QLatin1Char('/')) + QLatin1String(ID))) {
|
if (k.endsWith(QString(QLatin1Char('/')) + QLatin1String(ID))) {
|
||||||
@@ -184,7 +180,7 @@ QVariantMap AddDebuggerOperation::addDebugger(const QVariantMap &map,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (hasId) {
|
if (hasId) {
|
||||||
std::cerr << "Error: Id " << qPrintable(id) << " already defined as debugger." << std::endl;
|
std::cerr << "Error: Id " << qPrintable(m_id) << " already defined as debugger." << std::endl;
|
||||||
return QVariantMap();
|
return QVariantMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -204,27 +200,27 @@ QVariantMap AddDebuggerOperation::addDebugger(const QVariantMap &map,
|
|||||||
|
|
||||||
// insert data:
|
// insert data:
|
||||||
KeyValuePairList data;
|
KeyValuePairList data;
|
||||||
data << KeyValuePair(QStringList() << debugger << QLatin1String(ID), QVariant(id));
|
data << KeyValuePair(QStringList() << debugger << QLatin1String(ID), QVariant(m_id));
|
||||||
data << KeyValuePair(QStringList() << debugger << QLatin1String(DISPLAYNAME),
|
data << KeyValuePair(QStringList() << debugger << QLatin1String(DISPLAYNAME),
|
||||||
QVariant(displayName));
|
QVariant(m_displayName));
|
||||||
data << KeyValuePair(QStringList() << debugger << QLatin1String(AUTODETECTED), QVariant(true));
|
data << KeyValuePair(QStringList() << debugger << QLatin1String(AUTODETECTED), QVariant(true));
|
||||||
|
|
||||||
data << KeyValuePair(QStringList() << debugger << QLatin1String(ABIS), QVariant(abis));
|
data << KeyValuePair(QStringList() << debugger << QLatin1String(ABIS), QVariant(m_abis));
|
||||||
data << KeyValuePair(QStringList() << debugger << QLatin1String(ENGINE_TYPE), QVariant(engine));
|
data << KeyValuePair(QStringList() << debugger << QLatin1String(ENGINE_TYPE), QVariant(m_engine));
|
||||||
data << KeyValuePair(QStringList() << debugger << QLatin1String(BINARY),
|
data << KeyValuePair(QStringList() << debugger << QLatin1String(BINARY),
|
||||||
Utils::FilePath::fromUserInput(binary).toVariant());
|
Utils::FilePath::fromUserInput(m_binary).toVariant());
|
||||||
|
|
||||||
data << KeyValuePair(QStringList() << QLatin1String(COUNT), QVariant(count + 1));
|
data << KeyValuePair(QStringList() << QLatin1String(COUNT), QVariant(count + 1));
|
||||||
|
|
||||||
KeyValuePairList qtExtraList;
|
KeyValuePairList qtExtraList;
|
||||||
foreach (const KeyValuePair &pair, extra)
|
foreach (const KeyValuePair &pair, m_extra)
|
||||||
qtExtraList << KeyValuePair(QStringList() << debugger << pair.key, pair.value);
|
qtExtraList << KeyValuePair(QStringList() << debugger << pair.key, pair.value);
|
||||||
data.append(qtExtraList);
|
data.append(qtExtraList);
|
||||||
|
|
||||||
return AddKeysOperation::addKeys(cleaned, data);
|
return AddKeysData{data}.addKeys(cleaned);
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariantMap AddDebuggerOperation::initializeDebuggers()
|
QVariantMap AddDebuggerData::initializeDebuggers()
|
||||||
{
|
{
|
||||||
QVariantMap map;
|
QVariantMap map;
|
||||||
map.insert(QLatin1String(VERSION), 1);
|
map.insert(QLatin1String(VERSION), 1);
|
||||||
|
@@ -27,31 +27,13 @@
|
|||||||
|
|
||||||
#include "operation.h"
|
#include "operation.h"
|
||||||
|
|
||||||
#include <QString>
|
class AddDebuggerData
|
||||||
|
|
||||||
class AddDebuggerOperation : public Operation
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QString name() const;
|
QVariantMap addDebugger(const QVariantMap &map) const;
|
||||||
QString helpText() const;
|
|
||||||
QString argumentsHelpText() const;
|
|
||||||
|
|
||||||
bool setArguments(const QStringList &args);
|
|
||||||
|
|
||||||
int execute() const;
|
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
|
||||||
bool test() const;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static QVariantMap addDebugger(const QVariantMap &map,
|
|
||||||
const QString &id, const QString &displayName,
|
|
||||||
int engine, const QString &binary,
|
|
||||||
const QStringList &abis, const KeyValuePairList &extra);
|
|
||||||
|
|
||||||
static QVariantMap initializeDebuggers();
|
static QVariantMap initializeDebuggers();
|
||||||
|
|
||||||
private:
|
|
||||||
QString m_id;
|
QString m_id;
|
||||||
QString m_displayName;
|
QString m_displayName;
|
||||||
int m_engine = 0;
|
int m_engine = 0;
|
||||||
@@ -59,3 +41,19 @@ private:
|
|||||||
QStringList m_abis;
|
QStringList m_abis;
|
||||||
KeyValuePairList m_extra;
|
KeyValuePairList m_extra;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class AddDebuggerOperation : public Operation, public AddDebuggerData
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
QString name() const final;
|
||||||
|
QString helpText() const final;
|
||||||
|
QString argumentsHelpText() const final;
|
||||||
|
|
||||||
|
bool setArguments(const QStringList &args) final;
|
||||||
|
|
||||||
|
int execute() const final;
|
||||||
|
|
||||||
|
#ifdef WITH_TESTS
|
||||||
|
bool test() const final;
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
@@ -247,10 +247,7 @@ int AddDeviceOperation::execute() const
|
|||||||
if (map.isEmpty())
|
if (map.isEmpty())
|
||||||
map = initializeDevices();
|
map = initializeDevices();
|
||||||
|
|
||||||
QVariantMap result = addDevice(map, m_id, m_displayName, m_type, m_authentication,
|
QVariantMap result = addDevice(map);
|
||||||
m_b2q_platformHardware, m_b2q_platformSoftware, m_debugServer,
|
|
||||||
m_freePortsSpec, m_host, m_keyFile, m_origin, m_osType,
|
|
||||||
m_password, m_sshPort, m_timeout, m_uname, m_version, m_extra);
|
|
||||||
|
|
||||||
if (result.isEmpty() || map == result)
|
if (result.isEmpty() || map == result)
|
||||||
return 2;
|
return 2;
|
||||||
@@ -263,13 +260,15 @@ bool AddDeviceOperation::test() const
|
|||||||
{
|
{
|
||||||
QVariantMap map = initializeDevices();
|
QVariantMap map = initializeDevices();
|
||||||
|
|
||||||
QVariantMap result = addDevice(map, QLatin1String("test id"), QLatin1String("test name"),
|
AddDeviceData devData = {
|
||||||
|
QLatin1String("test id"), QLatin1String("test name"),
|
||||||
1, 2, QLatin1String("HW"), QLatin1String("SW"),
|
1, 2, QLatin1String("HW"), QLatin1String("SW"),
|
||||||
QLatin1String("debugServer"), QLatin1String("ports"),
|
QLatin1String("debugServer"), QLatin1String("ports"),
|
||||||
QLatin1String("host"), QLatin1String("keyfile"), 3,
|
QLatin1String("host"), QLatin1String("keyfile"), 3,
|
||||||
QLatin1String("ostype"), QLatin1String("passwd"), 4, 5,
|
QLatin1String("ostype"), QLatin1String("passwd"), 4, 5,
|
||||||
QLatin1String("uname"), 6, KeyValuePairList());
|
QLatin1String("uname"), 6, KeyValuePairList()
|
||||||
|
};
|
||||||
|
QVariantMap result = devData.addDevice(map);
|
||||||
QVariantMap data = result.value(QLatin1String(DEVICEMANAGER_ID)).toMap();
|
QVariantMap data = result.value(QLatin1String(DEVICEMANAGER_ID)).toMap();
|
||||||
QVariantList devList = data.value(QLatin1String(DEVICE_LIST_ID)).toList();
|
QVariantList devList = data.value(QLatin1String(DEVICE_LIST_ID)).toList();
|
||||||
if (devList.count() != 1)
|
if (devList.count() != 1)
|
||||||
@@ -312,30 +311,38 @@ bool AddDeviceOperation::test() const
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QVariantMap AddDeviceOperation::addDevice(const QVariantMap &map,
|
QVariantMap AddDeviceData::addDevice(const QVariantMap &map) const
|
||||||
const QString &id, const QString &displayName, int type,
|
|
||||||
int auth, const QString &hwPlatform, const QString &swPlatform,
|
|
||||||
const QString &debugServer, const QString &freePorts,
|
|
||||||
const QString &host, const QString &keyFile,
|
|
||||||
int origin, const QString &osType, const QString &passwd,
|
|
||||||
int sshPort, int timeout, const QString &uname, int version,
|
|
||||||
const KeyValuePairList &extra)
|
|
||||||
{
|
{
|
||||||
QVariantMap result = map;
|
QVariantMap result = map;
|
||||||
if (exists(map, id)) {
|
if (exists(map, m_id)) {
|
||||||
std::cerr << "Device " << qPrintable(id) << " already exists!" << std::endl;
|
std::cerr << "Device " << qPrintable(m_id) << " already exists!" << std::endl;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariantMap dmMap = map.value(QLatin1String(DEVICEMANAGER_ID)).toMap();
|
QVariantMap dmMap = map.value(QLatin1String(DEVICEMANAGER_ID)).toMap();
|
||||||
QVariantList devList = dmMap.value(QLatin1String(DEVICE_LIST_ID)).toList();
|
QVariantList devList = dmMap.value(QLatin1String(DEVICE_LIST_ID)).toList();
|
||||||
|
|
||||||
QVariantMap devMap
|
KeyValuePairList dev;
|
||||||
= AddKeysOperation::addKeys(QVariantMap(),
|
dev.append(KeyValuePair(QLatin1String(DEVICE_ID_ID), QVariant(m_id)));
|
||||||
createDevice(id, displayName, type, auth, hwPlatform,
|
dev.append(KeyValuePair(QLatin1String("Name"), QVariant(m_displayName)));
|
||||||
swPlatform, debugServer, freePorts, host,
|
dev.append(KeyValuePair(QLatin1String("Type"), QVariant(m_type)));
|
||||||
keyFile, origin, osType, passwd, sshPort,
|
dev.append(KeyValuePair(QLatin1String("Authentication"), QVariant(m_authentication)));
|
||||||
timeout, uname, version, extra));
|
dev.append(KeyValuePair(QLatin1String("Boot2Qt.PlatformInfoHardware"), QVariant(m_b2q_platformHardware)));
|
||||||
|
dev.append(KeyValuePair(QLatin1String("Boot2Qt.PlatformInfoSoftware"), QVariant(m_b2q_platformSoftware)));
|
||||||
|
dev.append(KeyValuePair(QLatin1String("DebugServerKey"), QVariant(m_debugServer)));
|
||||||
|
dev.append(KeyValuePair(QLatin1String("FreePortsSpec"), QVariant(m_freePortsSpec)));
|
||||||
|
dev.append(KeyValuePair(QLatin1String("Host"), QVariant(m_host)));
|
||||||
|
dev.append(KeyValuePair(QLatin1String("KeyFile"), QVariant(m_keyFile)));
|
||||||
|
dev.append(KeyValuePair(QLatin1String("Origin"), QVariant(m_origin)));
|
||||||
|
dev.append(KeyValuePair(QLatin1String("OsType"), QVariant(m_osType)));
|
||||||
|
dev.append(KeyValuePair(QLatin1String("Password"), QVariant(m_password)));
|
||||||
|
dev.append(KeyValuePair(QLatin1String("SshPort"), QVariant(m_sshPort)));
|
||||||
|
dev.append(KeyValuePair(QLatin1String("Timeout"), QVariant(m_timeout)));
|
||||||
|
dev.append(KeyValuePair(QLatin1String("Uname"), QVariant(m_uname)));
|
||||||
|
dev.append(KeyValuePair(QLatin1String("Version"), QVariant(m_version)));
|
||||||
|
dev.append(m_extra);
|
||||||
|
|
||||||
|
QVariantMap devMap = AddKeysData{dev}.addKeys(QVariantMap());
|
||||||
|
|
||||||
devList.append(devMap);
|
devList.append(devMap);
|
||||||
|
|
||||||
@@ -346,7 +353,7 @@ QVariantMap AddDeviceOperation::addDevice(const QVariantMap &map,
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariantMap AddDeviceOperation::initializeDevices()
|
QVariantMap AddDeviceData::initializeDevices()
|
||||||
{
|
{
|
||||||
QVariantMap dmData;
|
QVariantMap dmData;
|
||||||
dmData.insert(QLatin1String(DEFAULT_DEVICES_ID), QVariantMap());
|
dmData.insert(QLatin1String(DEFAULT_DEVICES_ID), QVariantMap());
|
||||||
@@ -357,13 +364,13 @@ QVariantMap AddDeviceOperation::initializeDevices()
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AddDeviceOperation::exists(const QString &id)
|
bool AddDeviceData::exists(const QString &id)
|
||||||
{
|
{
|
||||||
QVariantMap map = load(QLatin1String("Devices"));
|
QVariantMap map = Operation::load(QLatin1String("Devices"));
|
||||||
return exists(map, id);
|
return exists(map, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AddDeviceOperation::exists(const QVariantMap &map, const QString &id)
|
bool AddDeviceData::exists(const QVariantMap &map, const QString &id)
|
||||||
{
|
{
|
||||||
if (id == QLatin1String(INTERNAL_DSEKTOP_DEVICE_ID))
|
if (id == QLatin1String(INTERNAL_DSEKTOP_DEVICE_ID))
|
||||||
return true;
|
return true;
|
||||||
@@ -377,37 +384,3 @@ bool AddDeviceOperation::exists(const QVariantMap &map, const QString &id)
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Operation::KeyValuePairList AddDeviceOperation::createDevice(const QString &id, const QString &displayName,
|
|
||||||
int type, int auth, const QString &hwPlatform,
|
|
||||||
const QString &swPlatform, const QString &debugServer,
|
|
||||||
const QString &freePorts, const QString &host,
|
|
||||||
const QString &keyFile, int origin,
|
|
||||||
const QString &osType, const QString &passwd,
|
|
||||||
int sshPort, int timeout, const QString &uname,
|
|
||||||
int version, const Operation::KeyValuePairList &extra)
|
|
||||||
{
|
|
||||||
Operation::KeyValuePairList dev;
|
|
||||||
dev.append(KeyValuePair(QLatin1String(DEVICE_ID_ID), QVariant(id)));
|
|
||||||
dev.append(KeyValuePair(QLatin1String("Name"), QVariant(displayName)));
|
|
||||||
dev.append(KeyValuePair(QLatin1String("Type"), QVariant(type)));
|
|
||||||
|
|
||||||
dev.append(KeyValuePair(QLatin1String("Authentication"), QVariant(auth)));
|
|
||||||
dev.append(KeyValuePair(QLatin1String("Boot2Qt.PlatformInfoHardware"), QVariant(hwPlatform)));
|
|
||||||
dev.append(KeyValuePair(QLatin1String("Boot2Qt.PlatformInfoSoftware"), QVariant(swPlatform)));
|
|
||||||
dev.append(KeyValuePair(QLatin1String("DebugServerKey"), QVariant(debugServer)));
|
|
||||||
dev.append(KeyValuePair(QLatin1String("FreePortsSpec"), QVariant(freePorts)));
|
|
||||||
dev.append(KeyValuePair(QLatin1String("Host"), QVariant(host)));
|
|
||||||
dev.append(KeyValuePair(QLatin1String("KeyFile"), QVariant(keyFile)));
|
|
||||||
dev.append(KeyValuePair(QLatin1String("Origin"), QVariant(origin)));
|
|
||||||
dev.append(KeyValuePair(QLatin1String("OsType"), QVariant(osType)));
|
|
||||||
dev.append(KeyValuePair(QLatin1String("Password"), QVariant(passwd)));
|
|
||||||
dev.append(KeyValuePair(QLatin1String("SshPort"), QVariant(sshPort)));
|
|
||||||
dev.append(KeyValuePair(QLatin1String("Timeout"), QVariant(timeout)));
|
|
||||||
dev.append(KeyValuePair(QLatin1String("Uname"), QVariant(uname)));
|
|
||||||
dev.append(KeyValuePair(QLatin1String("Version"), QVariant(version)));
|
|
||||||
|
|
||||||
dev.append(extra);
|
|
||||||
|
|
||||||
return dev;
|
|
||||||
}
|
|
||||||
|
@@ -35,60 +35,48 @@ extern const char DEVICE_LIST_ID[];
|
|||||||
|
|
||||||
extern const char DEVICE_ID_ID[];
|
extern const char DEVICE_ID_ID[];
|
||||||
|
|
||||||
class AddDeviceOperation : public Operation
|
class AddDeviceData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QString name() const;
|
QVariantMap addDevice(const QVariantMap &map) const;
|
||||||
QString helpText() const;
|
|
||||||
QString argumentsHelpText() const;
|
|
||||||
|
|
||||||
bool setArguments(const QStringList &args);
|
|
||||||
|
|
||||||
int execute() const;
|
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
|
||||||
bool test() const;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static QVariantMap addDevice(const QVariantMap &map,
|
|
||||||
const QString &id, const QString &displayName, int type,
|
|
||||||
int auth, const QString &hwPlatform, const QString &swPlatform,
|
|
||||||
const QString &debugServer, const QString &freePorts,
|
|
||||||
const QString &host, const QString &keyFile,
|
|
||||||
int origin, const QString &osType, const QString &passwd,
|
|
||||||
int sshPort, int timeout, const QString &uname, int version,
|
|
||||||
const KeyValuePairList &extra);
|
|
||||||
|
|
||||||
static QVariantMap initializeDevices();
|
static QVariantMap initializeDevices();
|
||||||
|
|
||||||
static bool exists(const QString &id);
|
static bool exists(const QString &id);
|
||||||
static bool exists(const QVariantMap &map, const QString &id);
|
static bool exists(const QVariantMap &map, const QString &id);
|
||||||
|
|
||||||
private:
|
QString m_id;
|
||||||
static KeyValuePairList createDevice(const QString &id, const QString &displayName, int type,
|
QString m_displayName;
|
||||||
int auth, const QString &hwPlatform, const QString &swPlatform,
|
int m_type = -1;
|
||||||
const QString &debugServer, const QString &freePorts,
|
|
||||||
const QString &host, const QString &keyFile,
|
|
||||||
int origin, const QString &osType, const QString &passwd,
|
|
||||||
int sshPort, int timeout, const QString &uname, int version,
|
|
||||||
const KeyValuePairList &extra);
|
|
||||||
|
|
||||||
int m_authentication = -1;
|
int m_authentication = -1;
|
||||||
QString m_b2q_platformHardware;
|
QString m_b2q_platformHardware;
|
||||||
QString m_b2q_platformSoftware;
|
QString m_b2q_platformSoftware;
|
||||||
QString m_debugServer;
|
QString m_debugServer;
|
||||||
QString m_freePortsSpec;
|
QString m_freePortsSpec;
|
||||||
QString m_host;
|
QString m_host;
|
||||||
QString m_id;
|
|
||||||
QString m_keyFile;
|
QString m_keyFile;
|
||||||
QString m_displayName;
|
|
||||||
int m_origin = 1;
|
int m_origin = 1;
|
||||||
QString m_osType;
|
QString m_osType;
|
||||||
QString m_password;
|
QString m_password;
|
||||||
int m_sshPort = 0;
|
int m_sshPort = 0;
|
||||||
int m_timeout = 5;
|
int m_timeout = 5;
|
||||||
int m_type = -1;
|
|
||||||
QString m_uname;
|
QString m_uname;
|
||||||
int m_version = 0;
|
int m_version = 0;
|
||||||
KeyValuePairList m_extra;
|
KeyValuePairList m_extra;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class AddDeviceOperation : public Operation, public AddDeviceData
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
QString name() const final;
|
||||||
|
QString helpText() const final;
|
||||||
|
QString argumentsHelpText() const final;
|
||||||
|
|
||||||
|
bool setArguments(const QStringList &args) final;
|
||||||
|
|
||||||
|
int execute() const final;
|
||||||
|
|
||||||
|
#ifdef WITH_TESTS
|
||||||
|
bool test() const final;
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
@@ -76,7 +76,7 @@ int AddKeysOperation::execute() const
|
|||||||
|
|
||||||
QVariantMap map = load(m_file);
|
QVariantMap map = load(m_file);
|
||||||
|
|
||||||
QVariantMap result = addKeys(map, m_data);
|
QVariantMap result = addKeys(map);
|
||||||
if (result.isEmpty() || map == result)
|
if (result.isEmpty() || map == result)
|
||||||
return 4;
|
return 4;
|
||||||
|
|
||||||
@@ -108,7 +108,7 @@ bool AddKeysOperation::test() const
|
|||||||
data.append(KeyValuePair(QLatin1String("newsub/1/2/3/qbytearray"), QString::fromLatin1("QByteArray:test array.")));
|
data.append(KeyValuePair(QLatin1String("newsub/1/2/3/qbytearray"), QString::fromLatin1("QByteArray:test array.")));
|
||||||
data.append(KeyValuePair(QLatin1String("newsub/1/2.1/3/qbytearray"), QString::fromLatin1("QByteArray:test array.")));
|
data.append(KeyValuePair(QLatin1String("newsub/1/2.1/3/qbytearray"), QString::fromLatin1("QByteArray:test array.")));
|
||||||
|
|
||||||
QVariantMap result = addKeys(testMap, data);
|
QVariantMap result = AddKeysData{data}.addKeys(testMap);
|
||||||
if (result.count() != 9)
|
if (result.count() != 9)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -194,13 +194,13 @@ bool AddKeysOperation::test() const
|
|||||||
// preexisting:
|
// preexisting:
|
||||||
data.clear();
|
data.clear();
|
||||||
data.append(KeyValuePair(QLatin1String("testint"), QString::fromLatin1("int:4")));
|
data.append(KeyValuePair(QLatin1String("testint"), QString::fromLatin1("int:4")));
|
||||||
result = addKeys(testMap, data);
|
result = AddKeysData{data}.addKeys(testMap);
|
||||||
if (!result.isEmpty())
|
if (!result.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
data.clear();
|
data.clear();
|
||||||
data.append(KeyValuePair(QLatin1String("subkeys/testbool"), QString::fromLatin1("int:24")));
|
data.append(KeyValuePair(QLatin1String("subkeys/testbool"), QString::fromLatin1("int:24")));
|
||||||
result = addKeys(testMap, data);
|
result = AddKeysData{data}.addKeys(testMap);
|
||||||
if (!result.isEmpty())
|
if (!result.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -208,7 +208,7 @@ bool AddKeysOperation::test() const
|
|||||||
data.clear();
|
data.clear();
|
||||||
data.append(KeyValuePair(QLatin1String("bool-true"), QString::fromLatin1("bool:trUe")));
|
data.append(KeyValuePair(QLatin1String("bool-true"), QString::fromLatin1("bool:trUe")));
|
||||||
data.append(KeyValuePair(QLatin1String("bool-true"), QString::fromLatin1("bool:trUe")));
|
data.append(KeyValuePair(QLatin1String("bool-true"), QString::fromLatin1("bool:trUe")));
|
||||||
result = addKeys(testMap, data);
|
result = AddKeysData{data}.addKeys(testMap);
|
||||||
if (!result.isEmpty())
|
if (!result.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -216,12 +216,12 @@ bool AddKeysOperation::test() const
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QVariantMap AddKeysOperation::addKeys(const QVariantMap &map, const KeyValuePairList &additions)
|
QVariantMap AddKeysData::addKeys(const QVariantMap &map) const
|
||||||
{
|
{
|
||||||
// Insert data:
|
// Insert data:
|
||||||
QVariantMap result = map;
|
QVariantMap result = map;
|
||||||
|
|
||||||
foreach (const KeyValuePair &p, additions) {
|
foreach (const KeyValuePair &p, m_data) {
|
||||||
QList<QVariantMap> stack;
|
QList<QVariantMap> stack;
|
||||||
|
|
||||||
// Set up a stack of QVariantMaps along the path we take:
|
// Set up a stack of QVariantMaps along the path we take:
|
||||||
|
@@ -27,25 +27,29 @@
|
|||||||
|
|
||||||
#include "operation.h"
|
#include "operation.h"
|
||||||
|
|
||||||
class AddKeysOperation : public Operation
|
class AddKeysData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QString name() const;
|
QVariantMap addKeys(const QVariantMap &map) const;
|
||||||
QString helpText() const;
|
|
||||||
QString argumentsHelpText() const;
|
|
||||||
|
|
||||||
bool setArguments(const QStringList &args);
|
|
||||||
|
|
||||||
int execute() const;
|
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
|
||||||
bool test() const;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static QVariantMap addKeys(const QVariantMap &map, const KeyValuePairList &additions);
|
|
||||||
|
|
||||||
private:
|
|
||||||
QString m_file;
|
|
||||||
|
|
||||||
QList<KeyValuePair> m_data;
|
QList<KeyValuePair> m_data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class AddKeysOperation : public Operation, public AddKeysData
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
QString name() const final;
|
||||||
|
QString helpText() const final;
|
||||||
|
QString argumentsHelpText() const final;
|
||||||
|
|
||||||
|
bool setArguments(const QStringList &args) final;
|
||||||
|
|
||||||
|
int execute() const final;
|
||||||
|
|
||||||
|
#ifdef WITH_TESTS
|
||||||
|
bool test() const final;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString m_file;
|
||||||
|
};
|
||||||
|
@@ -293,12 +293,7 @@ int AddKitOperation::execute() const
|
|||||||
if (map.isEmpty())
|
if (map.isEmpty())
|
||||||
map = initializeKits();
|
map = initializeKits();
|
||||||
|
|
||||||
QVariantMap result = addKit(map, m_id, m_displayName, m_icon, m_debuggerId, m_debuggerEngine,
|
const QVariantMap result = addKit(map);
|
||||||
m_debugger, m_deviceType, m_device, m_sysRoot, m_tcs, m_qt,
|
|
||||||
m_mkspec, m_cmakeId, m_cmakeGenerator, m_cmakeExtraGenerator,
|
|
||||||
m_cmakeGeneratorToolset, m_cmakeGeneratorPlatform, m_cmakeConfiguration,
|
|
||||||
m_env, m_extra);
|
|
||||||
|
|
||||||
if (result.isEmpty() || map == result)
|
if (result.isEmpty() || map == result)
|
||||||
return 2;
|
return 2;
|
||||||
|
|
||||||
@@ -308,26 +303,26 @@ int AddKitOperation::execute() const
|
|||||||
#ifdef WITH_TESTS
|
#ifdef WITH_TESTS
|
||||||
bool AddKitOperation::test() const
|
bool AddKitOperation::test() const
|
||||||
{
|
{
|
||||||
|
AddKitData kitData;
|
||||||
QVariantMap map = initializeKits();
|
QVariantMap map = initializeKits();
|
||||||
|
|
||||||
QVariantMap tcMap = AddToolChainOperation::initializeToolChains();
|
QVariantMap tcMap = AddToolChainData::initializeToolChains();
|
||||||
tcMap = AddToolChainOperation::addToolChain(tcMap, "{tc-id}", "langId", "TC", "/usr/bin/gcc",
|
tcMap = AddToolChainData{"{tc-id}", "langId", "TC", "/usr/bin/gcc",
|
||||||
"x86-linux-generic-elf-32bit",
|
"x86-linux-generic-elf-32bit", "x86-linux-generic-elf-32bit", {}}
|
||||||
"x86-linux-generic-elf-32bit",
|
.addToolChain(tcMap);
|
||||||
KeyValuePairList());
|
|
||||||
|
|
||||||
QVariantMap qtMap = AddQtOperation::initializeQtVersions();
|
QVariantMap qtMap = AddQtData::initializeQtVersions();
|
||||||
qtMap = AddQtOperation::addQt(qtMap, "{qt-id}", "Qt", "desktop-qt", "/usr/bin/qmake",
|
qtMap = AddQtData{"{qt-id}", "Qt", "desktop-qt", "/usr/bin/qmake", {}, {}}.addQt(qtMap);
|
||||||
KeyValuePairList(), {});
|
|
||||||
|
|
||||||
QVariantMap devMap = AddDeviceOperation::initializeDevices();
|
QVariantMap devMap = AddDeviceOperation::initializeDevices();
|
||||||
devMap = AddDeviceOperation::addDevice(devMap, "{dev-id}", "Dev", 0, 0,
|
devMap = AddDeviceData{"{dev-id}", "Dev", 0, 0,
|
||||||
"HWplatform", "SWplatform",
|
"HWplatform", "SWplatform",
|
||||||
"localhost", "10000-11000",
|
"localhost", "10000-11000",
|
||||||
"localhost", "", 42,
|
"localhost", "", 42,
|
||||||
"desktop", "", 22, 10000,
|
"desktop", "", 22, 10000,
|
||||||
"uname", 1,
|
"uname", 1,
|
||||||
KeyValuePairList());
|
KeyValuePairList()}
|
||||||
|
.addDevice(devMap);
|
||||||
|
|
||||||
const QStringList env = {"TEST=1", "PATH"};
|
const QStringList env = {"TEST=1", "PATH"};
|
||||||
|
|
||||||
@@ -341,34 +336,35 @@ bool AddKitOperation::test() const
|
|||||||
tcs.insert("Cxx", "{tcXX-id}");
|
tcs.insert("Cxx", "{tcXX-id}");
|
||||||
|
|
||||||
// Fail if TC is not there:
|
// Fail if TC is not there:
|
||||||
QVariantMap empty = addKit(map, tcMap, qtMap, devMap, QVariantMap(),
|
kitData = {"testId", "Test Kit", "/tmp/icon.png", QString(), 1,
|
||||||
"testId", "Test Kit", "/tmp/icon.png", QString(), 1,
|
|
||||||
"/usr/bin/gdb-test", "Desktop", "{dev-id}", QString(),
|
"/usr/bin/gdb-test", "Desktop", "{dev-id}", QString(),
|
||||||
tcs, "{qt-id}", "unsupported/mkspec",
|
tcs, "{qt-id}", "unsupported/mkspec",
|
||||||
QString(), QString(), QString(), QString(), QString(), QStringList(),
|
QString(), QString(), QString(), QString(), QString(), QStringList(),
|
||||||
QStringList(),
|
QStringList(),
|
||||||
KeyValuePairList({KeyValuePair("PE.Profile.Data/extraData", QVariant("extraValue"))}));
|
{{{"PE.Profile.Data/extraData", QVariant("extraValue")}}}};
|
||||||
|
QVariantMap empty = kitData.addKit(map, tcMap, qtMap, devMap, {});
|
||||||
|
|
||||||
if (!empty.isEmpty())
|
if (!empty.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
// Do not fail if TC is an ABI:
|
// Do not fail if TC is an ABI:
|
||||||
tcs.clear();
|
tcs.clear();
|
||||||
tcs.insert("C", "x86-linux-generic-elf-64bit");
|
tcs.insert("C", "x86-linux-generic-elf-64bit");
|
||||||
empty = addKit(map, tcMap, qtMap, devMap, QVariantMap(),
|
kitData = {"testId", "Test Kit", "/tmp/icon.png", QString(), 1,
|
||||||
"testId", "Test Kit", "/tmp/icon.png", QString(), 1,
|
|
||||||
"/usr/bin/gdb-test", "Desktop", "{dev-id}", QString(),
|
"/usr/bin/gdb-test", "Desktop", "{dev-id}", QString(),
|
||||||
tcs, "{qt-id}", "unsupported/mkspec",
|
tcs, "{qt-id}", "unsupported/mkspec",
|
||||||
QString(), QString(), QString(), QString(), QString(), QStringList(), env,
|
QString(), QString(), QString(), QString(), QString(), QStringList(), env,
|
||||||
KeyValuePairList({KeyValuePair("PE.Profile.Data/extraData", QVariant("extraValue"))}));
|
{KeyValuePair("PE.Profile.Data/extraData", QVariant("extraValue"))}};
|
||||||
|
empty = kitData.addKit(map, tcMap, qtMap, devMap, {});
|
||||||
if (empty.isEmpty())
|
if (empty.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
// QTCREATORBUG-11983, mach_o was not covered by the first attempt to fix this.
|
// QTCREATORBUG-11983, mach_o was not covered by the first attempt to fix this.
|
||||||
tcs.insert("D", "x86-macos-generic-mach_o-64bit");
|
tcs.insert("D", "x86-macos-generic-mach_o-64bit");
|
||||||
empty = addKit(map, tcMap, qtMap, devMap, QVariantMap(),
|
kitData = {"testId", "Test Kit", "/tmp/icon.png", QString(), 1,
|
||||||
"testId", "Test Kit", "/tmp/icon.png", QString(), 1,
|
|
||||||
"/usr/bin/gdb-test", "Desktop", "{dev-id}", QString(),
|
"/usr/bin/gdb-test", "Desktop", "{dev-id}", QString(),
|
||||||
tcs, "{qt-id}", "unsupported/mkspec",
|
tcs, "{qt-id}", "unsupported/mkspec",
|
||||||
QString(), QString(), QString(), QString(), QString(), QStringList(), env,
|
QString(), QString(), QString(), QString(), QString(), QStringList(), env,
|
||||||
KeyValuePairList({KeyValuePair("PE.Profile.Data/extraData", QVariant("extraValue"))}));
|
{{KeyValuePair("PE.Profile.Data/extraData", QVariant("extraValue"))}}};
|
||||||
|
empty = kitData.addKit(map, tcMap, qtMap, devMap, {});
|
||||||
if (empty.isEmpty())
|
if (empty.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -376,31 +372,31 @@ bool AddKitOperation::test() const
|
|||||||
tcs.insert("Cxx", "{tc-id}");
|
tcs.insert("Cxx", "{tc-id}");
|
||||||
|
|
||||||
// Fail if Qt is not there:
|
// Fail if Qt is not there:
|
||||||
empty = addKit(map, tcMap, qtMap, devMap, QVariantMap(),
|
kitData = {"testId", "Test Kit", "/tmp/icon.png", QString(), 1,
|
||||||
"testId", "Test Kit", "/tmp/icon.png", QString(), 1,
|
|
||||||
"/usr/bin/gdb-test", "Desktop", "{dev-id}", QString(), tcs, "{qtXX-id}",
|
"/usr/bin/gdb-test", "Desktop", "{dev-id}", QString(), tcs, "{qtXX-id}",
|
||||||
"unsupported/mkspec",
|
"unsupported/mkspec",
|
||||||
QString(), QString(), QString(), QString(), QString(), QStringList(), env,
|
QString(), QString(), QString(), QString(), QString(), QStringList(), env,
|
||||||
KeyValuePairList({KeyValuePair("PE.Profile.Data/extraData", QVariant("extraValue"))}));
|
{{KeyValuePair("PE.Profile.Data/extraData", QVariant("extraValue"))}}};
|
||||||
|
empty = kitData.addKit(map, tcMap, qtMap, devMap, {});
|
||||||
if (!empty.isEmpty())
|
if (!empty.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
// Fail if dev is not there:
|
// Fail if dev is not there:
|
||||||
empty = addKit(map, tcMap, qtMap, devMap, QVariantMap(),
|
kitData = {"testId", "Test Kit", "/tmp/icon.png", QString(), 1,
|
||||||
"testId", "Test Kit", "/tmp/icon.png", QString(), 1,
|
|
||||||
"/usr/bin/gdb-test", "Desktop", "{devXX-id}", QString(), tcs, "{qt-id}",
|
"/usr/bin/gdb-test", "Desktop", "{devXX-id}", QString(), tcs, "{qt-id}",
|
||||||
"unsupported/mkspec",
|
"unsupported/mkspec",
|
||||||
QString(), QString(), QString(), QString(), QString(), QStringList(), env,
|
QString(), QString(), QString(), QString(), QString(), QStringList(), env,
|
||||||
KeyValuePairList({KeyValuePair("PE.Profile.Data/extraData", QVariant("extraValue"))}));
|
{KeyValuePair("PE.Profile.Data/extraData", QVariant("extraValue"))}};
|
||||||
|
empty = kitData.addKit(map, tcMap, qtMap, devMap, {});
|
||||||
if (!empty.isEmpty())
|
if (!empty.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Profile 0:
|
// Profile 0:
|
||||||
map = addKit(map, tcMap, qtMap, devMap, QVariantMap(),
|
kitData = {"testId", "Test Kit", "/tmp/icon.png", QString(), 1,
|
||||||
"testId", "Test Kit", "/tmp/icon.png", QString(), 1,
|
|
||||||
"/usr/bin/gdb-test", "Desktop", QString(), QString(), tcs, "{qt-id}",
|
"/usr/bin/gdb-test", "Desktop", QString(), QString(), tcs, "{qt-id}",
|
||||||
"unsupported/mkspec",
|
"unsupported/mkspec",
|
||||||
QString(), QString(), QString(), QString(), QString(), QStringList(), env,
|
QString(), QString(), QString(), QString(), QString(), QStringList(), env,
|
||||||
KeyValuePairList({KeyValuePair("PE.Profile.Data/extraData", QVariant("extraValue"))}));
|
{{KeyValuePair("PE.Profile.Data/extraData", QVariant("extraValue"))}}};
|
||||||
|
map = kitData.addKit(map, tcMap, qtMap, devMap, {});
|
||||||
|
|
||||||
if (map.count() != 4
|
if (map.count() != 4
|
||||||
|| !map.contains(VERSION) || map.value(VERSION).toInt() != 1
|
|| !map.contains(VERSION) || map.value(VERSION).toInt() != 1
|
||||||
@@ -434,22 +430,23 @@ bool AddKitOperation::test() const
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Ignore existing ids:
|
// Ignore existing ids:
|
||||||
QVariantMap result = addKit(map, tcMap, qtMap, devMap, QVariantMap(),
|
kitData = {"testId", "Test Qt Version X",
|
||||||
"testId", "Test Qt Version X",
|
|
||||||
"/tmp/icon3.png", QString(), 1, "/usr/bin/gdb-test3", "Desktop",
|
"/tmp/icon3.png", QString(), 1, "/usr/bin/gdb-test3", "Desktop",
|
||||||
QString(), QString(), tcs, "{qt-id}", "unsupported/mkspec",
|
QString(), QString(), tcs, "{qt-id}", "unsupported/mkspec",
|
||||||
QString(), QString(), QString(), QString(), QString(), QStringList(), env,
|
QString(), QString(), QString(), QString(), QString(), QStringList(), env,
|
||||||
KeyValuePairList({KeyValuePair("PE.Profile.Data/extraData", QVariant("extraValue"))}));
|
{{KeyValuePair("PE.Profile.Data/extraData", QVariant("extraValue"))}}};
|
||||||
|
QVariantMap result = kitData.addKit(map, tcMap, qtMap, devMap, {});
|
||||||
if (!result.isEmpty())
|
if (!result.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Profile 1: Make sure name is unique:
|
// Profile 1: Make sure name is unique:
|
||||||
map = addKit(map, tcMap, qtMap, devMap, QVariantMap(),
|
kitData = {"testId2", "Test Kit2", "/tmp/icon2.png", QString(), 1,
|
||||||
"testId2", "Test Kit2", "/tmp/icon2.png", QString(), 1,
|
|
||||||
"/usr/bin/gdb-test2", "Desktop", "{dev-id}", "/sys/root//", tcs,
|
"/usr/bin/gdb-test2", "Desktop", "{dev-id}", "/sys/root//", tcs,
|
||||||
"{qt-id}", "unsupported/mkspec",
|
"{qt-id}", "unsupported/mkspec",
|
||||||
QString(), QString(), QString(), QString(), QString(), QStringList(), env,
|
QString(), QString(), QString(), QString(), QString(), QStringList(), env,
|
||||||
KeyValuePairList({KeyValuePair("PE.Profile.Data/extraData", QVariant("extraValue"))}));
|
{{KeyValuePair("PE.Profile.Data/extraData", QVariant("extraValue"))}}};
|
||||||
|
map = kitData.addKit(map, tcMap, qtMap, devMap, {});
|
||||||
|
|
||||||
if (map.count() != 5
|
if (map.count() != 5
|
||||||
|| !map.contains(VERSION) || map.value(VERSION).toInt() != 1
|
|| !map.contains(VERSION) || map.value(VERSION).toInt() != 1
|
||||||
|| !map.contains(COUNT) || map.value(COUNT).toInt() != 2
|
|| !map.contains(COUNT) || map.value(COUNT).toInt() != 2
|
||||||
@@ -489,12 +486,12 @@ bool AddKitOperation::test() const
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Profile 2: Test debugger id:
|
// Profile 2: Test debugger id:
|
||||||
map = addKit(map, tcMap, qtMap, devMap, QVariantMap(),
|
kitData = {"test with debugger Id", "Test debugger Id",
|
||||||
"test with debugger Id", "Test debugger Id",
|
|
||||||
"/tmp/icon2.png", "debugger Id", 0, QString(), "Desktop", QString(), QString(),
|
"/tmp/icon2.png", "debugger Id", 0, QString(), "Desktop", QString(), QString(),
|
||||||
tcs, "{qt-id}", "unsupported/mkspec",
|
tcs, "{qt-id}", "unsupported/mkspec",
|
||||||
QString(), QString(), QString(), QString(), QString(), QStringList(), env,
|
QString(), QString(), QString(), QString(), QString(), QStringList(), env,
|
||||||
KeyValuePairList({KeyValuePair("PE.Profile.Data/extraData", QVariant("extraValue"))}));
|
{KeyValuePair("PE.Profile.Data/extraData", QVariant("extraValue"))}};
|
||||||
|
map = kitData.addKit(map, tcMap, qtMap, devMap, {});
|
||||||
if (map.count() != 6
|
if (map.count() != 6
|
||||||
|| !map.contains(VERSION) || map.value(VERSION).toInt() != 1
|
|| !map.contains(VERSION) || map.value(VERSION).toInt() != 1
|
||||||
|| !map.contains(COUNT) || map.value(COUNT).toInt() != 3
|
|| !map.contains(COUNT) || map.value(COUNT).toInt() != 3
|
||||||
@@ -528,61 +525,35 @@ bool AddKitOperation::test() const
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QVariantMap AddKitOperation::addKit(const QVariantMap &map,
|
QVariantMap AddKitData::addKit(const QVariantMap &map) const
|
||||||
const QString &id, const QString &displayName,
|
|
||||||
const QString &icon, const QString &debuggerId,
|
|
||||||
const quint32 &debuggerType, const QString &debugger,
|
|
||||||
const QString &deviceType, const QString &device,
|
|
||||||
const QString &sysRoot, const QHash<QString, QString> &tcs, const QString &qt,
|
|
||||||
const QString &mkspec, const QString &cmakeId,
|
|
||||||
const QString &cmakeGenerator, const QString &cmakeExtraGenerator,
|
|
||||||
const QString &cmakeGeneratorToolset,
|
|
||||||
const QString &cmakeGeneratorPlatform,
|
|
||||||
const QStringList &cmakeConfiguration, const QStringList &env,
|
|
||||||
const KeyValuePairList &extra)
|
|
||||||
{
|
{
|
||||||
QVariantMap tcMap = load("ToolChains");
|
QVariantMap tcMap = Operation::load("ToolChains");
|
||||||
QVariantMap qtMap = load("QtVersions");
|
QVariantMap qtMap = Operation::load("QtVersions");
|
||||||
QVariantMap devMap = load("Devices");
|
QVariantMap devMap = Operation::load("Devices");
|
||||||
QVariantMap cmakeMap = load("cmaketools");
|
QVariantMap cmakeMap = Operation::load("cmaketools");
|
||||||
|
|
||||||
return addKit(map, tcMap, qtMap, devMap, cmakeMap, id, displayName, icon, debuggerId, debuggerType,
|
return AddKitData::addKit(map, tcMap, qtMap, devMap, cmakeMap);
|
||||||
debugger, deviceType, device, sysRoot, tcs, qt, mkspec,
|
|
||||||
cmakeId, cmakeGenerator, cmakeExtraGenerator, cmakeGeneratorToolset,
|
|
||||||
cmakeGeneratorPlatform, cmakeConfiguration,
|
|
||||||
env, extra);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariantMap AddKitOperation::addKit(const QVariantMap &map, const QVariantMap &tcMap,
|
QVariantMap AddKitData::addKit(const QVariantMap &map, const QVariantMap &tcMap,
|
||||||
const QVariantMap &qtMap, const QVariantMap &devMap,
|
const QVariantMap &qtMap, const QVariantMap &devMap,
|
||||||
const QVariantMap &cmakeMap,
|
const QVariantMap &cmakeMap) const
|
||||||
const QString &id, const QString &displayName,
|
|
||||||
const QString &icon, const QString &debuggerId,
|
|
||||||
const quint32 &debuggerType, const QString &debugger,
|
|
||||||
const QString &deviceType, const QString &device,
|
|
||||||
const QString &sysRoot, const QHash<QString, QString> &tcs, const QString &qt,
|
|
||||||
const QString &mkspec, const QString &cmakeId,
|
|
||||||
const QString &cmakeGenerator, const QString &cmakeExtraGenerator,
|
|
||||||
const QString &cmakeGeneratorToolset,
|
|
||||||
const QString &cmakeGeneratorPlatform,
|
|
||||||
const QStringList &cmakeConfiguration, const QStringList &env,
|
|
||||||
const KeyValuePairList &extra)
|
|
||||||
{
|
{
|
||||||
// Sanity check: Make sure autodetection source is not in use already:
|
// Sanity check: Make sure autodetection source is not in use already:
|
||||||
QStringList valueKeys = FindValueOperation::findValue(map, QVariant(id));
|
const QStringList valueKeys = FindValueOperation::findValue(map, QVariant(m_id));
|
||||||
bool hasId = false;
|
bool hasId = false;
|
||||||
foreach (const QString &k, valueKeys) {
|
for (const QString &k : valueKeys) {
|
||||||
if (k.endsWith(QString('/') + ID)) {
|
if (k.endsWith(QString('/') + ID)) {
|
||||||
hasId = true;
|
hasId = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (hasId) {
|
if (hasId) {
|
||||||
std::cerr << "Error: Id " << qPrintable(id) << " already defined as kit." << std::endl;
|
std::cerr << "Error: Id " << qPrintable(m_id) << " already defined as kit." << std::endl;
|
||||||
return QVariantMap();
|
return QVariantMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto i = tcs.constBegin(); i != tcs.constEnd(); ++i) {
|
for (auto i = m_tcs.constBegin(); i != m_tcs.constEnd(); ++i) {
|
||||||
if (!i.value().isEmpty() && !AddToolChainOperation::exists(tcMap, i.value())) {
|
if (!i.value().isEmpty() && !AddToolChainOperation::exists(tcMap, i.value())) {
|
||||||
const QRegularExpression abiRegExp("^[a-z0-9_]+-[a-z0-9_]+-[a-z0-9_]+-[a-z0-9_]+-(8|16|32|64|128)bit$");
|
const QRegularExpression abiRegExp("^[a-z0-9_]+-[a-z0-9_]+-[a-z0-9_]+-[a-z0-9_]+-(8|16|32|64|128)bit$");
|
||||||
if (!abiRegExp.match(i.value()).hasMatch()) {
|
if (!abiRegExp.match(i.value()).hasMatch()) {
|
||||||
@@ -593,15 +564,15 @@ QVariantMap AddKitOperation::addKit(const QVariantMap &map, const QVariantMap &t
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString qtId = qt;
|
QString qtId = m_qt;
|
||||||
if (!qtId.isEmpty() && !qtId.startsWith("SDK."))
|
if (!qtId.isEmpty() && !qtId.startsWith("SDK."))
|
||||||
qtId = QString::fromLatin1("SDK.") + qt;
|
qtId = QString::fromLatin1("SDK.") + m_qt;
|
||||||
if (!qtId.isEmpty() && !AddQtOperation::exists(qtMap, qtId)) {
|
if (!qtId.isEmpty() && !AddQtData::exists(qtMap, qtId)) {
|
||||||
std::cerr << "Error: Qt " << qPrintable(qtId) << " does not exist." << std::endl;
|
std::cerr << "Error: Qt " << qPrintable(qtId) << " does not exist." << std::endl;
|
||||||
return QVariantMap();
|
return QVariantMap();
|
||||||
}
|
}
|
||||||
if (!device.isEmpty() && !AddDeviceOperation::exists(devMap, device)) {
|
if (!m_device.isEmpty() && !AddDeviceOperation::exists(devMap, m_device)) {
|
||||||
std::cerr << "Error: Device " << qPrintable(device) << " does not exist." << std::endl;
|
std::cerr << "Error: Device " << qPrintable(m_device) << " does not exist." << std::endl;
|
||||||
return QVariantMap();
|
return QVariantMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -609,8 +580,8 @@ QVariantMap AddKitOperation::addKit(const QVariantMap &map, const QVariantMap &t
|
|||||||
if (!qtId.isNull() && qtId.isEmpty())
|
if (!qtId.isNull() && qtId.isEmpty())
|
||||||
qtId = "-1";
|
qtId = "-1";
|
||||||
|
|
||||||
if (!cmakeId.isEmpty() && !AddCMakeOperation::exists(cmakeMap, cmakeId)) {
|
if (!m_cmakeId.isEmpty() && !AddCMakeData::exists(cmakeMap, m_cmakeId)) {
|
||||||
std::cerr << "Error: CMake tool " << qPrintable(cmakeId) << " does not exist." << std::endl;
|
std::cerr << "Error: CMake tool " << qPrintable(m_cmakeId) << " does not exist." << std::endl;
|
||||||
return QVariantMap();
|
return QVariantMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -625,68 +596,69 @@ QVariantMap AddKitOperation::addKit(const QVariantMap &map, const QVariantMap &t
|
|||||||
|
|
||||||
QString defaultKit = GetOperation::get(map, DEFAULT).toString();
|
QString defaultKit = GetOperation::get(map, DEFAULT).toString();
|
||||||
if (defaultKit.isEmpty())
|
if (defaultKit.isEmpty())
|
||||||
defaultKit = id;
|
defaultKit = m_id;
|
||||||
|
|
||||||
// remove data:
|
// remove data:
|
||||||
QVariantMap cleaned = RmKeysOperation::rmKeys(map, {COUNT, DEFAULT});
|
QVariantMap cleaned = RmKeysOperation::rmKeys(map, {COUNT, DEFAULT});
|
||||||
|
|
||||||
// insert data:
|
// insert data:
|
||||||
KeyValuePairList data = {KeyValuePair({kit, ID}, QVariant(id)),
|
KeyValuePairList data = {KeyValuePair({kit, ID}, QVariant(m_id)),
|
||||||
KeyValuePair({kit, DISPLAYNAME}, QVariant(displayName)),
|
KeyValuePair({kit, DISPLAYNAME}, QVariant(m_displayName)),
|
||||||
KeyValuePair({kit, ICON}, QVariant(icon)),
|
KeyValuePair({kit, ICON}, QVariant(m_icon)),
|
||||||
KeyValuePair({kit, AUTODETECTED}, QVariant(true)),
|
KeyValuePair({kit, AUTODETECTED}, QVariant(true)),
|
||||||
KeyValuePair({kit, SDK}, QVariant(true))};
|
KeyValuePair({kit, SDK}, QVariant(true))};
|
||||||
|
|
||||||
if (!debuggerId.isEmpty() || !debugger.isEmpty()) {
|
if (!m_debuggerId.isEmpty() || !m_debugger.isEmpty()) {
|
||||||
if (debuggerId.isEmpty()) {
|
if (m_debuggerId.isEmpty()) {
|
||||||
data << KeyValuePair({kit, DATA, DEBUGGER, DEBUGGER_ENGINE}, QVariant(debuggerType));
|
data << KeyValuePair({kit, DATA, DEBUGGER, DEBUGGER_ENGINE}, QVariant(m_debuggerEngine));
|
||||||
data << KeyValuePair({kit, DATA, DEBUGGER, DEBUGGER_BINARY}, QVariant(debugger));
|
data << KeyValuePair({kit, DATA, DEBUGGER, DEBUGGER_BINARY}, QVariant(m_debugger));
|
||||||
} else {
|
} else {
|
||||||
data << KeyValuePair({kit, DATA, DEBUGGER }, QVariant(debuggerId));
|
data << KeyValuePair({kit, DATA, DEBUGGER }, QVariant(m_debuggerId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!deviceType.isNull())
|
|
||||||
data << KeyValuePair({kit, DATA, DEVICE_TYPE}, QVariant(deviceType));
|
if (!m_deviceType.isNull())
|
||||||
if (!device.isNull())
|
data << KeyValuePair({kit, DATA, DEVICE_TYPE}, QVariant(m_deviceType));
|
||||||
data << KeyValuePair({kit, DATA, DEVICE_ID}, QVariant(device));
|
if (!m_device.isNull())
|
||||||
if (!sysRoot.isNull())
|
data << KeyValuePair({kit, DATA, DEVICE_ID}, QVariant(m_device));
|
||||||
data << KeyValuePair({kit, DATA, SYSROOT}, Utils::FilePath::fromUserInput(sysRoot).toVariant());
|
if (!m_sysRoot.isNull())
|
||||||
for (auto i = tcs.constBegin(); i != tcs.constEnd(); ++i)
|
data << KeyValuePair({kit, DATA, SYSROOT}, Utils::FilePath::fromUserInput(m_sysRoot).toVariant());
|
||||||
|
for (auto i = m_tcs.constBegin(); i != m_tcs.constEnd(); ++i)
|
||||||
data << KeyValuePair({kit, DATA, TOOLCHAIN, i.key()}, QVariant(i.value()));
|
data << KeyValuePair({kit, DATA, TOOLCHAIN, i.key()}, QVariant(i.value()));
|
||||||
if (!qtId.isNull())
|
if (!qtId.isNull())
|
||||||
data << KeyValuePair({kit, DATA, QT}, QVariant(qtId));
|
data << KeyValuePair({kit, DATA, QT}, QVariant(qtId));
|
||||||
if (!mkspec.isNull())
|
if (!m_mkspec.isNull())
|
||||||
data << KeyValuePair({kit, DATA, MKSPEC}, QVariant(mkspec));
|
data << KeyValuePair({kit, DATA, MKSPEC}, QVariant(m_mkspec));
|
||||||
if (!cmakeId.isNull())
|
if (!m_cmakeId.isNull())
|
||||||
data << KeyValuePair({kit, DATA, CMAKE_ID}, QVariant(cmakeId));
|
data << KeyValuePair({kit, DATA, CMAKE_ID}, QVariant(m_cmakeId));
|
||||||
if (!cmakeGenerator.isNull()) {
|
if (!m_cmakeGenerator.isNull()) {
|
||||||
QVariantMap generatorMap;
|
QVariantMap generatorMap;
|
||||||
generatorMap.insert("Generator", cmakeGenerator);
|
generatorMap.insert("Generator", m_cmakeGenerator);
|
||||||
if (!cmakeExtraGenerator.isNull())
|
if (!m_cmakeExtraGenerator.isNull())
|
||||||
generatorMap.insert("ExtraGenerator", cmakeExtraGenerator);
|
generatorMap.insert("ExtraGenerator", m_cmakeExtraGenerator);
|
||||||
if (!cmakeGeneratorToolset.isNull())
|
if (!m_cmakeGeneratorToolset.isNull())
|
||||||
generatorMap.insert("Toolset", cmakeGeneratorToolset);
|
generatorMap.insert("Toolset", m_cmakeGeneratorToolset);
|
||||||
if (!cmakeGeneratorPlatform.isNull())
|
if (!m_cmakeGeneratorPlatform.isNull())
|
||||||
generatorMap.insert("Platform", cmakeGeneratorPlatform);
|
generatorMap.insert("Platform", m_cmakeGeneratorPlatform);
|
||||||
data << KeyValuePair({kit, DATA, CMAKE_GENERATOR}, generatorMap);
|
data << KeyValuePair({kit, DATA, CMAKE_GENERATOR}, generatorMap);
|
||||||
}
|
}
|
||||||
if (!cmakeConfiguration.isEmpty())
|
if (!m_cmakeConfiguration.isEmpty())
|
||||||
data << KeyValuePair({kit, DATA, CMAKE_CONFIGURATION}, QVariant(cmakeConfiguration));
|
data << KeyValuePair({kit, DATA, CMAKE_CONFIGURATION}, QVariant(m_cmakeConfiguration));
|
||||||
if (!env.isEmpty())
|
if (!m_env.isEmpty())
|
||||||
data << KeyValuePair({kit, DATA, ENV}, QVariant(env));
|
data << KeyValuePair({kit, DATA, ENV}, QVariant(m_env));
|
||||||
|
|
||||||
data << KeyValuePair(DEFAULT, QVariant(defaultKit));
|
data << KeyValuePair(DEFAULT, QVariant(defaultKit));
|
||||||
data << KeyValuePair(COUNT, QVariant(count + 1));
|
data << KeyValuePair(COUNT, QVariant(count + 1));
|
||||||
|
|
||||||
KeyValuePairList qtExtraList;
|
KeyValuePairList qtExtraList;
|
||||||
foreach (const KeyValuePair &pair, extra)
|
foreach (const KeyValuePair &pair, m_extra)
|
||||||
qtExtraList << KeyValuePair(QStringList() << kit << pair.key, pair.value);
|
qtExtraList << KeyValuePair(QStringList() << kit << pair.key, pair.value);
|
||||||
data.append(qtExtraList);
|
data.append(qtExtraList);
|
||||||
|
|
||||||
return AddKeysOperation::addKeys(cleaned, data);
|
return AddKeysData{data}.addKeys(cleaned);
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariantMap AddKitOperation::initializeKits()
|
QVariantMap AddKitData::initializeKits()
|
||||||
{
|
{
|
||||||
QVariantMap map;
|
QVariantMap map;
|
||||||
map.insert(VERSION, 1);
|
map.insert(VERSION, 1);
|
||||||
|
@@ -28,49 +28,17 @@
|
|||||||
#include "operation.h"
|
#include "operation.h"
|
||||||
|
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
#include <QString>
|
|
||||||
|
|
||||||
class AddKitOperation : public Operation
|
class AddKitData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QString name() const;
|
QVariantMap addKit(const QVariantMap &map) const;
|
||||||
QString helpText() const;
|
QVariantMap addKit(const QVariantMap &map, const QVariantMap &tcMap,
|
||||||
QString argumentsHelpText() const;
|
const QVariantMap &qtMap, const QVariantMap &devMap,
|
||||||
|
const QVariantMap &cmakeMap) const;
|
||||||
bool setArguments(const QStringList &args);
|
|
||||||
|
|
||||||
int execute() const;
|
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
|
||||||
bool test() const;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static QVariantMap addKit(const QVariantMap &map, const QString &id, const QString &displayName,
|
|
||||||
const QString &icon, const QString &debuggerId,
|
|
||||||
const quint32 &debuggerType, const QString &debugger,
|
|
||||||
const QString &deviceType, const QString &device,
|
|
||||||
const QString &sysRoot, const QHash<QString, QString> &tcs,
|
|
||||||
const QString &qt, const QString &mkspec,
|
|
||||||
const QString &cmakeId, const QString &cmakeGenerator,
|
|
||||||
const QString &cmakeExtraGenerator, const QString &cmakeGeneratorToolset,
|
|
||||||
const QString &cmakeGeneratorPlatform,
|
|
||||||
const QStringList &cmakeConfiguration, const QStringList &env,
|
|
||||||
const KeyValuePairList &extra);
|
|
||||||
|
|
||||||
static QVariantMap initializeKits();
|
static QVariantMap initializeKits();
|
||||||
|
|
||||||
// internal:
|
|
||||||
static QVariantMap addKit(const QVariantMap &map, const QVariantMap &tcMap,
|
|
||||||
const QVariantMap &qtMap, const QVariantMap &devMap, const QVariantMap &cmakeMap,
|
|
||||||
const QString &id, const QString &displayName,
|
|
||||||
const QString &icon, const QString &debuggerId,
|
|
||||||
const quint32 &debuggerType, const QString &debugger,
|
|
||||||
const QString &deviceType, const QString &device,
|
|
||||||
const QString &sysRoot, const QHash<QString, QString> &tcs,
|
|
||||||
const QString &qt, const QString &mkspec, const QString &cmakeId, const QString &cmakeGenerator, const QString &cmakeExtraGenerator, const QString &cmakeGeneratorToolset, const QString &cmakeGeneratorPlatform, const QStringList &cmakeConfiguration, const QStringList &env,
|
|
||||||
const KeyValuePairList &extra);
|
|
||||||
|
|
||||||
private:
|
|
||||||
QString m_id;
|
QString m_id;
|
||||||
QString m_displayName;
|
QString m_displayName;
|
||||||
QString m_icon;
|
QString m_icon;
|
||||||
@@ -92,3 +60,18 @@ private:
|
|||||||
QStringList m_env;
|
QStringList m_env;
|
||||||
KeyValuePairList m_extra;
|
KeyValuePairList m_extra;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class AddKitOperation : public Operation, public AddKitData
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
QString name() const final;
|
||||||
|
QString helpText() const final;
|
||||||
|
QString argumentsHelpText() const final;
|
||||||
|
|
||||||
|
bool setArguments(const QStringList &args) final;
|
||||||
|
int execute() const final;
|
||||||
|
|
||||||
|
#ifdef WITH_TESTS
|
||||||
|
bool test() const final;
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
@@ -169,7 +169,7 @@ int AddQtOperation::execute() const
|
|||||||
if (map.isEmpty())
|
if (map.isEmpty())
|
||||||
map = initializeQtVersions();
|
map = initializeQtVersions();
|
||||||
|
|
||||||
QVariantMap result = addQt(map, m_id, m_displayName, m_type, m_qmake, m_extra, m_abis);
|
QVariantMap result = addQt(map);
|
||||||
|
|
||||||
if (result.isEmpty() || result == map)
|
if (result.isEmpty() || result == map)
|
||||||
return 2;
|
return 2;
|
||||||
@@ -180,6 +180,7 @@ int AddQtOperation::execute() const
|
|||||||
#ifdef WITH_TESTS
|
#ifdef WITH_TESTS
|
||||||
bool AddQtOperation::test() const
|
bool AddQtOperation::test() const
|
||||||
{
|
{
|
||||||
|
AddQtData qtData;
|
||||||
QVariantMap map = initializeQtVersions();
|
QVariantMap map = initializeQtVersions();
|
||||||
|
|
||||||
if (map.count() != 1
|
if (map.count() != 1
|
||||||
@@ -188,16 +189,13 @@ bool AddQtOperation::test() const
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
#if defined Q_OS_WIN
|
#if defined Q_OS_WIN
|
||||||
map = addQt(map, QLatin1String("{some-qt-id}"), QLatin1String("Test Qt Version"), QLatin1String("testType"),
|
qtData = {"{some-qt-id}", "Test Qt Version", "testType", "/tmp//../tmp/test\\qmake", {},
|
||||||
QLatin1String("/tmp//../tmp/test\\qmake"),
|
{{QLatin1String("extraData"), QVariant(QLatin1String("extraValue"))}}};
|
||||||
KeyValuePairList() << KeyValuePair(QLatin1String("extraData"), QVariant(QLatin1String("extraValue"))),
|
|
||||||
QStringList());
|
|
||||||
#else
|
#else
|
||||||
map = addQt(map, QLatin1String("{some-qt-id}"), QLatin1String("Test Qt Version"), QLatin1String("testType"),
|
qtData = {"{some-qt-id}", "Test Qt Version", "testType", "/tmp//../tmp/test/qmake", {},
|
||||||
QLatin1String("/tmp//../tmp/test/qmake"),
|
{{QLatin1String("extraData"), QVariant(QLatin1String("extraValue"))}}};
|
||||||
KeyValuePairList() << KeyValuePair(QLatin1String("extraData"), QVariant(QLatin1String("extraValue"))),
|
|
||||||
QStringList());
|
|
||||||
#endif
|
#endif
|
||||||
|
map = qtData.addQt(map);
|
||||||
|
|
||||||
if (map.count() != 2
|
if (map.count() != 2
|
||||||
|| !map.contains(QLatin1String(VERSION))
|
|| !map.contains(QLatin1String(VERSION))
|
||||||
@@ -226,18 +224,16 @@ bool AddQtOperation::test() const
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Ignore existing ids:
|
// Ignore existing ids:
|
||||||
QVariantMap result = addQt(map, QLatin1String("{some-qt-id}"), QLatin1String("Test Qt Version2"), QLatin1String("testType2"),
|
qtData = {"{some-qt-id}", "Test Qt Version2", "testType2", "/tmp/test/qmake2", {},
|
||||||
QLatin1String("/tmp/test/qmake2"),
|
{{QLatin1String("extraData"), QVariant(QLatin1String("extraValue"))}}};
|
||||||
KeyValuePairList() << KeyValuePair(QLatin1String("extraData"), QVariant(QLatin1String("extraValue"))),
|
QVariantMap result = qtData.addQt(map);
|
||||||
QStringList());
|
|
||||||
if (!result.isEmpty())
|
if (!result.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// add 2nd Qt version:
|
// add 2nd Qt version:
|
||||||
map = addQt(map, QLatin1String("testId2"), QLatin1String("Test Qt Version"), QLatin1String("testType3"),
|
qtData = {"testId2", "Test Qt Version", "testType3", "/tmp/test/qmake2", {},
|
||||||
QLatin1String("/tmp/test/qmake2"),
|
{{QLatin1String("extraData"), QVariant(QLatin1String("extraValue"))}}};
|
||||||
KeyValuePairList() << KeyValuePair(QLatin1String("extraData"), QVariant(QLatin1String("extraValue"))),
|
map = qtData.addQt(map);
|
||||||
QStringList());
|
|
||||||
if (map.count() != 3
|
if (map.count() != 3
|
||||||
|| !map.contains(QLatin1String(VERSION))
|
|| !map.contains(QLatin1String(VERSION))
|
||||||
|| map.value(QLatin1String(VERSION)).toInt() != 1
|
|| map.value(QLatin1String(VERSION)).toInt() != 1
|
||||||
@@ -272,16 +268,13 @@ bool AddQtOperation::test() const
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QVariantMap AddQtOperation::addQt(const QVariantMap &map,
|
QVariantMap AddQtData::addQt(const QVariantMap &map) const
|
||||||
const QString &id, const QString &displayName, const QString &type,
|
|
||||||
const QString &qmake, const KeyValuePairList &extra,
|
|
||||||
const QStringList &abis)
|
|
||||||
{
|
{
|
||||||
QString sdkId = extendId(id);
|
QString sdkId = extendId(m_id);
|
||||||
|
|
||||||
// Sanity check: Make sure autodetection source is not in use already:
|
// Sanity check: Make sure autodetection source is not in use already:
|
||||||
if (exists(map, sdkId)) {
|
if (exists(map, sdkId)) {
|
||||||
std::cerr << "Error: Id " << qPrintable(id) << " already defined as Qt versions." << std::endl;
|
std::cerr << "Error: Id " << qPrintable(m_id) << " already defined as Qt versions." << std::endl;
|
||||||
return QVariantMap();
|
return QVariantMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -299,40 +292,41 @@ QVariantMap AddQtOperation::addQt(const QVariantMap &map,
|
|||||||
const QString qt = QString::fromLatin1(PREFIX) + QString::number(versionCount);
|
const QString qt = QString::fromLatin1(PREFIX) + QString::number(versionCount);
|
||||||
|
|
||||||
// Sanitize qmake path:
|
// Sanitize qmake path:
|
||||||
FilePath saneQmake = FilePath::fromUserInput(qmake).cleanPath();
|
FilePath saneQmake = FilePath::fromUserInput(m_qmake).cleanPath();
|
||||||
|
|
||||||
// insert data:
|
// insert data:
|
||||||
KeyValuePairList data;
|
KeyValuePairList data;
|
||||||
data << KeyValuePair(QStringList() << qt << QLatin1String(ID), QVariant(-1));
|
data << KeyValuePair(QStringList() << qt << QLatin1String(ID), QVariant(-1));
|
||||||
data << KeyValuePair(QStringList() << qt << QLatin1String(DISPLAYNAME), QVariant(displayName));
|
data << KeyValuePair(QStringList() << qt << QLatin1String(DISPLAYNAME), QVariant(m_displayName));
|
||||||
data << KeyValuePair(QStringList() << qt << QLatin1String(AUTODETECTED), QVariant(true));
|
data << KeyValuePair(QStringList() << qt << QLatin1String(AUTODETECTED), QVariant(true));
|
||||||
data << KeyValuePair(QStringList() << qt << QLatin1String(AUTODETECTION_SOURCE), QVariant(sdkId));
|
data << KeyValuePair(QStringList() << qt << QLatin1String(AUTODETECTION_SOURCE), QVariant(sdkId));
|
||||||
|
|
||||||
data << KeyValuePair(QStringList() << qt << QLatin1String(QMAKE), saneQmake.toVariant());
|
data << KeyValuePair(QStringList() << qt << QLatin1String(QMAKE), saneQmake.toVariant());
|
||||||
data << KeyValuePair(QStringList() << qt << QLatin1String(TYPE), QVariant(type));
|
data << KeyValuePair(QStringList() << qt << QLatin1String(TYPE), QVariant(m_type));
|
||||||
data << KeyValuePair(QStringList() << qt << ABIS, QVariant(abis));
|
data << KeyValuePair(QStringList() << qt << ABIS, QVariant(m_abis));
|
||||||
|
|
||||||
KeyValuePairList qtExtraList;
|
KeyValuePairList qtExtraList;
|
||||||
foreach (const KeyValuePair &pair, extra)
|
foreach (const KeyValuePair &pair, m_extra)
|
||||||
qtExtraList << KeyValuePair(QStringList() << qt << pair.key, pair.value);
|
qtExtraList << KeyValuePair(QStringList() << qt << pair.key, pair.value);
|
||||||
data.append(qtExtraList);
|
data.append(qtExtraList);
|
||||||
|
|
||||||
return AddKeysOperation::addKeys(map, data);
|
return AddKeysData{data}.addKeys(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariantMap AddQtOperation::initializeQtVersions()
|
QVariantMap AddQtData::initializeQtVersions()
|
||||||
{
|
{
|
||||||
QVariantMap map;
|
QVariantMap map;
|
||||||
map.insert(QLatin1String(VERSION), 1);
|
map.insert(QLatin1String(VERSION), 1);
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AddQtOperation::exists(const QString &id)
|
bool AddQtData::exists(const QString &id)
|
||||||
{
|
{
|
||||||
QVariantMap map = load(QLatin1String("QtVersions"));
|
QVariantMap map = Operation::load(QLatin1String("QtVersions"));
|
||||||
return exists(map, id);
|
return exists(map, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AddQtOperation::exists(const QVariantMap &map, const QString &id)
|
bool AddQtData::exists(const QVariantMap &map, const QString &id)
|
||||||
{
|
{
|
||||||
QString sdkId = extendId(id);
|
QString sdkId = extendId(id);
|
||||||
|
|
||||||
|
@@ -27,34 +27,16 @@
|
|||||||
|
|
||||||
#include "operation.h"
|
#include "operation.h"
|
||||||
|
|
||||||
#include <QString>
|
class AddQtData
|
||||||
|
|
||||||
class AddQtOperation : public Operation
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QString name() const;
|
QVariantMap addQt(const QVariantMap &map) const;
|
||||||
QString helpText() const;
|
|
||||||
QString argumentsHelpText() const;
|
|
||||||
|
|
||||||
bool setArguments(const QStringList &args);
|
|
||||||
|
|
||||||
int execute() const;
|
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
|
||||||
bool test() const;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static QVariantMap addQt(const QVariantMap &map,
|
|
||||||
const QString &id, const QString &displayName, const QString &type,
|
|
||||||
const QString &qmake, const KeyValuePairList &extra,
|
|
||||||
const QStringList &abis);
|
|
||||||
|
|
||||||
static QVariantMap initializeQtVersions();
|
static QVariantMap initializeQtVersions();
|
||||||
|
|
||||||
static bool exists(const QString &id);
|
static bool exists(const QString &id);
|
||||||
static bool exists(const QVariantMap &map, const QString &id);
|
static bool exists(const QVariantMap &map, const QString &id);
|
||||||
|
|
||||||
private:
|
|
||||||
QString m_id; // actually this is the autodetectionSource
|
QString m_id; // actually this is the autodetectionSource
|
||||||
QString m_displayName;
|
QString m_displayName;
|
||||||
QString m_type;
|
QString m_type;
|
||||||
@@ -62,3 +44,17 @@ private:
|
|||||||
QStringList m_abis;
|
QStringList m_abis;
|
||||||
KeyValuePairList m_extra;
|
KeyValuePairList m_extra;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class AddQtOperation : public Operation, public AddQtData
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
QString name() const final;
|
||||||
|
QString helpText() const final;
|
||||||
|
QString argumentsHelpText() const final;
|
||||||
|
bool setArguments(const QStringList &args) final;
|
||||||
|
int execute() const final;
|
||||||
|
|
||||||
|
#ifdef WITH_TESTS
|
||||||
|
bool test() const final;
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
@@ -158,8 +158,7 @@ int AddToolChainOperation::execute() const
|
|||||||
if (map.isEmpty())
|
if (map.isEmpty())
|
||||||
map = initializeToolChains();
|
map = initializeToolChains();
|
||||||
|
|
||||||
QVariantMap result = addToolChain(map, m_id, m_languageId, m_displayName, m_path,
|
QVariantMap result = addToolChain(map);
|
||||||
m_targetAbi, m_supportedAbis, m_extra);
|
|
||||||
if (result.isEmpty() || map == result)
|
if (result.isEmpty() || map == result)
|
||||||
return 2;
|
return 2;
|
||||||
|
|
||||||
@@ -172,8 +171,8 @@ bool AddToolChainOperation::test() const
|
|||||||
QVariantMap map = initializeToolChains();
|
QVariantMap map = initializeToolChains();
|
||||||
|
|
||||||
// Add toolchain:
|
// Add toolchain:
|
||||||
map = addToolChain(map, "testId", "langId", "name", "/tmp/test", "test-abi", "test-abi,test-abi2",
|
map = AddToolChainData{"testId", "langId", "name", "/tmp/test", "test-abi", "test-abi,test-abi2",
|
||||||
KeyValuePairList() << KeyValuePair("ExtraKey", QVariant("ExtraValue")));
|
{{"ExtraKey", QVariant("ExtraValue")}}}.addToolChain(map);
|
||||||
if (map.value(COUNT).toInt() != 1
|
if (map.value(COUNT).toInt() != 1
|
||||||
|| !map.contains(QString::fromLatin1(PREFIX) + '0'))
|
|| !map.contains(QString::fromLatin1(PREFIX) + '0'))
|
||||||
return false;
|
return false;
|
||||||
@@ -190,15 +189,15 @@ bool AddToolChainOperation::test() const
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Ignore same Id:
|
// Ignore same Id:
|
||||||
QVariantMap unchanged = addToolChain(map, "testId", "langId", "name2", "/tmp/test2", "test-abi2",
|
QVariantMap unchanged = AddToolChainData{"testId", "langId", "name2", "/tmp/test2", "test-abi2",
|
||||||
"test-abi2,test-abi3",
|
"test-abi2,test-abi3",
|
||||||
KeyValuePairList() << KeyValuePair("ExtraKey", QVariant("ExtraValue2")));
|
{{"ExtraKey", QVariant("ExtraValue2")}}}.addToolChain(map);
|
||||||
if (!unchanged.isEmpty())
|
if (!unchanged.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// add 2nd tool chain:
|
// add 2nd tool chain:
|
||||||
map = addToolChain(map, "{some-tc-id}", "langId2", "name", "/tmp/test", "test-abi", "test-abi,test-abi2",
|
map = AddToolChainData{"{some-tc-id}", "langId2", "name", "/tmp/test", "test-abi", "test-abi,test-abi2",
|
||||||
KeyValuePairList() << KeyValuePair("ExtraKey", QVariant("ExtraValue")));
|
{{"ExtraKey", QVariant("ExtraValue")}}}.addToolChain(map);
|
||||||
if (map.value(COUNT).toInt() != 2
|
if (map.value(COUNT).toInt() != 2
|
||||||
|| !map.contains(QString::fromLatin1(PREFIX) + '0')
|
|| !map.contains(QString::fromLatin1(PREFIX) + '0')
|
||||||
|| !map.contains(QString::fromLatin1(PREFIX) + '1'))
|
|| !map.contains(QString::fromLatin1(PREFIX) + '1'))
|
||||||
@@ -230,15 +229,11 @@ bool AddToolChainOperation::test() const
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QVariantMap AddToolChainOperation::addToolChain(const QVariantMap &map, const QString &id,
|
QVariantMap AddToolChainData::addToolChain(const QVariantMap &map) const
|
||||||
const QString &lang, const QString &displayName,
|
|
||||||
const QString &path, const QString &abi,
|
|
||||||
const QString &supportedAbis,
|
|
||||||
const KeyValuePairList &extra)
|
|
||||||
{
|
{
|
||||||
// Sanity check: Does the Id already exist?
|
// Sanity check: Does the Id already exist?
|
||||||
if (exists(map, id)) {
|
if (exists(map, m_id)) {
|
||||||
std::cerr << "Error: Id " << qPrintable(id) << " already defined for tool chains." << std::endl;
|
std::cerr << "Error: Id " << qPrintable(m_id) << " already defined for tool chains." << std::endl;
|
||||||
return QVariantMap();
|
return QVariantMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -255,44 +250,44 @@ QVariantMap AddToolChainOperation::addToolChain(const QVariantMap &map, const QS
|
|||||||
const QString tc = QString::fromLatin1(PREFIX) + QString::number(count);
|
const QString tc = QString::fromLatin1(PREFIX) + QString::number(count);
|
||||||
|
|
||||||
KeyValuePairList data;
|
KeyValuePairList data;
|
||||||
data << KeyValuePair({tc, ID}, QVariant(id));
|
data << KeyValuePair({tc, ID}, QVariant(m_id));
|
||||||
|
|
||||||
// Language compatibility hack for old Qt components that use the language spec from 4.2.
|
// Language compatibility hack for old Qt components that use the language spec from 4.2.
|
||||||
// Some Qt 5.15 components were actually still using this.
|
// Some Qt 5.15 components were actually still using this.
|
||||||
QString newLang; // QtC 4.3 and later
|
QString newLang; // QtC 4.3 and later
|
||||||
lang.toInt(&ok);
|
m_languageId.toInt(&ok);
|
||||||
if (lang == "2" || lang == "Cxx") {
|
if (m_languageId == "2" || m_languageId == "Cxx") {
|
||||||
newLang = "Cxx";
|
newLang = "Cxx";
|
||||||
} else if (lang == "1" || lang == "C") {
|
} else if (m_languageId == "1" || m_languageId == "C") {
|
||||||
newLang = "C";
|
newLang = "C";
|
||||||
} else if (ok) {
|
} else if (ok) {
|
||||||
std::cerr << "Error: Language ID must be 1 for C, 2 for Cxx "
|
std::cerr << "Error: Language ID must be 1 for C, 2 for Cxx "
|
||||||
<< "or a string like \"C\", \"Cxx\", \"Nim\" (was \""
|
<< "or a string like \"C\", \"Cxx\", \"Nim\" (was \""
|
||||||
<< qPrintable(lang) << "\")" << std::endl;
|
<< qPrintable(m_languageId) << "\")" << std::endl;
|
||||||
return {};
|
return {};
|
||||||
} else if (!ok) {
|
} else if (!ok) {
|
||||||
newLang = lang;
|
newLang = m_languageId;
|
||||||
}
|
}
|
||||||
data << KeyValuePair({tc, LANGUAGE_KEY_V2}, QVariant(newLang));
|
data << KeyValuePair({tc, LANGUAGE_KEY_V2}, QVariant(newLang));
|
||||||
data << KeyValuePair({tc, DISPLAYNAME}, QVariant(displayName));
|
data << KeyValuePair({tc, DISPLAYNAME}, QVariant(m_displayName));
|
||||||
data << KeyValuePair({tc, AUTODETECTED}, QVariant(true));
|
data << KeyValuePair({tc, AUTODETECTED}, QVariant(true));
|
||||||
data << KeyValuePair({tc, PATH}, Utils::FilePath::fromUserInput(path).toVariant());
|
data << KeyValuePair({tc, PATH}, Utils::FilePath::fromUserInput(m_path).toVariant());
|
||||||
data << KeyValuePair({tc, TARGET_ABI}, QVariant(abi));
|
data << KeyValuePair({tc, TARGET_ABI}, QVariant(m_targetAbi));
|
||||||
QVariantList abis;
|
QVariantList abis;
|
||||||
QStringList abiStrings = supportedAbis.split(',');
|
QStringList abiStrings = m_supportedAbis.split(',');
|
||||||
foreach (const QString &s, abiStrings)
|
foreach (const QString &s, abiStrings)
|
||||||
abis << QVariant(s);
|
abis << QVariant(s);
|
||||||
data << KeyValuePair({tc, SUPPORTED_ABIS}, QVariant(abis));
|
data << KeyValuePair({tc, SUPPORTED_ABIS}, QVariant(abis));
|
||||||
KeyValuePairList tcExtraList;
|
KeyValuePairList tcExtraList;
|
||||||
foreach (const KeyValuePair &pair, extra)
|
foreach (const KeyValuePair &pair, m_extra)
|
||||||
tcExtraList << KeyValuePair(QStringList({tc}) << pair.key, pair.value);
|
tcExtraList << KeyValuePair(QStringList({tc}) << pair.key, pair.value);
|
||||||
data.append(tcExtraList);
|
data.append(tcExtraList);
|
||||||
data << KeyValuePair(COUNT, QVariant(count + 1));
|
data << KeyValuePair(COUNT, QVariant(count + 1));
|
||||||
|
|
||||||
return AddKeysOperation::addKeys(result, data);
|
return AddKeysData{data}.addKeys(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariantMap AddToolChainOperation::initializeToolChains()
|
QVariantMap AddToolChainData::initializeToolChains()
|
||||||
{
|
{
|
||||||
QVariantMap map;
|
QVariantMap map;
|
||||||
map.insert(COUNT, 0);
|
map.insert(COUNT, 0);
|
||||||
@@ -300,7 +295,7 @@ QVariantMap AddToolChainOperation::initializeToolChains()
|
|||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AddToolChainOperation::exists(const QVariantMap &map, const QString &id)
|
bool AddToolChainData::exists(const QVariantMap &map, const QString &id)
|
||||||
{
|
{
|
||||||
QStringList valueKeys = FindValueOperation::findValue(map, id);
|
QStringList valueKeys = FindValueOperation::findValue(map, id);
|
||||||
// support old settings using QByteArray for id's
|
// support old settings using QByteArray for id's
|
||||||
@@ -314,7 +309,7 @@ bool AddToolChainOperation::exists(const QVariantMap &map, const QString &id)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AddToolChainOperation::exists(const QString &id)
|
bool AddToolChainData::exists(const QString &id)
|
||||||
{
|
{
|
||||||
QVariantMap map = Operation::load("ToolChains");
|
QVariantMap map = Operation::load("ToolChains");
|
||||||
return exists(map, id);
|
return exists(map, id);
|
||||||
|
@@ -27,34 +27,16 @@
|
|||||||
|
|
||||||
#include "operation.h"
|
#include "operation.h"
|
||||||
|
|
||||||
#include <QString>
|
class AddToolChainData
|
||||||
|
|
||||||
class AddToolChainOperation : public Operation
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QString name() const;
|
QVariantMap addToolChain(const QVariantMap &map) const;
|
||||||
QString helpText() const;
|
|
||||||
QString argumentsHelpText() const;
|
|
||||||
|
|
||||||
bool setArguments(const QStringList &args);
|
|
||||||
|
|
||||||
int execute() const;
|
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
|
||||||
bool test() const;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static QVariantMap addToolChain(const QVariantMap &map,
|
|
||||||
const QString &id, const QString &lang,
|
|
||||||
const QString &displayName, const QString &path,
|
|
||||||
const QString &abi, const QString &supportedAbis,
|
|
||||||
const KeyValuePairList &extra);
|
|
||||||
|
|
||||||
static QVariantMap initializeToolChains();
|
static QVariantMap initializeToolChains();
|
||||||
|
|
||||||
static bool exists(const QString &id);
|
static bool exists(const QString &id);
|
||||||
static bool exists(const QVariantMap &map, const QString &id);
|
static bool exists(const QVariantMap &map, const QString &id);
|
||||||
|
|
||||||
private:
|
|
||||||
QString m_id;
|
QString m_id;
|
||||||
QString m_languageId;
|
QString m_languageId;
|
||||||
QString m_displayName;
|
QString m_displayName;
|
||||||
@@ -63,3 +45,19 @@ private:
|
|||||||
QString m_supportedAbis;
|
QString m_supportedAbis;
|
||||||
KeyValuePairList m_extra;
|
KeyValuePairList m_extra;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class AddToolChainOperation : public Operation, public AddToolChainData
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
QString name() const final;
|
||||||
|
QString helpText() const final;
|
||||||
|
QString argumentsHelpText() const final;
|
||||||
|
|
||||||
|
bool setArguments(const QStringList &args) final;
|
||||||
|
|
||||||
|
int execute() const final;
|
||||||
|
|
||||||
|
#ifdef WITH_TESTS
|
||||||
|
bool test() const final;
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
@@ -79,7 +79,7 @@ bool AddValueOperation::setArguments(const QStringList &args)
|
|||||||
m_file = tempArgs.takeFirst();
|
m_file = tempArgs.takeFirst();
|
||||||
m_key = tempArgs.takeFirst();
|
m_key = tempArgs.takeFirst();
|
||||||
for (const auto &arg : tempArgs) {
|
for (const auto &arg : tempArgs) {
|
||||||
const auto val = Operation::valueFromString(arg);
|
const auto val = valueFromString(arg);
|
||||||
if (!val.isValid() || val.isNull()) {
|
if (!val.isValid() || val.isNull()) {
|
||||||
std::cerr << "Error: " << std::quoted(arg.toStdString())
|
std::cerr << "Error: " << std::quoted(arg.toStdString())
|
||||||
<< " is not a valid QVariant like string Type:Value.\n"
|
<< " is not a valid QVariant like string Type:Value.\n"
|
||||||
@@ -101,7 +101,7 @@ int AddValueOperation::execute() const
|
|||||||
return FAILURE;
|
return FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto status = appendListToMap(map, m_key, m_values);
|
bool status = appendListToMap(map);
|
||||||
|
|
||||||
if (status) {
|
if (status) {
|
||||||
status = save(map, m_file);
|
status = save(map, m_file);
|
||||||
@@ -122,13 +122,12 @@ bool AddValueOperation::test() const
|
|||||||
testKvpList.append(KeyValuePair(QLatin1String("test/foobar"), QString::fromLatin1("int:42")));
|
testKvpList.append(KeyValuePair(QLatin1String("test/foobar"), QString::fromLatin1("int:42")));
|
||||||
testKvpList.append(KeyValuePair(QLatin1String("test/bar"), testDataList));
|
testKvpList.append(KeyValuePair(QLatin1String("test/bar"), testDataList));
|
||||||
|
|
||||||
const auto valueList = QVariantList(
|
const QVariantList valueList = {valueFromString("QString:ELIL"), valueFromString("int:-1")};
|
||||||
{Operation::valueFromString("QString:ELIL"), Operation::valueFromString("int:-1")});
|
|
||||||
|
|
||||||
QVariantMap testMap;
|
QVariantMap testMap;
|
||||||
|
|
||||||
// add to empty map
|
// add to empty map
|
||||||
auto result = appendListToMap(testMap, "some key", valueList);
|
bool result = AddValueData{"some key", valueList}.appendListToMap(testMap);
|
||||||
|
|
||||||
if (result)
|
if (result)
|
||||||
return false;
|
return false;
|
||||||
@@ -137,19 +136,19 @@ bool AddValueOperation::test() const
|
|||||||
testMap.insert(QLatin1String("aKey"), "withAString");
|
testMap.insert(QLatin1String("aKey"), "withAString");
|
||||||
|
|
||||||
// append to a value
|
// append to a value
|
||||||
result = appendListToMap(testMap, "aKey", valueList);
|
result = AddValueData{"aKey", valueList}.appendListToMap(testMap);
|
||||||
|
|
||||||
if (result)
|
if (result)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
testMap = AddKeysOperation::addKeys(testMap, testKvpList);
|
testMap = AddKeysData{testKvpList}.addKeys(testMap);
|
||||||
|
|
||||||
// quick sanity check
|
// quick sanity check
|
||||||
if (testMap.count() != 3 && testDataList.count() != 2 && testKvpList.count() != 3)
|
if (testMap.count() != 3 && testDataList.count() != 2 && testKvpList.count() != 3)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// successful adding of values
|
// successful adding of values
|
||||||
result = appendListToMap(testMap, "test/bar", valueList);
|
result = AddValueData{"test/bar", valueList}.appendListToMap(testMap);
|
||||||
if (!result)
|
if (!result)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -165,30 +164,28 @@ bool AddValueOperation::test() const
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool AddValueOperation::appendListToMap(QVariantMap &map,
|
bool AddValueData::appendListToMap(QVariantMap &map) const
|
||||||
const QString &key,
|
|
||||||
const QVariantList &values)
|
|
||||||
{
|
{
|
||||||
const auto data = GetOperation::get(map, key);
|
const QVariant data = GetOperation::get(map, m_key);
|
||||||
|
|
||||||
if (!data.isValid() || data.isNull()) {
|
if (!data.isValid() || data.isNull()) {
|
||||||
std::cerr << "Error: Could not retrieve value for key " << std::quoted(key.toStdString())
|
std::cerr << "Error: Could not retrieve value for key " << std::quoted(m_key.toStdString())
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.type() != QVariant::List) {
|
if (data.type() != QVariant::List) {
|
||||||
std::cerr << "Error: Data stored in " << std::quoted(key.toStdString())
|
std::cerr << "Error: Data stored in " << std::quoted(m_key.toStdString())
|
||||||
<< " is not a QVariantList." << std::endl;
|
<< " is not a QVariantList." << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto newList = qvariant_cast<QVariantList>(data);
|
auto newList = qvariant_cast<QVariantList>(data);
|
||||||
|
|
||||||
newList.append(values);
|
newList.append(m_values);
|
||||||
|
|
||||||
map = RmKeysOperation::rmKeys(map, {key});
|
map = RmKeysOperation::rmKeys(map, {m_key});
|
||||||
map = AddKeysOperation::addKeys(map, {Operation::KeyValuePair(key, newList)});
|
map = AddKeysData{{{m_key, newList}}}.addKeys(map);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@@ -28,25 +28,30 @@
|
|||||||
|
|
||||||
#include "operation.h"
|
#include "operation.h"
|
||||||
|
|
||||||
class AddValueOperation : public Operation
|
class AddValueData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QString name() const override;
|
bool appendListToMap(QVariantMap &map) const;
|
||||||
QString helpText() const override;
|
|
||||||
QString argumentsHelpText() const override;
|
|
||||||
|
|
||||||
bool setArguments(const QStringList &args) override;
|
|
||||||
|
|
||||||
int execute() const override;
|
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
|
||||||
bool test() const override;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static bool appendListToMap(QVariantMap &map, const QString &key, const QVariantList &values);
|
|
||||||
|
|
||||||
private:
|
|
||||||
QString m_file;
|
|
||||||
QString m_key;
|
QString m_key;
|
||||||
QVariantList m_values;
|
QVariantList m_values;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class AddValueOperation : public Operation, public AddValueData
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
QString name() const final;
|
||||||
|
QString helpText() const final;
|
||||||
|
QString argumentsHelpText() const final;
|
||||||
|
|
||||||
|
bool setArguments(const QStringList &args) final;
|
||||||
|
|
||||||
|
int execute() const final;
|
||||||
|
|
||||||
|
#ifdef WITH_TESTS
|
||||||
|
bool test() const final;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString m_file;
|
||||||
|
};
|
||||||
|
@@ -30,18 +30,17 @@
|
|||||||
class FindKeyOperation : public Operation
|
class FindKeyOperation : public Operation
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QString name() const;
|
QString name() const final;
|
||||||
QString helpText() const;
|
QString helpText() const final;
|
||||||
QString argumentsHelpText() const;
|
QString argumentsHelpText() const final;
|
||||||
|
|
||||||
bool setArguments(const QStringList &args);
|
bool setArguments(const QStringList &args) final;
|
||||||
|
|
||||||
int execute() const;
|
int execute() const final;
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
#ifdef WITH_TESTS
|
||||||
bool test() const;
|
bool test() const final;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static QStringList findKey(const QVariant &in, const QString &key,
|
static QStringList findKey(const QVariant &in, const QString &key,
|
||||||
const QString &prefix = QString());
|
const QString &prefix = QString());
|
||||||
|
|
||||||
|
@@ -53,7 +53,7 @@ bool FindValueOperation::setArguments(const QStringList &args)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant v = Operation::valueFromString(current);
|
QVariant v = valueFromString(current);
|
||||||
if (!v.isValid()) {
|
if (!v.isValid()) {
|
||||||
std::cerr << "Value for key '" << qPrintable(current) << "' is not valid." << std::endl << std::endl;
|
std::cerr << "Value for key '" << qPrintable(current) << "' is not valid." << std::endl << std::endl;
|
||||||
return false;
|
return false;
|
||||||
|
@@ -30,16 +30,16 @@
|
|||||||
class FindValueOperation : public Operation
|
class FindValueOperation : public Operation
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QString name() const;
|
QString name() const final;
|
||||||
QString helpText() const;
|
QString helpText() const final;
|
||||||
QString argumentsHelpText() const;
|
QString argumentsHelpText() const final;
|
||||||
|
|
||||||
bool setArguments(const QStringList &args);
|
bool setArguments(const QStringList &args) final;
|
||||||
|
|
||||||
int execute() const;
|
int execute() const final;
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
#ifdef WITH_TESTS
|
||||||
bool test() const;
|
bool test() const final;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static QStringList findValue(const QVariant &in, const QVariant &value,
|
static QStringList findValue(const QVariant &in, const QVariant &value,
|
||||||
|
@@ -30,16 +30,16 @@
|
|||||||
class GetOperation : public Operation
|
class GetOperation : public Operation
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QString name() const;
|
QString name() const final;
|
||||||
QString helpText() const;
|
QString helpText() const final;
|
||||||
QString argumentsHelpText() const;
|
QString argumentsHelpText() const final;
|
||||||
|
|
||||||
bool setArguments(const QStringList &args);
|
bool setArguments(const QStringList &args) final;
|
||||||
|
|
||||||
int execute() const;
|
int execute() const final;
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
#ifdef WITH_TESTS
|
||||||
bool test() const;
|
bool test() const final;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static QVariant get(const QVariantMap &map, const QString &key);
|
static QVariant get(const QVariantMap &map, const QString &key);
|
||||||
|
@@ -34,7 +34,7 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
QVariant Operation::valueFromString(const QString &v)
|
QVariant valueFromString(const QString &v)
|
||||||
{
|
{
|
||||||
int pos = v.indexOf(QLatin1Char(':'));
|
int pos = v.indexOf(QLatin1Char(':'));
|
||||||
if (pos <= 0)
|
if (pos <= 0)
|
||||||
@@ -62,23 +62,23 @@ QVariant Operation::valueFromString(const QString &v)
|
|||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
Operation::KeyValuePair::KeyValuePair(const QString &k, const QString &v) :
|
KeyValuePair::KeyValuePair(const QString &k, const QString &v) :
|
||||||
value(valueFromString(v))
|
value(valueFromString(v))
|
||||||
{
|
{
|
||||||
key = k.split(QLatin1Char('/'));
|
key = k.split(QLatin1Char('/'));
|
||||||
}
|
}
|
||||||
|
|
||||||
Operation::KeyValuePair::KeyValuePair(const QString &k, const QVariant &v) :
|
KeyValuePair::KeyValuePair(const QString &k, const QVariant &v) :
|
||||||
value(v)
|
value(v)
|
||||||
{
|
{
|
||||||
key = k.split(QLatin1Char('/'));
|
key = k.split(QLatin1Char('/'));
|
||||||
}
|
}
|
||||||
|
|
||||||
Operation::KeyValuePair::KeyValuePair(const QStringList &k, const QString &v) :
|
KeyValuePair::KeyValuePair(const QStringList &k, const QString &v) :
|
||||||
key(k), value(valueFromString(v))
|
key(k), value(valueFromString(v))
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
Operation::KeyValuePair::KeyValuePair(const QStringList &k, const QVariant &v) :
|
KeyValuePair::KeyValuePair(const QStringList &k, const QVariant &v) :
|
||||||
key(k), value(v)
|
key(k), value(v)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
@@ -30,10 +30,8 @@
|
|||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
|
||||||
class Operation
|
class KeyValuePair
|
||||||
{
|
{
|
||||||
public:
|
|
||||||
class KeyValuePair {
|
|
||||||
public:
|
public:
|
||||||
KeyValuePair(const QString &k, const QString &v);
|
KeyValuePair(const QString &k, const QString &v);
|
||||||
KeyValuePair(const QString &k, const QVariant &v);
|
KeyValuePair(const QString &k, const QVariant &v);
|
||||||
@@ -43,8 +41,14 @@ public:
|
|||||||
QStringList key;
|
QStringList key;
|
||||||
QVariant value;
|
QVariant value;
|
||||||
};
|
};
|
||||||
typedef QList<KeyValuePair> KeyValuePairList;
|
|
||||||
|
|
||||||
|
using KeyValuePairList = QList<KeyValuePair>;
|
||||||
|
|
||||||
|
QVariant valueFromString(const QString &v);
|
||||||
|
|
||||||
|
class Operation
|
||||||
|
{
|
||||||
|
public:
|
||||||
virtual ~Operation() { }
|
virtual ~Operation() { }
|
||||||
|
|
||||||
virtual QString name() const = 0;
|
virtual QString name() const = 0;
|
||||||
@@ -61,6 +65,4 @@ public:
|
|||||||
|
|
||||||
static QVariantMap load(const QString &file);
|
static QVariantMap load(const QString &file);
|
||||||
bool save(const QVariantMap &map, const QString &file) const;
|
bool save(const QVariantMap &map, const QString &file) const;
|
||||||
|
|
||||||
static QVariant valueFromString(const QString &v);
|
|
||||||
};
|
};
|
||||||
|
@@ -85,7 +85,7 @@ int RmCMakeOperation::execute() const
|
|||||||
if (map.isEmpty())
|
if (map.isEmpty())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
QVariantMap result = rmCMake(map, m_id);
|
QVariantMap result = RmCMakeData{m_id}.rmCMake(map);
|
||||||
if (result == map)
|
if (result == map)
|
||||||
return 2;
|
return 2;
|
||||||
|
|
||||||
@@ -98,20 +98,20 @@ bool RmCMakeOperation::test() const
|
|||||||
// Add cmakes:
|
// Add cmakes:
|
||||||
QVariantMap map = AddCMakeOperation::initializeCMake();
|
QVariantMap map = AddCMakeOperation::initializeCMake();
|
||||||
const QVariantMap emptyMap = map;
|
const QVariantMap emptyMap = map;
|
||||||
map = AddCMakeOperation::addCMake(map, "testId", "name", "/tmp/test",
|
map = AddCMakeData{"testId", "name", "/tmp/test",
|
||||||
KeyValuePairList({KeyValuePair("ExtraKey", QVariant("ExtraValue"))}));
|
{{"ExtraKey", QVariant("ExtraValue")}}}.addCMake(map);
|
||||||
map = AddCMakeOperation::addCMake(map, "testId2", "other name", "/tmp/test2", KeyValuePairList());
|
map = AddCMakeData{"testId2", "other name", "/tmp/test2", {}}.addCMake(map);
|
||||||
|
|
||||||
QVariantMap result = rmCMake(QVariantMap(), "nonexistent");
|
QVariantMap result = RmCMakeData{"nonexistent"}.rmCMake(QVariantMap());
|
||||||
if (!result.isEmpty())
|
if (!result.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
result = rmCMake(map, "nonexistent");
|
result = RmCMakeData{"nonexistent"}.rmCMake(map);
|
||||||
if (result != map)
|
if (result != map)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Remove from map with both testId and testId2:
|
// Remove from map with both testId and testId2:
|
||||||
result = rmCMake(map, "testId2");
|
result = RmCMakeData{"testId2"}.rmCMake(map);
|
||||||
if (result == map
|
if (result == map
|
||||||
|| result.value(COUNT, 0).toInt() != 1
|
|| result.value(COUNT, 0).toInt() != 1
|
||||||
|| !result.contains(QString::fromLatin1(PREFIX) + "0")
|
|| !result.contains(QString::fromLatin1(PREFIX) + "0")
|
||||||
@@ -119,7 +119,7 @@ bool RmCMakeOperation::test() const
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Remove from map with both testId and testId2:
|
// Remove from map with both testId and testId2:
|
||||||
result = rmCMake(map, "testId");
|
result = RmCMakeData{"testId"}.rmCMake(map);
|
||||||
if (result == map
|
if (result == map
|
||||||
|| result.value(COUNT, 0).toInt() != 1
|
|| result.value(COUNT, 0).toInt() != 1
|
||||||
|| !result.contains(QString::fromLatin1(PREFIX) + "0")
|
|| !result.contains(QString::fromLatin1(PREFIX) + "0")
|
||||||
@@ -127,7 +127,7 @@ bool RmCMakeOperation::test() const
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Remove from map without testId!
|
// Remove from map without testId!
|
||||||
result = rmCMake(result, "testId2");
|
result = RmCMakeData{"testId2"}.rmCMake(result);
|
||||||
if (result != emptyMap)
|
if (result != emptyMap)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -135,7 +135,7 @@ bool RmCMakeOperation::test() const
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QVariantMap RmCMakeOperation::rmCMake(const QVariantMap &map, const QString &id)
|
QVariantMap RmCMakeData::rmCMake(const QVariantMap &map) const
|
||||||
{
|
{
|
||||||
// Find count of cmakes:
|
// Find count of cmakes:
|
||||||
bool ok;
|
bool ok;
|
||||||
@@ -148,7 +148,7 @@ QVariantMap RmCMakeOperation::rmCMake(const QVariantMap &map, const QString &id)
|
|||||||
QVariantList cmList;
|
QVariantList cmList;
|
||||||
for (int i = 0; i < count; ++i) {
|
for (int i = 0; i < count; ++i) {
|
||||||
QVariantMap cmData = GetOperation::get(map, QString::fromLatin1(PREFIX) + QString::number(i)).toMap();
|
QVariantMap cmData = GetOperation::get(map, QString::fromLatin1(PREFIX) + QString::number(i)).toMap();
|
||||||
if (cmData.value(ID).toString() != id)
|
if (cmData.value(ID).toString() != m_id)
|
||||||
cmList.append(cmData);
|
cmList.append(cmData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -27,25 +27,26 @@
|
|||||||
|
|
||||||
#include "operation.h"
|
#include "operation.h"
|
||||||
|
|
||||||
#include <QString>
|
class RmCMakeData
|
||||||
|
|
||||||
class RmCMakeOperation : public Operation
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QString name() const;
|
QVariantMap rmCMake(const QVariantMap &map) const;
|
||||||
QString helpText() const;
|
|
||||||
QString argumentsHelpText() const;
|
|
||||||
|
|
||||||
bool setArguments(const QStringList &args);
|
|
||||||
|
|
||||||
int execute() const;
|
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
|
||||||
bool test() const;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static QVariantMap rmCMake(const QVariantMap &map, const QString &id);
|
|
||||||
|
|
||||||
private:
|
|
||||||
QString m_id;
|
QString m_id;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class RmCMakeOperation : public Operation, public RmCMakeData
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
QString name() const final;
|
||||||
|
QString helpText() const final;
|
||||||
|
QString argumentsHelpText() const final;
|
||||||
|
|
||||||
|
bool setArguments(const QStringList &args) final;
|
||||||
|
|
||||||
|
int execute() const final;
|
||||||
|
|
||||||
|
#ifdef WITH_TESTS
|
||||||
|
bool test() const final;
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
@@ -95,16 +95,15 @@ bool RmDebuggerOperation::test() const
|
|||||||
{
|
{
|
||||||
|
|
||||||
QVariantMap map =
|
QVariantMap map =
|
||||||
AddDebuggerOperation::addDebugger(AddDebuggerOperation::initializeDebuggers(),
|
AddDebuggerData{QLatin1String("id1"), QLatin1String("Name1"),
|
||||||
QLatin1String("id1"), QLatin1String("Name1"),
|
|
||||||
2, QLatin1String("/tmp/debugger1"),
|
2, QLatin1String("/tmp/debugger1"),
|
||||||
QStringList() << QLatin1String("test11") << QLatin1String("test12"),
|
{"test11", "test12"}, {}}
|
||||||
KeyValuePairList());
|
.addDebugger(AddDebuggerOperation::initializeDebuggers());
|
||||||
map =
|
|
||||||
AddDebuggerOperation::addDebugger(map, QLatin1String("id2"), QLatin1String("Name2"),
|
map = AddDebuggerData{QLatin1String("id2"), QLatin1String("Name2"),
|
||||||
2, QLatin1String("/tmp/debugger2"),
|
2, QLatin1String("/tmp/debugger2"),
|
||||||
QStringList() << QLatin1String("test21") << QLatin1String("test22"),
|
{"test21", "test22"}, {}}
|
||||||
KeyValuePairList());
|
.addDebugger(map);
|
||||||
|
|
||||||
QVariantMap result = rmDebugger(map, QLatin1String("id2"));
|
QVariantMap result = rmDebugger(map, QLatin1String("id2"));
|
||||||
if (result.count() != 3
|
if (result.count() != 3
|
||||||
@@ -178,6 +177,6 @@ QVariantMap RmDebuggerOperation::rmDebugger(const QVariantMap &map, const QStrin
|
|||||||
debuggerList.at(i));
|
debuggerList.at(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
return AddKeysOperation::addKeys(result, data);
|
return AddKeysData{data}.addKeys(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -98,40 +98,40 @@ int RmKitOperation::execute() const
|
|||||||
bool RmKitOperation::test() const
|
bool RmKitOperation::test() const
|
||||||
{
|
{
|
||||||
QVariantMap tcMap = AddToolChainOperation::initializeToolChains();
|
QVariantMap tcMap = AddToolChainOperation::initializeToolChains();
|
||||||
tcMap = AddToolChainOperation::addToolChain(tcMap, "{tc-id}", "langId", "TC", "/usr/bin/gcc",
|
tcMap = AddToolChainData{"{tc-id}", "langId", "TC", "/usr/bin/gcc",
|
||||||
"x86-linux-generic-elf-32bit",
|
"x86-linux-generic-elf-32bit", "x86-linux-generic-elf-32bit", {}}
|
||||||
"x86-linux-generic-elf-32bit",
|
.addToolChain(tcMap);
|
||||||
KeyValuePairList());
|
|
||||||
|
|
||||||
QVariantMap qtMap = AddQtOperation::initializeQtVersions();
|
QVariantMap qtMap = AddQtData::initializeQtVersions();
|
||||||
qtMap = AddQtOperation::addQt(qtMap, "{qt-id}", "Qt", "desktop-qt", "/usr/bin/qmake",
|
qtMap = AddQtData{"{qt-id}", "Qt", "desktop-qt", "/usr/bin/qmake", {}, {}}.addQt(qtMap);
|
||||||
KeyValuePairList(), QStringList());
|
|
||||||
|
|
||||||
QVariantMap devMap = AddDeviceOperation::initializeDevices();
|
QVariantMap devMap = AddDeviceOperation::initializeDevices();
|
||||||
devMap = AddDeviceOperation::addDevice(devMap, "{dev-id}", "Dev", 0, 0,
|
devMap = AddDeviceData{"{dev-id}", "Dev", 0, 0,
|
||||||
"HWplatform", "SWplatform",
|
"HWplatform", "SWplatform",
|
||||||
"localhost", "10000-11000", "localhost", "", 42,
|
"localhost", "10000-11000", "localhost", "", 42,
|
||||||
"desktop", "", 22, 10000, "uname", 1,
|
"desktop", "", 22, 10000, "uname", 1,
|
||||||
KeyValuePairList());
|
KeyValuePairList()}
|
||||||
|
.addDevice(devMap);
|
||||||
|
|
||||||
QHash<QString, QString> tcs;
|
QHash<QString, QString> tcs;
|
||||||
tcs.insert("Cxx", "{tc-id}");
|
tcs.insert("Cxx", "{tc-id}");
|
||||||
|
|
||||||
QVariantMap map =
|
QVariantMap map =
|
||||||
AddKitOperation::addKit(AddKitOperation::initializeKits(), tcMap, qtMap, devMap,
|
AddKitData{"testId", "Test Qt Version", "/tmp/icon.png", QString(), 1,
|
||||||
QVariantMap(),
|
|
||||||
"testId", "Test Qt Version", "/tmp/icon.png", QString(), 1,
|
|
||||||
"/usr/bin/gdb-test", "Desktop", QString(), QString(), tcs,
|
"/usr/bin/gdb-test", "Desktop", QString(), QString(), tcs,
|
||||||
"{qt-id}", "unsupported/mkspec",
|
"{qt-id}", "unsupported/mkspec",
|
||||||
QString(), QString(), QString(), QString(), QString(), QStringList(), QStringList(),
|
QString(), QString(), QString(), QString(), QString(), QStringList(), QStringList(),
|
||||||
KeyValuePairList() << KeyValuePair("PE.Profile.Data/extraData", QVariant("extraValue")));
|
{{"PE.Profile.Data/extraData", QVariant("extraValue")}}}
|
||||||
map =
|
.addKit(AddKitData::initializeKits(), tcMap, qtMap, devMap, {});
|
||||||
AddKitOperation::addKit(map, tcMap, qtMap, devMap, QVariantMap(), "testId2", "Test Qt Version",
|
|
||||||
|
|
||||||
|
map = AddKitData{"testId2", "Test Qt Version",
|
||||||
"/tmp/icon2.png", QString(), 1, "/usr/bin/gdb-test2",
|
"/tmp/icon2.png", QString(), 1, "/usr/bin/gdb-test2",
|
||||||
"Desktop", QString(), QString(), tcs, "{qt-id}",
|
"Desktop", QString(), QString(), tcs, "{qt-id}",
|
||||||
"unsupported/mkspec2",
|
"unsupported/mkspec2",
|
||||||
QString(), QString(), QString(), QString(), QString(), QStringList(), QStringList(),
|
QString(), QString(), QString(), QString(), QString(), QStringList(), QStringList(),
|
||||||
KeyValuePairList() << KeyValuePair("PE.Profile.Data/extraData", QVariant("extraValue2")));
|
{{"PE.Profile.Data/extraData", QVariant("extraValue2")}}}
|
||||||
|
.addKit(map, tcMap, qtMap, devMap, {});
|
||||||
|
|
||||||
QVariantMap result = rmKit(map, "testId");
|
QVariantMap result = rmKit(map, "testId");
|
||||||
if (result.count() != 4
|
if (result.count() != 4
|
||||||
@@ -212,5 +212,5 @@ QVariantMap RmKitOperation::rmKit(const QVariantMap &map, const QString &id)
|
|||||||
data << KeyValuePair(QString::fromLatin1(PREFIX) + QString::number(i),
|
data << KeyValuePair(QString::fromLatin1(PREFIX) + QString::number(i),
|
||||||
profileList.at(i));
|
profileList.at(i));
|
||||||
|
|
||||||
return AddKeysOperation::addKeys(result, data);
|
return AddKeysData{data}.addKeys(result);
|
||||||
}
|
}
|
||||||
|
@@ -95,19 +95,17 @@ int RmQtOperation::execute() const
|
|||||||
bool RmQtOperation::test() const
|
bool RmQtOperation::test() const
|
||||||
{
|
{
|
||||||
// Add toolchain:
|
// Add toolchain:
|
||||||
QVariantMap map = AddQtOperation::initializeQtVersions();
|
QVariantMap map = AddQtData::initializeQtVersions();
|
||||||
|
|
||||||
QVariantMap result = rmQt(QVariantMap(), QLatin1String("nonexistant"));
|
QVariantMap result = rmQt(QVariantMap(), QLatin1String("nonexistant"));
|
||||||
if (result != map)
|
if (result != map)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
map = AddQtOperation::addQt(map, QLatin1String("testId"), QLatin1String("name"), QLatin1String("type"),
|
map = AddQtData{"testId", "name", "type", "/tmp/test", {},
|
||||||
QLatin1String("/tmp/test"),
|
{{QLatin1String("ExtraKey"), QVariant(QLatin1String("ExtraValue"))}}}
|
||||||
KeyValuePairList() << KeyValuePair(QLatin1String("ExtraKey"), QVariant(QLatin1String("ExtraValue"))),
|
.addQt(map);
|
||||||
QStringList());
|
|
||||||
map = AddQtOperation::addQt(map, QLatin1String("testId2"), QLatin1String("other name"), QLatin1String("type"),
|
map = AddQtData{"testId2", "other name", "type", "/tmp/test2", {}, {}}.addQt(map);
|
||||||
QLatin1String("/tmp/test2"),
|
|
||||||
KeyValuePairList(), QStringList());
|
|
||||||
|
|
||||||
result = rmQt(map, QLatin1String("nonexistant"));
|
result = rmQt(map, QLatin1String("nonexistant"));
|
||||||
if (result != map)
|
if (result != map)
|
||||||
@@ -149,7 +147,7 @@ QVariantMap RmQtOperation::rmQt(const QVariantMap &map, const QString &id)
|
|||||||
qtList.append(qtData);
|
qtList.append(qtData);
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariantMap newMap = AddQtOperation::initializeQtVersions();
|
QVariantMap newMap = AddQtData::initializeQtVersions();
|
||||||
for (int i = 0; i < qtList.count(); ++i)
|
for (int i = 0; i < qtList.count(); ++i)
|
||||||
newMap.insert(QString::fromLatin1(PREFIX) + QString::number(i), qtList.at(i));
|
newMap.insert(QString::fromLatin1(PREFIX) + QString::number(i), qtList.at(i));
|
||||||
|
|
||||||
|
@@ -97,11 +97,13 @@ bool RmToolChainOperation::test() const
|
|||||||
{
|
{
|
||||||
// Add toolchain:
|
// Add toolchain:
|
||||||
QVariantMap map = AddToolChainOperation::initializeToolChains();
|
QVariantMap map = AddToolChainOperation::initializeToolChains();
|
||||||
map = AddToolChainOperation::addToolChain(map, "testId", "langId", "name", "/tmp/test", "test-abi",
|
map = AddToolChainData{"testId", "langId", "name", "/tmp/test", "test-abi",
|
||||||
"test-abi,test-abi2",
|
"test-abi,test-abi2", {{"ExtraKey", QVariant("ExtraValue")}}}
|
||||||
KeyValuePairList({KeyValuePair("ExtraKey", QVariant("ExtraValue"))}));
|
.addToolChain(map);
|
||||||
map = AddToolChainOperation::addToolChain(map, "testId2", "langId", "other name", "/tmp/test2", "test-abi",
|
|
||||||
"test-abi,test-abi2", KeyValuePairList());
|
map = AddToolChainData{"testId2", "langId", "other name", "/tmp/test2", "test-abi",
|
||||||
|
"test-abi,test-abi2", {}}
|
||||||
|
.addToolChain(map);
|
||||||
|
|
||||||
QVariantMap result = rmToolChain(QVariantMap(), "nonexistent");
|
QVariantMap result = rmToolChain(QVariantMap(), "nonexistent");
|
||||||
if (!result.isEmpty())
|
if (!result.isEmpty())
|
||||||
|
@@ -32,16 +32,16 @@
|
|||||||
class RmToolChainOperation : public Operation
|
class RmToolChainOperation : public Operation
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QString name() const;
|
QString name() const final;
|
||||||
QString helpText() const;
|
QString helpText() const final;
|
||||||
QString argumentsHelpText() const;
|
QString argumentsHelpText() const final;
|
||||||
|
|
||||||
bool setArguments(const QStringList &args);
|
bool setArguments(const QStringList &args) final;
|
||||||
|
|
||||||
int execute() const;
|
int execute() const final;
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
#ifdef WITH_TESTS
|
||||||
bool test() const;
|
bool test() const final;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static QVariantMap rmToolChain(const QVariantMap &map, const QString &id);
|
static QVariantMap rmToolChain(const QVariantMap &map, const QString &id);
|
||||||
|
Reference in New Issue
Block a user