Commit 4f36ad63 authored by Tobias Hunger's avatar Tobias Hunger Committed by Tim Jenssen

Add sdktool

Add a tool to ease configuration of Qt versions, tool chains
and kits with Qt Creator for the SDK and similar systems.

Change-Id: I9727dd25ea359a935ea494b035a59411eb3529b8
Reviewed-by: default avatarTim Jenssen <tim.jenssen@digia.com>
parent 9c2afc4f
......@@ -80,7 +80,8 @@ Project {
"src/plugins/welcome/welcome.qbs",
"src/share/share.qbs",
"src/tools/qtcdebugger/qtcdebugger.qbs",
"src/tools/qtpromaker/qtpromaker.qbs"
"src/tools/qtpromaker/qtpromaker.qbs",
"src/tools/sdktool/sdktool.qbs"
]
Product {
......
The SDK tool can be used to set up Qt versions, tool chains and kits
in Qt Creator.
There still is a lot of knowledge about Qt Creator internals required
to use this tool!
Note that some tool chains/Qt versions/kits may require settings not
available via command line switches. All operations will add any parameter
followed by another parameter in the form "<TYPE>:<VALUE>" to the
configuration that they create.
Currently supported types are int, bool, QString, QByteArray and QVariantList.
Dependencies:
The SDK tool depends on the Utils library of Qt Creator and Qt itself.
Please make sure both libraries are found by setting PATH/LD_LIBRARY_PATH.
Usage:
Qt Creator SDK setup tool.
Usage:./sdktool <ARGS> <OPERATION> <OPERATION_ARGS>
ARGS:
--help|-h Print this help text
--sdkpath=PATH|-s PATH Set the path to the SDK files
OPERATION:
One of:
addKeys add settings to Qt Creator configuration
addKit add a Kit to Qt Creator
addQt add a Qt version to Qt Creator
addTC add a tool chain to Qt Creator
findKey find a key in the settings of Qt Creator
find find a value in the settings of Qt Creator
get get settings from Qt Creator configuration
rmKeys remove settings from Qt Creator configuration
rmKit remove a Kit from Qt Creator
rmQt remove a Qt version from Qt Creator
rmTC remove a tool chain from Qt Creator
OPERATION_ARGS:
use "--help <OPERATION>" to get help on the arguments required for an operation.
Help for individual operations can be retrieved using
./sdktool --help addKit
Examples:
Add a tool chain:
./sdktool addTC \
--id "ProjectExplorer.ToolChain.Gcc:my_test_TC" \
--name "Test TC" \
--path /usr/bin/g++ \
--abi x86-linux-generic-elf-64bit \
--supportedAbis x86-linux-generic-elf-64bit,x86-linux-generic-elf-32bit \
ADDITIONAL_INTEGER_PARAMETER int:42 \
ADDITIONAL_STRING_PARAMETER "QString:some string" \
Tricky parts:
- The id has to be in the form "ToolChainType:some_unique_part", where the
tool chain type must be one of (as of Qt Creator 2.6):
* ProjectExplorer.ToolChain.Msvc for Microsoft MSVC compilers
(Note: This one will be autodetected anyway, so there is little
need to add it from the sdktool)
* ProjectExplorer.ToolChain.WinCE for Windows CE tool chain by
Microsoft (Note: This one will be autodetected anyway, so there
is little need to add it from the sdktool)
* ProjectExplorer.ToolChain.Gcc for a normal GCC (linux/mac)
* Qt4ProjectManager.ToolChain.Android for the Android tool chain
* ProjectExplorer.ToolChain.Clang for the Clang compiler
* ProjectExplorer.ToolChain.LinuxIcc for the LinuxICC compiler
* ProjectExplorer.ToolChain.Mingw for the Mingw compiler
Check the classes derived from ProjectExplorer::ToolChain for their
Ids.
The some_unique_part can be anything. Creator uses GUIDs by default,
but any string is fine for the SDK to use.
- The ABI needs to be in a format that ProjectExplorer::Abi::fromString(...)
can parse.
Add a Qt version:
./sdktool addQt \
--id "my_test_Qt" \
--name "Test Qt" \
--qmake /home/code/build/qt4-4/bin/qmake \
--type Qt4ProjectManager.QtVersion.Desktop \
Tricky parts:
- The id can be any unique string. In creator this is set as the autodetection
source of the Qt version.
- type must be the string returned by BaseQtVersion::type().
Currently these are (Qt Creator 2.6):
* Qt4ProjectManager.QtVersion.Android for Android
* Qt4ProjectManager.QtVersion.Desktop for a desktop Qt
* RemoteLinux.EmbeddedLinuxQt for an embedded linux Qt
* Qt4ProjectManager.QtVersion.Maemo for an Maemo Qt
* Qt4ProjectManager.QtVersion.QNX.BlackBerry for Qt on BlackBerry
* Qt4ProjectManager.QtVersion.QNX.QNX for Qt on QNX
* Qt4ProjectManager.QtVersion.Simulator for Qt running in the Qt simulator
* Qt4ProjectManager.QtVersion.WinCE for Qt on WinCE
Add a Kit using the newly set up tool chain and Qt version:
./sdktool addKit \
--id "my_test_kit" \
--name "Test Kit" \
--debuggerengine 1 \
--debugger /tmp/gdb-test \
--devicetype Desktop \
--sysroot /tmp/sysroot \
--toolchain "ProjectExplorer.ToolChain.Gcc:my_test_TC" \
--qt "my_test_Qt" \
--mkspec "testspec" \
Tricky parts:
- debuggerengine is the integer used in the enum Debugger::DebuggerEngineType
The most important type is 1 for GDB.
- devicetype is the string returned IDevice::type()
Currently these are (Qt Creator 2.6):
* Android.Device.Type for Android devices
* Desktop for code running on the local desktop
* BBOsType for BlackBerry devices
* HarmattanOsType for N9/N950 devices based on Harmattan
* Maemo5OsType for N900 devices based on Maemo
- toolchain is one of the ids used when setting up toolchains with sdktool addTC.
- qt is one of the ids used when setting up Qt versions with sdktool addQt.
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: http://www.qt-project.org/
**
**
** GNU Lesser General Public License Usage
**
** 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, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**************************************************************************/
#include "addkeysoperation.h"
#include <iostream>
QString AddKeysOperation::name() const
{
return QLatin1String("addKeys");
}
QString AddKeysOperation::helpText() const
{
return QLatin1String("add settings to Qt Creator configuration");
}
QString AddKeysOperation::argumentsHelpText() const
{
return QLatin1String("A file (profiles, qtversions or toolchains) followed by one or more Tuples\n"
"<KEY> <TYPE>:<VALUE> are required. KEY needs to start with\n"
"the name of the file to insert data into (minus the .xml extension).");
}
bool AddKeysOperation::setArguments(const QStringList &args)
{
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 (m_file.isNull()) {
m_file = current;
continue;
}
if (next.isNull())
return false;
++i;
KeyValuePair pair(current, next);
if (pair.key.isEmpty() || !pair.value.isValid())
return false;
m_data << pair;
}
return !m_file.isEmpty();
}
int AddKeysOperation::execute() const
{
if (m_data.isEmpty())
return 0;
QVariantMap map = load(m_file);
map = addKeys(map, m_data);
if (map.isEmpty())
return 1;
// Write data again:
return save(map, m_file) ? 0 : 2;
}
#ifdef WITH_TESTS
bool AddKeysOperation::test() const
{
QVariantMap testMap;
QVariantMap subKeys;
subKeys.insert(QLatin1String("subsubkeys"), QVariantMap());
subKeys.insert(QLatin1String("testbool"), true);
testMap.insert(QLatin1String("subkeys"), subKeys);
subKeys.clear();
testMap.insert(QLatin1String("subkeys2"), subKeys);
testMap.insert(QLatin1String("testint"), 23);
KeyValuePairList data;
data.append(KeyValuePair(QLatin1String("bool-true"), QString::fromLatin1("bool:trUe")));
data.append(KeyValuePair(QLatin1String("bool-false"), QString::fromLatin1("bool:false")));
data.append(KeyValuePair(QLatin1String("int"), QString::fromLatin1("int:42")));
data.append(KeyValuePair(QLatin1String("qstring"), QString::fromLatin1("QString:test string.")));
data.append(KeyValuePair(QLatin1String("qbytearray"), QString::fromLatin1("QByteArray:test array.")));
data.append(KeyValuePair(QLatin1String("subkeys/qbytearray"), QString::fromLatin1("QByteArray:test array.")));
data.append(KeyValuePair(QLatin1String("subkeys/newsubkeys/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.")));
QVariantMap result = addKeys(testMap, data);
if (!result.count() == 8)
return false;
// subkeys:
QVariantMap cur = result.value(QLatin1String("subkeys")).toMap();
if (cur.count() != 4
|| !cur.contains(QLatin1String("qbytearray"))
|| !cur.contains(QLatin1String("testbool"))
|| !cur.contains(QLatin1String("subsubkeys"))
|| !cur.contains(QLatin1String("newsubkeys")))
return false;
// subkeys/newsubkeys:
QVariantMap tmp = cur;
cur = cur.value(QLatin1String("newsubkeys")).toMap();
if (cur.count() != 1
|| !cur.contains(QLatin1String("qbytearray")))
return false;
// subkeys/subsubkeys:
cur = tmp.value(QLatin1String("subsubkeys")).toMap();
if (cur.count() != 0)
return false;
// newsub:
cur = result.value(QLatin1String("newsub")).toMap();
if (cur.count() != 1
|| !cur.contains(QLatin1String("1")))
return false;
// newsub/1:
cur = cur.value(QLatin1String("1")).toMap();
if (cur.count() != 2
|| !cur.contains(QLatin1String("2"))
|| !cur.contains(QLatin1String("2.1")))
return false;
// newsub/1/2:
tmp = cur;
cur = cur.value(QLatin1String("2")).toMap();
if (cur.count() != 1
|| !cur.contains(QLatin1String("3")))
return false;
// newsub/1/2/3:
cur = cur.value(QLatin1String("3")).toMap();
if (cur.count() != 1
|| !cur.contains(QLatin1String("qbytearray")))
return false;
// newsub/1/2.1:
cur = tmp.value(QLatin1String("2.1")).toMap();
if (cur.count() != 1
|| !cur.contains(QLatin1String("3")))
return false;
// newsub/1/2.1/3:
cur = cur.value(QLatin1String("3")).toMap();
if (cur.count() != 1
|| !cur.contains(QLatin1String("qbytearray")))
return false;
// subkeys2:
cur = result.value(QLatin1String("subkeys2")).toMap();
if (cur.count() != 0)
return false;
// values:
if (!result.contains(QLatin1String("bool-true")) || !result.value(QLatin1String("bool-true")).toBool())
return false;
if (!result.contains(QLatin1String("bool-false")) || result.value(QLatin1String("bool-false")).toBool())
return false;
if (!result.contains(QLatin1String("int")) || result.value(QLatin1String("int")).toInt() != 42)
return false;
if (!result.contains(QLatin1String("qstring"))
|| result.value(QLatin1String("qstring")).toString() != QLatin1String("test string."))
return false;
if (!result.contains(QLatin1String("qbytearray"))
|| result.value(QLatin1String("qbytearray")).toByteArray() != "test array.")
return false;
// Make sure we do not overwrite data:
// preexisting:
data.clear();
data.append(KeyValuePair(QLatin1String("testint"), QString::fromLatin1("int:4")));
result = addKeys(testMap, data);
if (!result.isEmpty())
return false;
data.clear();
data.append(KeyValuePair(QLatin1String("subkeys/testbool"), QString::fromLatin1("int:24")));
result = addKeys(testMap, data);
if (!result.isEmpty())
return false;
// data inserted before:
data.clear();
data.append(KeyValuePair(QLatin1String("bool-true"), QString::fromLatin1("bool:trUe")));
data.append(KeyValuePair(QLatin1String("bool-true"), QString::fromLatin1("bool:trUe")));
result = addKeys(testMap, data);
if (!result.isEmpty())
return false;
return true;
}
#endif
QVariantMap AddKeysOperation::addKeys(const QVariantMap &map, const KeyValuePairList &additions)
{
// Insert data:
QVariantMap result = map;
foreach (const KeyValuePair &p, additions) {
QList<QVariantMap> stack;
// Set up a stack of QVariantMaps along the path we take:
stack.append(result);
for (int i = 0; i < p.key.count() - 1; ++i) {
QVariantMap subMap;
if (stack.last().contains(p.key.at(i)))
subMap = stack.last().value(p.key.at(i)).toMap();
stack.append(subMap);
}
// insert
Q_ASSERT(stack.count() == p.key.count());
if (stack.last().contains(p.key.last())) {
std::cerr << "DEBUG: Adding key " << qPrintable(p.key.join(QLatin1String("/"))) << " which already exists." << std::endl;
return QVariantMap();
}
stack.last().insert(p.key.last(), p.value);
// Generate new resultset by folding maps back in:
QVariantMap foldBack = stack.takeLast();
for (int i = p.key.count() - 2; i >= 0; --i) { // skip last key, that is already taken care of
const QString k = p.key.at(i);
QVariantMap current = stack.takeLast();
current.insert(k, foldBack);
foldBack = current;
}
Q_ASSERT(stack.count() == 0);
Q_ASSERT(foldBack != map);
result = foldBack;
}
return result;
}
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: http://www.qt-project.org/
**
**
** GNU Lesser General Public License Usage
**
** 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, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**************************************************************************/
#ifndef ADDKEYSOPERATION_H
#define ADDKEYSOPERATION_H
#include "operation.h"
class AddKeysOperation : public Operation
{
public:
QString name() 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;
};
#endif // ADDKEYSOPERATION_H
This diff is collapsed.
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: http://www.qt-project.org/
**
**
** GNU Lesser General Public License Usage
**
** 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, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**************************************************************************/
#ifndef ADDKITOPERATION_H
#define ADDKITOPERATION_H
#include "operation.h"
#include <QString>
class AddKitOperation : public Operation
{
public:
QString name() const;
QString helpText() const;
QString argumentsHelpText() 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 quint32 &debuggerType, const QString &debugger,
const QString &deviceType, const QString &sysRoot,
const QString &tc, const QString &qt, const QString &mkspec,
const KeyValuePairList &extra);
static QVariantMap initializeKits();
private:
QString m_id;
QString m_displayName;
QString m_icon;
quint32 m_debuggerEngine;
QString m_debugger;
QString m_deviceType;
QString m_sysRoot;
QString m_tc;
QString m_qt;
QString m_mkspec;
KeyValuePairList m_extra;
};
#endif // ADDKITOPERATION_H
This diff is collapsed.
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: http://www.qt-project.org/
**
**
** GNU Lesser General Public License Usage
**
** 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, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**************************************************************************/
#ifndef ADDQTOPERATION_H
#define ADDQTOPERATION_H
#include "operation.h"
#include <QString>
class AddQtOperation : public Operation
{
public:
QString name() 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);
static QVariantMap initializeQtVersions();
private:
QString m_id; // actually this is the autodetectionSource
QString m_displayName;
QString m_type;
QString m_qmake;
KeyValuePairList m_extra;
};
#endif // ADDQTOPERATION_H
This diff is collapsed.
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: http://www.qt-project.org/
**
**
** GNU Le