2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2012-09-18 15:58:07 +02:00
|
|
|
**
|
2014-01-07 13:27:11 +01:00
|
|
|
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
2012-10-02 09:12:39 +02:00
|
|
|
** Contact: http://www.qt-project.org/legal
|
2012-09-18 15:58:07 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2012-09-18 15:58:07 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and Digia. For licensing terms and
|
|
|
|
|
** conditions see http://qt.digia.com/licensing. For further information
|
|
|
|
|
** use the contact form at http://qt.digia.com/contact-us.
|
2012-09-18 15:58:07 +02:00
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
|
|
|
** General Public License version 2.1 as published by the Free Software
|
|
|
|
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
|
|
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
|
|
|
**
|
|
|
|
|
** In addition, as a special exception, Digia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
2012-09-18 15:58:07 +02:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2012-09-18 15:58:07 +02:00
|
|
|
|
|
|
|
|
#include "addkitoperation.h"
|
|
|
|
|
|
|
|
|
|
#include "addkeysoperation.h"
|
2014-03-04 11:06:51 +01:00
|
|
|
#include "addtoolchainoperation.h"
|
|
|
|
|
#include "addqtoperation.h"
|
|
|
|
|
#include "adddeviceoperation.h"
|
2012-09-18 15:58:07 +02:00
|
|
|
#include "findkeyoperation.h"
|
|
|
|
|
#include "findvalueoperation.h"
|
|
|
|
|
#include "getoperation.h"
|
|
|
|
|
#include "rmkeysoperation.h"
|
|
|
|
|
|
|
|
|
|
#include "settings.h"
|
|
|
|
|
|
2014-04-03 16:43:01 +02:00
|
|
|
#include <QRegExp>
|
|
|
|
|
|
2012-09-18 15:58:07 +02:00
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
|
|
// Qt version file stuff:
|
2013-10-29 16:44:24 +01:00
|
|
|
const char PREFIX[] = "Profile.";
|
|
|
|
|
const char VERSION[] = "Version";
|
|
|
|
|
const char COUNT[] = "Profile.Count";
|
|
|
|
|
const char DEFAULT[] = "Profile.Default";
|
2012-09-18 15:58:07 +02:00
|
|
|
|
|
|
|
|
// Kit:
|
2013-10-29 16:44:24 +01:00
|
|
|
const char ID[] = "PE.Profile.Id";
|
|
|
|
|
const char DISPLAYNAME[] = "PE.Profile.Name";
|
|
|
|
|
const char ICON[] = "PE.Profile.Icon";
|
|
|
|
|
const char AUTODETECTED[] = "PE.Profile.Autodetected";
|
|
|
|
|
const char SDK[] = "PE.Profile.SDK";
|
|
|
|
|
const char DATA[] = "PE.Profile.Data";
|
2012-09-18 15:58:07 +02:00
|
|
|
|
|
|
|
|
// Standard KitInformation:
|
2013-10-29 16:44:24 +01:00
|
|
|
const char DEBUGGER[] = "Debugger.Information";
|
|
|
|
|
const char DEBUGGER_ENGINE[] = "EngineType";
|
|
|
|
|
const char DEBUGGER_BINARY[] = "Binary";
|
|
|
|
|
const char DEVICE_TYPE[] = "PE.Profile.DeviceType";
|
2014-03-04 14:11:12 +01:00
|
|
|
const char DEVICE_ID[] = "PE.Profile.Device";
|
2013-10-29 16:44:24 +01:00
|
|
|
const char SYSROOT[] = "PE.Profile.SysRoot";
|
|
|
|
|
const char TOOLCHAIN[] = "PE.Profile.ToolChain";
|
|
|
|
|
const char MKSPEC[] = "QtPM4.mkSpecInformation";
|
|
|
|
|
const char QT[] = "QtSupport.QtInformation";
|
2012-09-18 15:58:07 +02:00
|
|
|
|
2012-09-28 10:13:56 +02:00
|
|
|
AddKitOperation::AddKitOperation()
|
|
|
|
|
: m_debuggerEngine(0)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-18 15:58:07 +02:00
|
|
|
QString AddKitOperation::name() const
|
|
|
|
|
{
|
|
|
|
|
return QLatin1String("addKit");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString AddKitOperation::helpText() const
|
|
|
|
|
{
|
|
|
|
|
return QLatin1String("add a Kit to Qt Creator");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString AddKitOperation::argumentsHelpText() const
|
|
|
|
|
{
|
2013-02-07 10:42:24 +01:00
|
|
|
return QLatin1String(" --id <ID> id of the new kit (required).\n"
|
|
|
|
|
" --name <NAME> display name of the new kit (required).\n"
|
2012-09-18 15:58:07 +02:00
|
|
|
" --icon <PATH> icon of the new kit.\n"
|
2013-10-29 16:40:57 +01:00
|
|
|
" --debuggerid <ID> the id of the debugger to use.\n"
|
|
|
|
|
" (not compatible with --debugger and --debuggerengine)\n"
|
2012-09-18 15:58:07 +02:00
|
|
|
" --debuggerengine <ENGINE> debuggerengine of the new kit.\n"
|
|
|
|
|
" --debugger <PATH> debugger of the new kit.\n"
|
2013-02-07 10:42:24 +01:00
|
|
|
" --devicetype <TYPE> device type of the new kit (required).\n"
|
2014-03-04 14:11:12 +01:00
|
|
|
" --device <ID> device id to use (optional).\n"
|
2012-09-18 15:58:07 +02:00
|
|
|
" --sysroot <PATH> sysroot of the new kit.\n"
|
|
|
|
|
" --toolchain <ID> tool chain of the new kit.\n"
|
|
|
|
|
" --qt <ID> Qt of the new kit.\n"
|
|
|
|
|
" --mkspec <PATH> mkspec of the new kit.\n"
|
|
|
|
|
" <KEY> <TYPE:VALUE> extra key value pairs\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool AddKitOperation::setArguments(const QStringList &args)
|
|
|
|
|
{
|
|
|
|
|
m_debuggerEngine = 0;
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < args.count(); ++i) {
|
|
|
|
|
const QString current = args.at(i);
|
|
|
|
|
const QString next = ((i + 1) < args.count()) ? args.at(i + 1) : QString();
|
|
|
|
|
|
|
|
|
|
if (current == QLatin1String("--id")) {
|
|
|
|
|
if (next.isNull())
|
|
|
|
|
return false;
|
|
|
|
|
++i; // skip next;
|
|
|
|
|
m_id = next;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (current == QLatin1String("--name")) {
|
|
|
|
|
if (next.isNull())
|
|
|
|
|
return false;
|
|
|
|
|
++i; // skip next;
|
|
|
|
|
m_displayName = next;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (current == QLatin1String("--icon")) {
|
|
|
|
|
if (next.isNull())
|
|
|
|
|
return false;
|
|
|
|
|
++i; // skip next;
|
|
|
|
|
m_icon = next;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (current == QLatin1String("--debuggerengine")) {
|
|
|
|
|
if (next.isNull())
|
|
|
|
|
return false;
|
|
|
|
|
++i; // skip next;
|
|
|
|
|
bool ok;
|
|
|
|
|
m_debuggerEngine = next.toInt(&ok);
|
|
|
|
|
if (!ok) {
|
|
|
|
|
std::cerr << "Debugger type is not an integer!" << std::endl;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-29 16:40:57 +01:00
|
|
|
if (current == QLatin1String("--debuggerid")) {
|
|
|
|
|
if (next.isNull())
|
|
|
|
|
return false;
|
|
|
|
|
++i; // skip next;
|
|
|
|
|
m_debuggerId = next;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-18 15:58:07 +02:00
|
|
|
if (current == QLatin1String("--debugger")) {
|
|
|
|
|
if (next.isNull())
|
|
|
|
|
return false;
|
|
|
|
|
++i; // skip next;
|
|
|
|
|
m_debugger = next;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (current == QLatin1String("--devicetype")) {
|
|
|
|
|
if (next.isNull())
|
|
|
|
|
return false;
|
|
|
|
|
++i; // skip next;
|
|
|
|
|
m_deviceType = next;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-04 14:11:12 +01:00
|
|
|
if (current == QLatin1String("--device")) {
|
|
|
|
|
if (next.isNull())
|
|
|
|
|
return false;
|
|
|
|
|
++i; // skip next;
|
|
|
|
|
m_device = next;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-18 15:58:07 +02:00
|
|
|
if (current == QLatin1String("--sysroot")) {
|
|
|
|
|
if (next.isNull())
|
|
|
|
|
return false;
|
|
|
|
|
++i; // skip next;
|
|
|
|
|
m_sysRoot = next;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (current == QLatin1String("--toolchain")) {
|
|
|
|
|
if (next.isNull())
|
|
|
|
|
return false;
|
|
|
|
|
++i; // skip next;
|
|
|
|
|
m_tc = next;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (current == QLatin1String("--qt")) {
|
|
|
|
|
if (next.isNull())
|
|
|
|
|
return false;
|
|
|
|
|
++i; // skip next;
|
|
|
|
|
m_qt = next;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (current == QLatin1String("--mkspec")) {
|
|
|
|
|
if (next.isNull())
|
|
|
|
|
return false;
|
|
|
|
|
++i; // skip next;
|
|
|
|
|
m_mkspec = next;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (next.isNull())
|
|
|
|
|
return false;
|
|
|
|
|
++i; // skip next;
|
|
|
|
|
KeyValuePair pair(current, next);
|
|
|
|
|
if (!pair.value.isValid())
|
|
|
|
|
return false;
|
|
|
|
|
m_extra << pair;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (m_icon.isEmpty())
|
|
|
|
|
m_icon = QLatin1String(":///DESKTOP///");
|
|
|
|
|
|
2013-02-07 10:42:24 +01:00
|
|
|
if (m_id.isEmpty())
|
|
|
|
|
std::cerr << "No id given for kit." << std::endl << std::endl;
|
|
|
|
|
if (m_displayName.isEmpty())
|
|
|
|
|
std::cerr << "No name given for kit." << std::endl << std::endl;
|
|
|
|
|
if (m_deviceType.isEmpty())
|
|
|
|
|
std::cerr << "No devicetype given for kit." << std::endl << std::endl;
|
2013-10-29 16:40:57 +01:00
|
|
|
if (!m_debuggerId.isEmpty() && (!m_debugger.isEmpty() || m_debuggerEngine != 0)) {
|
|
|
|
|
std::cerr << "Can not set both debugger id and debugger/debuggerengine." << std::endl << std::endl;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2013-02-07 10:42:24 +01:00
|
|
|
|
2013-10-30 12:05:31 +01:00
|
|
|
if (m_debuggerId.isEmpty() && m_debugger.isEmpty())
|
|
|
|
|
m_debugger = QLatin1String("auto");
|
|
|
|
|
|
2012-09-18 15:58:07 +02:00
|
|
|
return !m_id.isEmpty() && !m_displayName.isEmpty() && !m_deviceType.isEmpty();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int AddKitOperation::execute() const
|
|
|
|
|
{
|
|
|
|
|
QVariantMap map = load(QLatin1String("profiles"));
|
|
|
|
|
if (map.isEmpty())
|
|
|
|
|
map = initializeKits();
|
|
|
|
|
|
2014-03-04 14:11:12 +01:00
|
|
|
QVariantMap result = addKit(map, m_id, m_displayName, m_icon, m_debuggerId, m_debuggerEngine,
|
|
|
|
|
m_debugger, m_deviceType.toUtf8(), m_device, m_sysRoot, m_tc, m_qt,
|
|
|
|
|
m_mkspec, m_extra);
|
2012-09-18 15:58:07 +02:00
|
|
|
|
2013-05-16 15:47:47 +02:00
|
|
|
if (result.isEmpty() || map == result)
|
2013-07-08 08:35:18 +02:00
|
|
|
return 2;
|
2012-09-18 15:58:07 +02:00
|
|
|
|
2013-07-08 08:35:18 +02:00
|
|
|
return save(result, QLatin1String("profiles")) ? 0 : 3;
|
2012-09-18 15:58:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifdef WITH_TESTS
|
|
|
|
|
bool AddKitOperation::test() const
|
|
|
|
|
{
|
|
|
|
|
QVariantMap map = initializeKits();
|
|
|
|
|
|
2014-03-04 11:06:51 +01:00
|
|
|
QVariantMap tcMap = AddToolChainOperation::initializeToolChains();
|
|
|
|
|
tcMap = AddToolChainOperation::addToolChain(tcMap, QLatin1String("{tc-id}"), QLatin1String("TC"),
|
|
|
|
|
QLatin1String("/usr/bin/gcc"),
|
|
|
|
|
QLatin1String("x86-linux-generic-elf-32bit"),
|
|
|
|
|
QLatin1String("x86-linux-generic-elf-32bit"),
|
|
|
|
|
KeyValuePairList());
|
|
|
|
|
|
|
|
|
|
QVariantMap qtMap = AddQtOperation::initializeQtVersions();
|
|
|
|
|
qtMap = AddQtOperation::addQt(qtMap, QLatin1String("{qt-id}"), QLatin1String("Qt"),
|
|
|
|
|
QLatin1String("desktop-qt"), QLatin1String("/usr/bin/qmake"),
|
|
|
|
|
KeyValuePairList());
|
|
|
|
|
|
|
|
|
|
QVariantMap devMap = AddDeviceOperation::initializeDevices();
|
|
|
|
|
devMap = AddDeviceOperation::addDevice(devMap, QLatin1String("{dev-id}"), QLatin1String("Dev"), 0, 0,
|
|
|
|
|
QLatin1String("HWplatform"), QLatin1String("SWplatform"),
|
|
|
|
|
QLatin1String("localhost"), QLatin1String("10000-11000"),
|
|
|
|
|
QLatin1String("localhost"), QLatin1String(""), 42,
|
|
|
|
|
QLatin1String("desktop"), QLatin1String(""), 22, 10000,
|
|
|
|
|
QLatin1String("uname"), 1,
|
|
|
|
|
KeyValuePairList());
|
|
|
|
|
|
2012-09-28 09:50:06 +02:00
|
|
|
if (map.count() != 3
|
2012-09-18 15:58:07 +02:00
|
|
|
|| !map.contains(QLatin1String(VERSION))
|
|
|
|
|
|| map.value(QLatin1String(VERSION)).toInt() != 1
|
|
|
|
|
|| !map.contains(QLatin1String(COUNT))
|
|
|
|
|
|| map.value(QLatin1String(COUNT)).toInt() != 0
|
|
|
|
|
|| !map.contains(QLatin1String(DEFAULT))
|
|
|
|
|
|| map.value(QLatin1String(DEFAULT)).toInt() != -1)
|
|
|
|
|
return false;
|
|
|
|
|
|
2014-03-04 11:06:51 +01:00
|
|
|
// Fail if TC is not there:
|
|
|
|
|
QVariantMap empty = addKit(map, tcMap, qtMap, devMap,
|
|
|
|
|
QLatin1String("testId"), QLatin1String("Test Kit"), QLatin1String("/tmp/icon.png"),
|
|
|
|
|
QString(), 1, QLatin1String("/usr/bin/gdb-test"),
|
|
|
|
|
QByteArray("Desktop"), QLatin1String("{dev-id}"), QString(),
|
|
|
|
|
QLatin1String("{tcXX-id}"), QLatin1String("{qt-id}"), QLatin1String("unsupported/mkspec"),
|
|
|
|
|
KeyValuePairList() << KeyValuePair(QLatin1String("PE.Profile.Data/extraData"), QVariant(QLatin1String("extraValue"))));
|
|
|
|
|
if (!empty.isEmpty())
|
|
|
|
|
return false;
|
2014-04-03 16:43:01 +02:00
|
|
|
// Do not fail if TC is an ABI:
|
|
|
|
|
empty = addKit(map, tcMap, qtMap, devMap,
|
|
|
|
|
QLatin1String("testId"), QLatin1String("Test Kit"), QLatin1String("/tmp/icon.png"),
|
|
|
|
|
QString(), 1, QLatin1String("/usr/bin/gdb-test"),
|
|
|
|
|
QByteArray("Desktop"), QLatin1String("{dev-id}"), QString(),
|
|
|
|
|
QLatin1String("x86-linux-generic-elf-64bit"), QLatin1String("{qt-id}"), QLatin1String("unsupported/mkspec"),
|
|
|
|
|
KeyValuePairList() << KeyValuePair(QLatin1String("PE.Profile.Data/extraData"), QVariant(QLatin1String("extraValue"))));
|
|
|
|
|
if (empty.isEmpty())
|
|
|
|
|
return false;
|
2014-04-07 11:11:17 +02:00
|
|
|
// QTCREATORBUG-11983, mach_o was not covered by the first attempt to fix this.
|
|
|
|
|
empty = addKit(map, tcMap, qtMap, devMap,
|
|
|
|
|
QLatin1String("testId"), QLatin1String("Test Kit"), QLatin1String("/tmp/icon.png"),
|
|
|
|
|
QString(), 1, QLatin1String("/usr/bin/gdb-test"),
|
|
|
|
|
QByteArray("Desktop"), QLatin1String("{dev-id}"), QString(),
|
|
|
|
|
QLatin1String("x86-macos-generic-mach_o-64bit"), QLatin1String("{qt-id}"), QLatin1String("unsupported/mkspec"),
|
|
|
|
|
KeyValuePairList() << KeyValuePair(QLatin1String("PE.Profile.Data/extraData"), QVariant(QLatin1String("extraValue"))));
|
|
|
|
|
if (empty.isEmpty())
|
|
|
|
|
return false;
|
|
|
|
|
|
2014-03-04 11:06:51 +01:00
|
|
|
// Fail if Qt is not there:
|
|
|
|
|
empty = addKit(map, tcMap, qtMap, devMap,
|
|
|
|
|
QLatin1String("testId"), QLatin1String("Test Kit"), QLatin1String("/tmp/icon.png"),
|
|
|
|
|
QString(), 1, QLatin1String("/usr/bin/gdb-test"),
|
|
|
|
|
QByteArray("Desktop"), QLatin1String("{dev-id}"), QString(),
|
|
|
|
|
QLatin1String("{tc-id}"), QLatin1String("{qtXX-id}"), QLatin1String("unsupported/mkspec"),
|
|
|
|
|
KeyValuePairList() << KeyValuePair(QLatin1String("PE.Profile.Data/extraData"), QVariant(QLatin1String("extraValue"))));
|
|
|
|
|
if (!empty.isEmpty())
|
|
|
|
|
return false;
|
|
|
|
|
// Fail if dev is not there:
|
|
|
|
|
empty = addKit(map, tcMap, qtMap, devMap,
|
|
|
|
|
QLatin1String("testId"), QLatin1String("Test Kit"), QLatin1String("/tmp/icon.png"),
|
|
|
|
|
QString(), 1, QLatin1String("/usr/bin/gdb-test"),
|
|
|
|
|
QByteArray("Desktop"), QLatin1String("{devXX-id}"), QString(),
|
|
|
|
|
QLatin1String("{tc-id}"), QLatin1String("{qt-id}"), QLatin1String("unsupported/mkspec"),
|
|
|
|
|
KeyValuePairList() << KeyValuePair(QLatin1String("PE.Profile.Data/extraData"), QVariant(QLatin1String("extraValue"))));
|
|
|
|
|
if (!empty.isEmpty())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
map = addKit(map, tcMap, qtMap, devMap,
|
|
|
|
|
QLatin1String("testId"), QLatin1String("Test Kit"), QLatin1String("/tmp/icon.png"),
|
2013-10-29 16:40:57 +01:00
|
|
|
QString(), 1, QLatin1String("/usr/bin/gdb-test"),
|
2014-03-04 14:11:12 +01:00
|
|
|
QByteArray("Desktop"), QString(), QString(),
|
2014-03-04 11:06:51 +01:00
|
|
|
QLatin1String("{tc-id}"), QLatin1String("{qt-id}"), QLatin1String("unsupported/mkspec"),
|
2012-09-18 15:58:07 +02:00
|
|
|
KeyValuePairList() << KeyValuePair(QLatin1String("PE.Profile.Data/extraData"), QVariant(QLatin1String("extraValue"))));
|
|
|
|
|
|
2012-09-28 09:50:06 +02:00
|
|
|
if (map.count() != 4
|
2012-09-18 15:58:07 +02:00
|
|
|
|| !map.contains(QLatin1String(VERSION))
|
|
|
|
|
|| map.value(QLatin1String(VERSION)).toInt() != 1
|
|
|
|
|
|| !map.contains(QLatin1String(COUNT))
|
|
|
|
|
|| map.value(QLatin1String(COUNT)).toInt() != 1
|
|
|
|
|
|| !map.contains(QLatin1String(DEFAULT))
|
|
|
|
|
|| map.value(QLatin1String(DEFAULT)).toInt() != 0
|
|
|
|
|
|| !map.contains(QLatin1String("Profile.0")))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
QVariantMap profile0 = map.value(QLatin1String("Profile.0")).toMap();
|
2013-10-29 16:40:57 +01:00
|
|
|
if (profile0.count() != 6
|
2012-09-18 15:58:07 +02:00
|
|
|
|| !profile0.contains(QLatin1String(ID))
|
|
|
|
|
|| profile0.value(QLatin1String(ID)).toString() != QLatin1String("testId")
|
|
|
|
|
|| !profile0.contains(QLatin1String(DISPLAYNAME))
|
2012-10-09 16:01:56 +02:00
|
|
|
|| profile0.value(QLatin1String(DISPLAYNAME)).toString() != QLatin1String("Test Kit")
|
2013-10-29 16:40:57 +01:00
|
|
|
|| !profile0.contains(QLatin1String(ICON))
|
|
|
|
|
|| profile0.value(QLatin1String(ICON)).toString() != QLatin1String("/tmp/icon.png")
|
|
|
|
|
|| !profile0.contains(QLatin1String(DATA))
|
|
|
|
|
|| profile0.value(QLatin1String(DATA)).type() != QVariant::Map
|
2012-09-18 15:58:07 +02:00
|
|
|
|| !profile0.contains(QLatin1String(AUTODETECTED))
|
2013-10-29 16:40:57 +01:00
|
|
|
|| profile0.value(QLatin1String(AUTODETECTED)).toBool() != true
|
2013-02-22 16:03:57 +01:00
|
|
|
|| !profile0.contains(QLatin1String(SDK))
|
2013-10-29 16:40:57 +01:00
|
|
|
|| profile0.value(QLatin1String(SDK)).toBool() != true)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
QVariantMap data = profile0.value(QLatin1String(DATA)).toMap();
|
2014-03-04 14:11:12 +01:00
|
|
|
if (data.count() != 8
|
2013-10-29 16:40:57 +01:00
|
|
|
|| !data.contains(QLatin1String(DEBUGGER))
|
|
|
|
|
|| data.value(QLatin1String(DEBUGGER)).type()!= QVariant::Map)
|
2012-09-18 15:58:07 +02:00
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
// Ignore existing ids:
|
2014-03-04 11:06:51 +01:00
|
|
|
QVariantMap result = addKit(map, tcMap, qtMap, devMap,
|
|
|
|
|
QLatin1String("testId"), QLatin1String("Test Qt Version X"), QLatin1String("/tmp/icon3.png"),
|
2013-10-29 16:40:57 +01:00
|
|
|
QString(), 1, QLatin1String("/usr/bin/gdb-test3"),
|
2014-03-04 14:11:12 +01:00
|
|
|
QByteArray("Desktop"), QString(), QString(),
|
2014-03-04 11:06:51 +01:00
|
|
|
QLatin1String("{tc-id}"), QLatin1String("{qt-id}"), QLatin1String("unsupported/mkspec"),
|
|
|
|
|
KeyValuePairList() << KeyValuePair(QLatin1String("PE.Profile.Data/extraData"), QVariant(QLatin1String("extraValue"))));
|
2012-09-18 15:58:07 +02:00
|
|
|
if (!result.isEmpty())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
// Make sure name is unique:
|
2014-03-04 11:06:51 +01:00
|
|
|
map = addKit(map, tcMap, qtMap, devMap,
|
|
|
|
|
QLatin1String("testId2"), QLatin1String("Test Kit2"), QLatin1String("/tmp/icon2.png"),
|
2013-10-29 16:40:57 +01:00
|
|
|
QString(), 1, QLatin1String("/usr/bin/gdb-test2"),
|
2014-03-04 11:06:51 +01:00
|
|
|
QByteArray("Desktop"), QLatin1String("{dev-id}"), QString(),
|
|
|
|
|
QLatin1String("{tc-id}"), QLatin1String("{qt-id}"), QLatin1String("unsupported/mkspec"),
|
|
|
|
|
KeyValuePairList() << KeyValuePair(QLatin1String("PE.Profile.Data/extraData"), QVariant(QLatin1String("extraValue"))));
|
2012-09-28 09:50:06 +02:00
|
|
|
if (map.count() != 5
|
2012-09-18 15:58:07 +02:00
|
|
|
|| !map.contains(QLatin1String(VERSION))
|
|
|
|
|
|| map.value(QLatin1String(VERSION)).toInt() != 1
|
|
|
|
|
|| !map.contains(QLatin1String(COUNT))
|
|
|
|
|
|| map.value(QLatin1String(COUNT)).toInt() != 2
|
|
|
|
|
|| !map.contains(QLatin1String(DEFAULT))
|
|
|
|
|
|| map.value(QLatin1String(DEFAULT)).toInt() != 0
|
|
|
|
|
|| !map.contains(QLatin1String("Profile.0"))
|
|
|
|
|
|| !map.contains(QLatin1String("Profile.1")))
|
|
|
|
|
|
|
|
|
|
if (map.value(QLatin1String("Profile.0")) != profile0)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
QVariantMap profile1 = map.value(QLatin1String("Profile.1")).toMap();
|
2013-10-29 16:40:57 +01:00
|
|
|
if (profile1.count() != 6
|
2012-09-18 15:58:07 +02:00
|
|
|
|| !profile1.contains(QLatin1String(ID))
|
|
|
|
|
|| profile1.value(QLatin1String(ID)).toString() != QLatin1String("testId2")
|
|
|
|
|
|| !profile1.contains(QLatin1String(DISPLAYNAME))
|
2012-10-09 16:01:56 +02:00
|
|
|
|| profile1.value(QLatin1String(DISPLAYNAME)).toString() != QLatin1String("Test Kit2")
|
2013-10-29 16:40:57 +01:00
|
|
|
|| !profile1.contains(QLatin1String(ICON))
|
|
|
|
|
|| profile1.value(QLatin1String(ICON)).toString() != QLatin1String("/tmp/icon2.png")
|
|
|
|
|
|| !profile1.contains(QLatin1String(DATA))
|
|
|
|
|
|| profile1.value(QLatin1String(DATA)).type() != QVariant::Map
|
2012-09-18 15:58:07 +02:00
|
|
|
|| !profile1.contains(QLatin1String(AUTODETECTED))
|
2013-10-29 16:40:57 +01:00
|
|
|
|| profile1.value(QLatin1String(AUTODETECTED)).toBool() != true
|
2013-02-22 16:03:57 +01:00
|
|
|
|| !profile1.contains(QLatin1String(SDK))
|
2013-10-29 16:40:57 +01:00
|
|
|
|| profile1.value(QLatin1String(SDK)).toBool() != true)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
data = profile1.value(QLatin1String(DATA)).toMap();
|
2014-03-04 14:11:12 +01:00
|
|
|
if (data.count() != 8
|
|
|
|
|
|| !data.contains(QLatin1String(DEVICE_ID))
|
2014-03-04 11:06:51 +01:00
|
|
|
|| data.value(QLatin1String(DEVICE_ID)).toString() != QLatin1String("{dev-id}")
|
2013-10-29 16:40:57 +01:00
|
|
|
|| !data.contains(QLatin1String(DEBUGGER))
|
|
|
|
|
|| data.value(QLatin1String(DEBUGGER)).type() != QVariant::Map)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
// Test debugger id:
|
2014-03-04 11:06:51 +01:00
|
|
|
map = addKit(map, tcMap, qtMap, devMap,
|
|
|
|
|
QLatin1String("test with debugger Id"), QLatin1String("Test debugger Id"), QLatin1String("/tmp/icon2.png"),
|
2013-10-29 16:40:57 +01:00
|
|
|
QString::fromLatin1("debugger Id"), 0, QString(),
|
2014-03-04 14:11:12 +01:00
|
|
|
QByteArray("Desktop"), QString(), QString(),
|
2014-03-04 11:06:51 +01:00
|
|
|
QLatin1String("{tc-id}"), QLatin1String("{qt-id}"), QLatin1String("unsupported/mkspec"),
|
|
|
|
|
KeyValuePairList() << KeyValuePair(QLatin1String("PE.Profile.Data/extraData"), QVariant(QLatin1String("extraValue"))));
|
2013-10-29 16:40:57 +01:00
|
|
|
if (map.count() != 6
|
|
|
|
|
|| !map.contains(QLatin1String(VERSION))
|
|
|
|
|
|| map.value(QLatin1String(VERSION)).toInt() != 1
|
|
|
|
|
|| !map.contains(QLatin1String(COUNT))
|
|
|
|
|
|| map.value(QLatin1String(COUNT)).toInt() != 3
|
|
|
|
|
|| !map.contains(QLatin1String(DEFAULT))
|
|
|
|
|
|| map.value(QLatin1String(DEFAULT)).toInt() != 0
|
|
|
|
|
|| !map.contains(QLatin1String("Profile.0"))
|
|
|
|
|
|| !map.contains(QLatin1String("Profile.1"))
|
|
|
|
|
|| !map.contains(QLatin1String("Profile.2")))
|
|
|
|
|
|
|
|
|
|
if (map.value(QLatin1String("Profile.0")) != profile0)
|
|
|
|
|
return false;
|
|
|
|
|
if (map.value(QLatin1String("Profile.1")) != profile1)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
QVariantMap profile2 = map.value(QLatin1String("Profile.2")).toMap();
|
|
|
|
|
if (profile2.count() != 6
|
|
|
|
|
|| !profile2.contains(QLatin1String(ID))
|
|
|
|
|
|| profile2.value(QLatin1String(ID)).toString() != QLatin1String("test with debugger Id")
|
|
|
|
|
|| !profile2.contains(QLatin1String(DISPLAYNAME))
|
|
|
|
|
|| profile2.value(QLatin1String(DISPLAYNAME)).toString() != QLatin1String("Test debugger Id")
|
|
|
|
|
|| !profile2.contains(QLatin1String(ICON))
|
|
|
|
|
|| profile2.value(QLatin1String(ICON)).toString() != QLatin1String("/tmp/icon2.png")
|
|
|
|
|
|| !profile2.contains(QLatin1String(DATA))
|
|
|
|
|
|| profile2.value(QLatin1String(DATA)).type() != QVariant::Map
|
|
|
|
|
|| !profile2.contains(QLatin1String(AUTODETECTED))
|
|
|
|
|
|| profile2.value(QLatin1String(AUTODETECTED)).toBool() != true
|
|
|
|
|
|| !profile2.contains(QLatin1String(SDK))
|
|
|
|
|
|| profile2.value(QLatin1String(SDK)).toBool() != true)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
data = profile2.value(QLatin1String(DATA)).toMap();
|
2014-03-04 14:11:12 +01:00
|
|
|
if (data.count() != 8
|
2013-10-29 16:40:57 +01:00
|
|
|
|| !data.contains(QLatin1String(DEBUGGER))
|
|
|
|
|
|| data.value(QLatin1String(DEBUGGER)).toString() != QLatin1String("debugger Id"))
|
2012-09-18 15:58:07 +02:00
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2014-03-04 11:06:51 +01:00
|
|
|
QVariantMap AddKitOperation::addKit(const QVariantMap &map,
|
|
|
|
|
const QString &id, const QString &displayName,
|
|
|
|
|
const QString &icon, const QString &debuggerId,
|
|
|
|
|
const quint32 &debuggerType, const QString &debugger,
|
|
|
|
|
const QByteArray &deviceType, const QString &device,
|
|
|
|
|
const QString &sysRoot, const QString &tc, const QString &qt,
|
|
|
|
|
const QString &mkspec, const KeyValuePairList &extra)
|
|
|
|
|
{
|
|
|
|
|
QVariantMap tcMap = load(QLatin1String("toolchains"));
|
|
|
|
|
QVariantMap qtMap = load(QLatin1String("qtversions"));
|
|
|
|
|
QVariantMap devMap = load(QLatin1String("devices"));
|
|
|
|
|
|
|
|
|
|
return addKit(map, tcMap, qtMap, devMap, id, displayName, icon, debuggerId, debuggerType,
|
|
|
|
|
debugger, deviceType, device, sysRoot, tc, qt, mkspec, extra);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVariantMap AddKitOperation::addKit(const QVariantMap &map, const QVariantMap &tcMap,
|
|
|
|
|
const QVariantMap &qtMap, const QVariantMap &devMap,
|
|
|
|
|
const QString &id, const QString &displayName,
|
|
|
|
|
const QString &icon, const QString &debuggerId,
|
|
|
|
|
const quint32 &debuggerType, const QString &debugger,
|
|
|
|
|
const QByteArray &deviceType, const QString &device,
|
|
|
|
|
const QString &sysRoot, const QString &tc, const QString &qt,
|
|
|
|
|
const QString &mkspec, const KeyValuePairList &extra)
|
2012-09-18 15:58:07 +02:00
|
|
|
{
|
|
|
|
|
// Sanity check: Make sure autodetection source is not in use already:
|
2014-02-20 11:37:56 +01:00
|
|
|
QStringList valueKeys = FindValueOperation::findValue(map, QVariant(id));
|
2012-09-18 15:58:07 +02:00
|
|
|
bool hasId = false;
|
|
|
|
|
foreach (const QString &k, valueKeys) {
|
|
|
|
|
if (k.endsWith(QString(QLatin1Char('/')) + QLatin1String(ID))) {
|
|
|
|
|
hasId = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (hasId) {
|
|
|
|
|
std::cerr << "Error: Id " << qPrintable(id) << " already defined as kit." << std::endl;
|
|
|
|
|
return QVariantMap();
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-03 16:43:01 +02:00
|
|
|
if (!tc.isEmpty() && !AddToolChainOperation::exists(tcMap, tc)) {
|
2014-04-07 11:11:17 +02:00
|
|
|
QRegExp abiRegExp = QRegExp(QLatin1String("[a-z0-9_]+-[a-z0-9_]+-[a-z0-9_]+-[a-z0-9_]+-(8|16|32|64|128)bit"));
|
2014-04-03 16:43:01 +02:00
|
|
|
if (!abiRegExp.exactMatch(tc)) {
|
|
|
|
|
std::cerr << "Error: Toolchain " << qPrintable(tc) << " does not exist." << std::endl;
|
|
|
|
|
return QVariantMap();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-04 11:06:51 +01:00
|
|
|
QString qtId = qt;
|
|
|
|
|
if (!qtId.isEmpty() && !qtId.startsWith(QLatin1String("SDK.")))
|
|
|
|
|
qtId = QString::fromLatin1("SDK.") + qt;
|
|
|
|
|
if (!qtId.isEmpty() && !AddQtOperation::exists(qtMap, qtId)) {
|
|
|
|
|
std::cerr << "Error: Qt " << qPrintable(qtId) << " does not exist." << std::endl;
|
|
|
|
|
return QVariantMap();
|
|
|
|
|
}
|
|
|
|
|
if (!device.isEmpty() && !AddDeviceOperation::exists(devMap, device)) {
|
|
|
|
|
std::cerr << "Error: Device " << qPrintable(device) << " does not exist." << std::endl;
|
|
|
|
|
return QVariantMap();
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-18 15:58:07 +02:00
|
|
|
// Find position to insert:
|
|
|
|
|
bool ok;
|
|
|
|
|
int count = GetOperation::get(map, QLatin1String(COUNT)).toInt(&ok);
|
|
|
|
|
if (!ok || count < 0) {
|
|
|
|
|
std::cerr << "Error: Count found in kits file seems wrong." << std::endl;
|
|
|
|
|
return QVariantMap();
|
|
|
|
|
}
|
|
|
|
|
const QString kit = QString::fromLatin1(PREFIX) + QString::number(count);
|
|
|
|
|
|
|
|
|
|
int defaultKit = GetOperation::get(map, QLatin1String(DEFAULT)).toInt(&ok);
|
|
|
|
|
if (!ok) {
|
|
|
|
|
std::cerr << "Error: Default kit seems wrong." << std::endl;
|
|
|
|
|
return QVariantMap();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (defaultKit < 0)
|
|
|
|
|
defaultKit = 0;
|
|
|
|
|
|
|
|
|
|
// remove data:
|
|
|
|
|
QStringList toRemove;
|
|
|
|
|
toRemove << QLatin1String(COUNT) << QLatin1String(DEFAULT);
|
|
|
|
|
QVariantMap cleaned = RmKeysOperation::rmKeys(map, toRemove);
|
|
|
|
|
|
|
|
|
|
// Sanity check: Make sure displayName is unique.
|
|
|
|
|
QStringList nameKeys = FindKeyOperation::findKey(map, QLatin1String(DISPLAYNAME));
|
|
|
|
|
QStringList nameList;
|
2013-03-11 17:23:55 +01:00
|
|
|
foreach (const QString &nameKey, nameKeys)
|
2012-09-18 15:58:07 +02:00
|
|
|
nameList << GetOperation::get(map, nameKey).toString();
|
|
|
|
|
const QString uniqueName = makeUnique(displayName, nameList);
|
|
|
|
|
|
|
|
|
|
// insert data:
|
|
|
|
|
KeyValuePairList data;
|
|
|
|
|
data << KeyValuePair(QStringList() << kit << QLatin1String(ID), QVariant(id));
|
|
|
|
|
data << KeyValuePair(QStringList() << kit << QLatin1String(DISPLAYNAME), QVariant(uniqueName));
|
|
|
|
|
data << KeyValuePair(QStringList() << kit << QLatin1String(ICON), QVariant(icon));
|
|
|
|
|
data << KeyValuePair(QStringList() << kit << QLatin1String(AUTODETECTED), QVariant(true));
|
2013-02-22 16:03:57 +01:00
|
|
|
data << KeyValuePair(QStringList() << kit << QLatin1String(SDK), QVariant(true));
|
2012-09-18 15:58:07 +02:00
|
|
|
|
2013-10-29 16:40:57 +01:00
|
|
|
if (debuggerId.isEmpty()) {
|
|
|
|
|
data << KeyValuePair(QStringList() << kit << QLatin1String(DATA)
|
|
|
|
|
<< QLatin1String(DEBUGGER) << QLatin1String(DEBUGGER_ENGINE), QVariant(debuggerType));
|
|
|
|
|
data << KeyValuePair(QStringList() << kit << QLatin1String(DATA)
|
|
|
|
|
<< QLatin1String(DEBUGGER) << QLatin1String(DEBUGGER_BINARY), QVariant(debugger));
|
|
|
|
|
} else {
|
|
|
|
|
data << KeyValuePair(QStringList() << kit << QLatin1String(DATA) << QLatin1String(DEBUGGER),
|
|
|
|
|
QVariant(debuggerId));
|
|
|
|
|
}
|
2013-01-12 23:10:40 +02:00
|
|
|
data << KeyValuePair(QStringList() << kit << QLatin1String(DATA)
|
|
|
|
|
<< QLatin1String(DEVICE_TYPE), QVariant(deviceType));
|
2014-03-04 14:11:12 +01:00
|
|
|
data << KeyValuePair(QStringList() << kit << QLatin1String(DATA)
|
|
|
|
|
<< QLatin1String(DEVICE_ID), QVariant(device));
|
2013-01-12 23:10:40 +02:00
|
|
|
data << KeyValuePair(QStringList() << kit << QLatin1String(DATA)
|
|
|
|
|
<< QLatin1String(SYSROOT), QVariant(sysRoot));
|
|
|
|
|
data << KeyValuePair(QStringList() << kit << QLatin1String(DATA)
|
|
|
|
|
<< QLatin1String(TOOLCHAIN), QVariant(tc));
|
|
|
|
|
data << KeyValuePair(QStringList() << kit << QLatin1String(DATA)
|
|
|
|
|
<< QLatin1String(QT), QVariant(qtId));
|
|
|
|
|
data << KeyValuePair(QStringList() << kit << QLatin1String(DATA)
|
|
|
|
|
<< QLatin1String(MKSPEC), QVariant(mkspec));
|
2012-09-18 15:58:07 +02:00
|
|
|
|
|
|
|
|
data << KeyValuePair(QStringList() << QLatin1String(DEFAULT), QVariant(defaultKit));
|
|
|
|
|
data << KeyValuePair(QStringList() << QLatin1String(COUNT), QVariant(count + 1));
|
|
|
|
|
|
|
|
|
|
KeyValuePairList qtExtraList;
|
|
|
|
|
foreach (const KeyValuePair &pair, extra)
|
|
|
|
|
qtExtraList << KeyValuePair(QStringList() << kit << pair.key, pair.value);
|
|
|
|
|
data.append(qtExtraList);
|
|
|
|
|
|
|
|
|
|
return AddKeysOperation::addKeys(cleaned, data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVariantMap AddKitOperation::initializeKits()
|
|
|
|
|
{
|
|
|
|
|
QVariantMap map;
|
|
|
|
|
map.insert(QLatin1String(VERSION), 1);
|
|
|
|
|
map.insert(QLatin1String(DEFAULT), -1);
|
|
|
|
|
map.insert(QLatin1String(COUNT), 0);
|
|
|
|
|
return map;
|
|
|
|
|
}
|