diff options
author | Tobias Hunger <tobias.hunger@qt.io> | 2016-11-17 14:07:03 +0100 |
---|---|---|
committer | Tobias Hunger <tobias.hunger@qt.io> | 2016-11-23 12:06:08 +0000 |
commit | 2d777a8082c41e15e8f337eea032a4fdaf5ce8b2 (patch) | |
tree | 0d0db0f3b057f63ec223b6f1d2aba0fc01fbbd61 | |
parent | 5f6a3f90fb8dc8f125dfa13896724e8a682bfcc5 (diff) | |
download | qt-creator-2d777a8082c41e15e8f337eea032a4fdaf5ce8b2.tar.gz |
SDKtool: Make AddKit handle cmake related settings
--cmake <ID>, --cmake-generator <GEN>:<EXTRA>:<TOOLSET>:<PLATFORM>
and --cmake-config "<KEY>:<TYPE>=<VALUE>" are now supported.
When using --cmake-generator <GEN> must be set, the rest is optional.
--cmake-config may be repeated several times. All will end up in the
kit in the sequence they appear on the command line.
Task-number: QTCREATORBUG-17290
Change-Id: Ida79d65095682331f53d0fbb36d606ad16e6c4ac
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
-rw-r--r-- | src/tools/sdktool/addkitoperation.cpp | 140 | ||||
-rw-r--r-- | src/tools/sdktool/addkitoperation.h | 16 | ||||
-rw-r--r-- | src/tools/sdktool/rmkitoperation.cpp | 9 |
3 files changed, 133 insertions, 32 deletions
diff --git a/src/tools/sdktool/addkitoperation.cpp b/src/tools/sdktool/addkitoperation.cpp index b2ebc9f80c..aadeb00d7f 100644 --- a/src/tools/sdktool/addkitoperation.cpp +++ b/src/tools/sdktool/addkitoperation.cpp @@ -25,6 +25,7 @@ #include "addkitoperation.h" +#include "addcmakeoperation.h" #include "addkeysoperation.h" #include "addtoolchainoperation.h" #include "addqtoperation.h" @@ -66,6 +67,9 @@ const char SYSROOT[] = "PE.Profile.SysRoot"; const char TOOLCHAIN[] = "PE.Profile.ToolChains"; const char MKSPEC[] = "QtPM4.mkSpecInformation"; const char QT[] = "QtSupport.QtInformation"; +const char CMAKE_ID[] = "CMakeProjectManager.CMakeKitInformation"; +const char CMAKE_GENERATOR[] = "CMake.GeneratorKitInformation"; +const char CMAKE_CONFIGURATION[] = "CMake.ConfigurationKitInformation"; AddKitOperation::AddKitOperation() : m_debuggerEngine(0) @@ -100,6 +104,10 @@ QString AddKitOperation::argumentsHelpText() const " --qt <ID> Qt of the new kit.\n" " --mkspec <PATH> mkspec of the new kit.\n" " --env <VALUE> add a custom environment setting. [may be repeated]\n" + " --cmake <ID> set a cmake tool.\n" + " --cmake-generator <GEN>:<EXTRA>:<TOOLSET>:<PLATFORM>\n" + " set a cmake generator.\n" + " --cmake-config <KEY:TYPE=VALUE> set a cmake configuration value [may be repeated]\n" " <KEY> <TYPE:VALUE> extra key value pairs\n"); } @@ -233,6 +241,36 @@ bool AddKitOperation::setArguments(const QStringList &args) continue; } + if (current == "--cmake") { + if (next.isNull()) + return false; + ++i; + m_cmakeId = next; + continue; + } + + if (current == "--cmake-generator") { + if (next.isNull()) + return false; + ++i; + QStringList parts = next.split(':'); + m_cmakeGenerator = parts.count() >= 1 ? parts.at(0) : QString(); + m_cmakeExtraGenerator = parts.count() >= 2 ? parts.at(1) : QString(); + m_cmakeGeneratorToolset = parts.count() >= 3 ? parts.at(2) : QString(); + m_cmakeGeneratorPlatform = parts.count() >= 4 ? parts.at(3) : QString(); + if (parts.count() > 4) + return false; + continue; + } + + if (current == "--cmake-config") { + if (next.isNull()) + return false; + ++i; + m_cmakeConfiguration.append(next); + continue; + } + if (next.isNull()) return false; ++i; // skip next; @@ -242,9 +280,6 @@ bool AddKitOperation::setArguments(const QStringList &args) m_extra << pair; } - if (m_icon.isEmpty()) - m_icon = ":///DESKTOP///"; - if (m_id.isEmpty()) std::cerr << "No id given for kit." << std::endl << std::endl; if (m_displayName.isEmpty()) @@ -267,7 +302,9 @@ int AddKitOperation::execute() const QVariantMap result = addKit(map, m_id, m_displayName, m_icon, m_debuggerId, m_debuggerEngine, m_debugger, m_deviceType, m_device, m_sysRoot, m_tcs, m_qt, - m_mkspec, m_env, m_extra); + m_mkspec, m_cmakeId, m_cmakeGenerator, m_cmakeExtraGenerator, + m_cmakeGeneratorToolset, m_cmakeGeneratorPlatform, m_cmakeConfiguration, + m_env, m_extra); if (result.isEmpty() || map == result) return 2; @@ -311,27 +348,33 @@ bool AddKitOperation::test() const tcs.insert("Cxx", "{tcXX-id}"); // Fail if TC is not there: - QVariantMap empty = addKit(map, tcMap, qtMap, devMap, + QVariantMap empty = addKit(map, tcMap, qtMap, devMap, QVariantMap(), "testId", "Test Kit", "/tmp/icon.png", QString(), 1, "/usr/bin/gdb-test", "Desktop", "{dev-id}", QString(), - tcs, "{qt-id}", "unsupported/mkspec", QStringList(), + tcs, "{qt-id}", "unsupported/mkspec", + QString(), QString(), QString(), QString(), QString(), QStringList(), + QStringList(), KeyValuePairList({ KeyValuePair("PE.Profile.Data/extraData", QVariant("extraValue")) })); if (!empty.isEmpty()) return false; // Do not fail if TC is an ABI: tcs.clear(); tcs.insert("C", "x86-linux-generic-elf-64bit"); - empty = addKit(map, tcMap, qtMap, devMap, "testId", "Test Kit", "/tmp/icon.png", QString(), 1, + empty = addKit(map, tcMap, qtMap, devMap, QVariantMap(), + "testId", "Test Kit", "/tmp/icon.png", QString(), 1, "/usr/bin/gdb-test", "Desktop", "{dev-id}", QString(), - tcs, "{qt-id}", "unsupported/mkspec", env, + tcs, "{qt-id}", "unsupported/mkspec", + QString(), QString(), QString(), QString(), QString(), QStringList(), env, KeyValuePairList({ KeyValuePair("PE.Profile.Data/extraData", QVariant("extraValue")) })); if (empty.isEmpty()) return false; // QTCREATORBUG-11983, mach_o was not covered by the first attempt to fix this. tcs.insert("D", "x86-macos-generic-mach_o-64bit"); - empty = addKit(map, tcMap, qtMap, devMap, "testId", "Test Kit", "/tmp/icon.png", QString(), 1, + empty = addKit(map, tcMap, qtMap, devMap, QVariantMap(), + "testId", "Test Kit", "/tmp/icon.png", QString(), 1, "/usr/bin/gdb-test", "Desktop", "{dev-id}", QString(), - tcs, "{qt-id}", "unsupported/mkspec", env, + tcs, "{qt-id}", "unsupported/mkspec", + QString(), QString(), QString(), QString(), QString(), QStringList(), env, KeyValuePairList({ KeyValuePair("PE.Profile.Data/extraData", QVariant("extraValue")) })); if (empty.isEmpty()) return false; @@ -340,24 +383,30 @@ bool AddKitOperation::test() const tcs.insert("Cxx", "{tc-id}"); // Fail if Qt is not there: - empty = addKit(map, tcMap, qtMap, devMap, "testId", "Test Kit", "/tmp/icon.png", QString(), 1, + empty = addKit(map, tcMap, qtMap, devMap, QVariantMap(), + "testId", "Test Kit", "/tmp/icon.png", QString(), 1, "/usr/bin/gdb-test", "Desktop", "{dev-id}", QString(), tcs, "{qtXX-id}", - "unsupported/mkspec", env, + "unsupported/mkspec", + QString(), QString(), QString(), QString(), QString(), QStringList(), env, KeyValuePairList({ KeyValuePair("PE.Profile.Data/extraData", QVariant("extraValue")) })); if (!empty.isEmpty()) return false; // Fail if dev is not there: - empty = addKit(map, tcMap, qtMap, devMap, "testId", "Test Kit", "/tmp/icon.png", QString(), 1, + empty = addKit(map, tcMap, qtMap, devMap, QVariantMap(), + "testId", "Test Kit", "/tmp/icon.png", QString(), 1, "/usr/bin/gdb-test", "Desktop", "{devXX-id}", QString(), tcs, "{qt-id}", - "unsupported/mkspec", env, + "unsupported/mkspec", + QString(), QString(), QString(), QString(), QString(), QStringList(), env, KeyValuePairList({ KeyValuePair("PE.Profile.Data/extraData", QVariant("extraValue")) })); if (!empty.isEmpty()) return false; // Profile 0: - map = addKit(map, tcMap, qtMap, devMap, "testId", "Test Kit", "/tmp/icon.png", QString(), 1, + map = addKit(map, tcMap, qtMap, devMap, QVariantMap(), + "testId", "Test Kit", "/tmp/icon.png", QString(), 1, "/usr/bin/gdb-test", "Desktop", QString(), QString(), tcs, "{qt-id}", - "unsupported/mkspec", env, + "unsupported/mkspec", + QString(), QString(), QString(), QString(), QString(), QStringList(), env, KeyValuePairList({ KeyValuePair("PE.Profile.Data/extraData", QVariant("extraValue")) })); if (map.count() != 4 @@ -392,17 +441,21 @@ bool AddKitOperation::test() const return false; // Ignore existing ids: - QVariantMap result = addKit(map, tcMap, qtMap, devMap, "testId", "Test Qt Version X", + QVariantMap result = addKit(map, tcMap, qtMap, devMap, QVariantMap(), + "testId", "Test Qt Version X", "/tmp/icon3.png", QString(), 1, "/usr/bin/gdb-test3", "Desktop", - QString(), QString(), tcs, "{qt-id}", "unsupported/mkspec", env, + QString(), QString(), tcs, "{qt-id}", "unsupported/mkspec", + QString(), QString(), QString(), QString(), QString(), QStringList(), env, KeyValuePairList({ KeyValuePair("PE.Profile.Data/extraData", QVariant("extraValue")) })); if (!result.isEmpty()) return false; // Profile 1: Make sure name is unique: - map = addKit(map, tcMap, qtMap, devMap, "testId2", "Test Kit2", "/tmp/icon2.png", QString(), 1, + map = addKit(map, tcMap, qtMap, devMap, QVariantMap(), + "testId2", "Test Kit2", "/tmp/icon2.png", QString(), 1, "/usr/bin/gdb-test2", "Desktop", "{dev-id}", "/sys/root\\\\", tcs, - "{qt-id}", "unsupported/mkspec", env, + "{qt-id}", "unsupported/mkspec", + QString(), QString(), QString(), QString(), QString(), QStringList(), env, KeyValuePairList({ KeyValuePair("PE.Profile.Data/extraData", QVariant("extraValue")) })); if (map.count() != 5 || !map.contains(VERSION) || map.value(VERSION).toInt() != 1 @@ -442,9 +495,11 @@ bool AddKitOperation::test() const return false; // Profile 2: Test debugger id: - map = addKit(map, tcMap, qtMap, devMap, "test with debugger Id", "Test debugger Id", + map = addKit(map, tcMap, qtMap, devMap, QVariantMap(), + "test with debugger Id", "Test debugger Id", "/tmp/icon2.png", "debugger Id", 0, QString(), "Desktop", QString(), QString(), - tcs, "{qt-id}", "unsupported/mkspec", env, + tcs, "{qt-id}", "unsupported/mkspec", + QString(), QString(), QString(), QString(), QString(), QStringList(), env, KeyValuePairList({ KeyValuePair("PE.Profile.Data/extraData", QVariant("extraValue")) })); if (map.count() != 6 || !map.contains(VERSION) || map.value(VERSION).toInt() != 1 @@ -484,25 +539,38 @@ QVariantMap AddKitOperation::addKit(const QVariantMap &map, 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 QStringList &env, + 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 qtMap = load("QtVersions"); QVariantMap devMap = load("Devices"); + QVariantMap cmakeMap = load("cmaketools"); - return addKit(map, tcMap, qtMap, devMap, id, displayName, icon, debuggerId, debuggerType, - debugger, deviceType, device, sysRoot, tcs, qt, mkspec, env, extra); + return addKit(map, tcMap, qtMap, devMap, cmakeMap, id, displayName, icon, debuggerId, debuggerType, + debugger, deviceType, device, sysRoot, tcs, qt, mkspec, + cmakeId, cmakeGenerator, cmakeExtraGenerator, cmakeGeneratorToolset, + cmakeGeneratorPlatform, cmakeConfiguration, + env, extra); } QVariantMap AddKitOperation::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 QStringList &env, + 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: @@ -541,6 +609,10 @@ QVariantMap AddKitOperation::addKit(const QVariantMap &map, const QVariantMap &t std::cerr << "Error: Device " << qPrintable(device) << " does not exist." << std::endl; return QVariantMap(); } + if (!cmakeId.isEmpty() && !AddCMakeOperation::exists(cmakeMap, cmakeId)) { + std::cerr << "Error: CMake tool " << qPrintable(cmakeId) << " does not exist." << std::endl; + return QVariantMap(); + } // Find position to insert: bool ok; @@ -592,6 +664,22 @@ QVariantMap AddKitOperation::addKit(const QVariantMap &map, const QVariantMap &t data << KeyValuePair({ kit, DATA, QT }, QVariant(qtId)); if (!mkspec.isNull()) data << KeyValuePair({ kit, DATA, MKSPEC }, QVariant(mkspec)); + if (!cmakeId.isNull()) + data << KeyValuePair({kit, CMAKE_ID}, QVariant(cmakeId)); + if (!cmakeGenerator.isNull()) { + QVariantMap generatorMap; + generatorMap.insert("Generator", cmakeGenerator); + if (!cmakeExtraGenerator.isNull()) + generatorMap.insert("ExtraGenerator", cmakeExtraGenerator); + if (!cmakeGeneratorToolset.isNull()) + generatorMap.insert("Toolset", cmakeGeneratorToolset); + if (!cmakeGeneratorPlatform.isNull()) + generatorMap.insert("Platform", cmakeGeneratorPlatform); + data << KeyValuePair({ kit, CMAKE_GENERATOR }, generatorMap); + } + if (!cmakeConfiguration.isEmpty()) { + data << KeyValuePair({kit, CMAKE_CONFIGURATION}, QVariant(cmakeConfiguration)); + } if (!env.isEmpty()) data << KeyValuePair({ kit, DATA, ENV }, QVariant(env)); diff --git a/src/tools/sdktool/addkitoperation.h b/src/tools/sdktool/addkitoperation.h index ef79318b58..196e58a847 100644 --- a/src/tools/sdktool/addkitoperation.h +++ b/src/tools/sdktool/addkitoperation.h @@ -52,20 +52,24 @@ public: 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 QStringList &env, + 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(); // internal: static QVariantMap addKit(const QVariantMap &map, const QVariantMap &tcMap, - const QVariantMap &qtMap, const QVariantMap &devMap, + 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 QStringList &env, + 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: @@ -81,6 +85,12 @@ private: QHash<QString, QString> m_tcs; QString m_qt; QString m_mkspec; + QString m_cmakeId; + QString m_cmakeGenerator; + QString m_cmakeExtraGenerator; + QString m_cmakeGeneratorToolset; + QString m_cmakeGeneratorPlatform; + QStringList m_cmakeConfiguration; QStringList m_env; KeyValuePairList m_extra; }; diff --git a/src/tools/sdktool/rmkitoperation.cpp b/src/tools/sdktool/rmkitoperation.cpp index 9bd313e43c..37dc58330e 100644 --- a/src/tools/sdktool/rmkitoperation.cpp +++ b/src/tools/sdktool/rmkitoperation.cpp @@ -119,15 +119,18 @@ bool RmKitOperation::test() const QVariantMap map = AddKitOperation::addKit(AddKitOperation::initializeKits(), tcMap, qtMap, devMap, + QVariantMap(), "testId", "Test Qt Version", "/tmp/icon.png", QString(), 1, "/usr/bin/gdb-test", "Desktop", QString(), QString(), tcs, - "{qt-id}", "unsupported/mkspec", QStringList(), + "{qt-id}", "unsupported/mkspec", + QString(), QString(), QString(), QString(), QString(), QStringList(), QStringList(), KeyValuePairList() << KeyValuePair("PE.Profile.Data/extraData", QVariant("extraValue"))); map = - AddKitOperation::addKit(map, tcMap, qtMap, devMap, "testId2", "Test Qt Version", + AddKitOperation::addKit(map, tcMap, qtMap, devMap, QVariantMap(), "testId2", "Test Qt Version", "/tmp/icon2.png", QString(), 1, "/usr/bin/gdb-test2", "Desktop", QString(), QString(), tcs, "{qt-id}", - "unsupported/mkspec2", QStringList(), + "unsupported/mkspec2", + QString(), QString(), QString(), QString(), QString(), QStringList(), QStringList(), KeyValuePairList() << KeyValuePair("PE.Profile.Data/extraData", QVariant("extraValue2"))); QVariantMap result = rmKit(map, "testId"); |