Commit 4a890f6d authored by Daniel Teske's avatar Daniel Teske

Simplify Android settings, move debugger/gdbserver to Kit

Creator now realiable creates one toolchain for each toolchain found in
the ndk. This no longer depends on any qt versions being present.

Also the gdb command and gdb server command are moved to the Kit and are
no longer found in the Android Options page. Both settings can be
autodetected from the Kit options page. Note that this might break
existing android kits.

Change-Id: I1dce084f2bb372e615e19b1c9e3a1e205b5d9647
Reviewed-by: default avatarBogDan Vatra <bogdan@kde.org>
parent 66fefcd1
...@@ -37,7 +37,8 @@ HEADERS += \ ...@@ -37,7 +37,8 @@ HEADERS += \
javaparser.h \ javaparser.h \
androidplugin.h \ androidplugin.h \
androiddevicefactory.h \ androiddevicefactory.h \
androiddevice.h androiddevice.h \
androidgdbserverkitinformation.h
SOURCES += \ SOURCES += \
androidconfigurations.cpp \ androidconfigurations.cpp \
...@@ -65,8 +66,8 @@ SOURCES += \ ...@@ -65,8 +66,8 @@ SOURCES += \
javaparser.cpp \ javaparser.cpp \
androidplugin.cpp \ androidplugin.cpp \
androiddevicefactory.cpp \ androiddevicefactory.cpp \
androiddevice.cpp androiddevice.cpp \
androidgdbserverkitinformation.cpp
FORMS += \ FORMS += \
androidsettingswidget.ui \ androidsettingswidget.ui \
......
...@@ -73,7 +73,6 @@ namespace { ...@@ -73,7 +73,6 @@ namespace {
const QLatin1String OpenJDKLocationKey("OpenJDKLocation"); const QLatin1String OpenJDKLocationKey("OpenJDKLocation");
const QLatin1String KeystoreLocationKey("KeystoreLocation"); const QLatin1String KeystoreLocationKey("KeystoreLocation");
const QLatin1String PartitionSizeKey("PartitionSize"); const QLatin1String PartitionSizeKey("PartitionSize");
const QLatin1String NDKGccVersionRegExp("-\\d[\\.\\d]+");
const QLatin1String ArmToolchainPrefix("arm-linux-androideabi"); const QLatin1String ArmToolchainPrefix("arm-linux-androideabi");
const QLatin1String X86ToolchainPrefix("x86"); const QLatin1String X86ToolchainPrefix("x86");
const QLatin1String ArmToolsPrefix("arm-linux-androideabi"); const QLatin1String ArmToolsPrefix("arm-linux-androideabi");
...@@ -95,6 +94,15 @@ namespace { ...@@ -95,6 +94,15 @@ namespace {
} }
} }
Abi::Architecture AndroidConfigurations::architectureForToolChainPrefix(const QString& toolchainprefix)
{
if (toolchainprefix == ArmToolchainPrefix)
return Abi::ArmArchitecture;
if (toolchainprefix == X86ToolchainPrefix)
return Abi::X86Architecture;
return Abi::UnknownArchitecture;
}
QLatin1String AndroidConfigurations::toolchainPrefix(Abi::Architecture architecture) QLatin1String AndroidConfigurations::toolchainPrefix(Abi::Architecture architecture)
{ {
switch (architecture) { switch (architecture) {
...@@ -122,10 +130,6 @@ QLatin1String AndroidConfigurations::toolsPrefix(Abi::Architecture architecture) ...@@ -122,10 +130,6 @@ QLatin1String AndroidConfigurations::toolsPrefix(Abi::Architecture architecture)
AndroidConfig::AndroidConfig(const QSettings &settings) AndroidConfig::AndroidConfig(const QSettings &settings)
{ {
// user settings // user settings
armGdbLocation = FileName::fromString(settings.value(ArmGdbLocationKey).toString());
armGdbserverLocation = FileName::fromString(settings.value(ArmGdbserverLocationKey).toString());
x86GdbLocation = FileName::fromString(settings.value(X86GdbLocationKey).toString());
x86GdbserverLocation = FileName::fromString(settings.value(X86GdbserverLocationKey).toString());
partitionSize = settings.value(PartitionSizeKey, 1024).toInt(); partitionSize = settings.value(PartitionSizeKey, 1024).toInt();
sdkLocation = FileName::fromString(settings.value(SDKLocationKey).toString()); sdkLocation = FileName::fromString(settings.value(SDKLocationKey).toString());
ndkLocation = FileName::fromString(settings.value(NDKLocationKey).toString()); ndkLocation = FileName::fromString(settings.value(NDKLocationKey).toString());
...@@ -133,14 +137,6 @@ AndroidConfig::AndroidConfig(const QSettings &settings) ...@@ -133,14 +137,6 @@ AndroidConfig::AndroidConfig(const QSettings &settings)
openJDKLocation = FileName::fromString(settings.value(OpenJDKLocationKey).toString()); openJDKLocation = FileName::fromString(settings.value(OpenJDKLocationKey).toString());
keystoreLocation = FileName::fromString(settings.value(KeystoreLocationKey).toString()); keystoreLocation = FileName::fromString(settings.value(KeystoreLocationKey).toString());
QRegExp versionRegExp(NDKGccVersionRegExp);
const QString &value = settings.value(NDKToolchainVersionKey).toString();
if (versionRegExp.exactMatch(value))
ndkToolchainVersion = value;
else
ndkToolchainVersion = value.mid(versionRegExp.indexIn(value)+1);
// user settings
PersistentSettingsReader reader; PersistentSettingsReader reader;
if (reader.load(FileName::fromString(sdkSettingsFileName())) if (reader.load(FileName::fromString(sdkSettingsFileName()))
&& settings.value(changeTimeStamp).toInt() != QFileInfo(sdkSettingsFileName()).lastModified().toMSecsSinceEpoch() / 1000) { && settings.value(changeTimeStamp).toInt() != QFileInfo(sdkSettingsFileName()).lastModified().toMSecsSinceEpoch() / 1000) {
...@@ -150,25 +146,6 @@ AndroidConfig::AndroidConfig(const QSettings &settings) ...@@ -150,25 +146,6 @@ AndroidConfig::AndroidConfig(const QSettings &settings)
antLocation = FileName::fromString(reader.restoreValue(AntLocationKey).toString()); antLocation = FileName::fromString(reader.restoreValue(AntLocationKey).toString());
openJDKLocation = FileName::fromString(reader.restoreValue(OpenJDKLocationKey).toString()); openJDKLocation = FileName::fromString(reader.restoreValue(OpenJDKLocationKey).toString());
keystoreLocation = FileName::fromString(reader.restoreValue(KeystoreLocationKey).toString()); keystoreLocation = FileName::fromString(reader.restoreValue(KeystoreLocationKey).toString());
QRegExp versionRegExp(NDKGccVersionRegExp);
const QString &value = reader.restoreValue(NDKToolchainVersionKey).toString();
if (versionRegExp.exactMatch(value))
ndkToolchainVersion = value;
else
ndkToolchainVersion = value.mid(versionRegExp.indexIn(value)+1);
if (armGdbLocation.isEmpty())
armGdbLocation = FileName::fromString(reader.restoreValue(ArmGdbLocationKey).toString());
if (armGdbserverLocation.isEmpty())
armGdbserverLocation = FileName::fromString(reader.restoreValue(ArmGdbserverLocationKey).toString());
if (x86GdbLocation.isEmpty())
x86GdbLocation = FileName::fromString(reader.restoreValue(X86GdbLocationKey).toString());
if (x86GdbserverLocation.isEmpty())
x86GdbserverLocation = FileName::fromString(reader.restoreValue(X86GdbserverLocationKey).toString());
// persistent settings // persistent settings
} }
...@@ -188,14 +165,9 @@ void AndroidConfig::save(QSettings &settings) const ...@@ -188,14 +165,9 @@ void AndroidConfig::save(QSettings &settings) const
// user settings // user settings
settings.setValue(SDKLocationKey, sdkLocation.toString()); settings.setValue(SDKLocationKey, sdkLocation.toString());
settings.setValue(NDKLocationKey, ndkLocation.toString()); settings.setValue(NDKLocationKey, ndkLocation.toString());
settings.setValue(NDKToolchainVersionKey, ndkToolchainVersion);
settings.setValue(AntLocationKey, antLocation.toString()); settings.setValue(AntLocationKey, antLocation.toString());
settings.setValue(OpenJDKLocationKey, openJDKLocation.toString()); settings.setValue(OpenJDKLocationKey, openJDKLocation.toString());
settings.setValue(KeystoreLocationKey, keystoreLocation.toString()); settings.setValue(KeystoreLocationKey, keystoreLocation.toString());
settings.setValue(ArmGdbLocationKey, armGdbLocation.toString());
settings.setValue(ArmGdbserverLocationKey, armGdbserverLocation.toString());
settings.setValue(X86GdbLocationKey, x86GdbLocation.toString());
settings.setValue(X86GdbserverLocationKey, x86GdbserverLocation.toString());
settings.setValue(PartitionSizeKey, partitionSize); settings.setValue(PartitionSizeKey, partitionSize);
} }
...@@ -240,25 +212,6 @@ QStringList AndroidConfigurations::sdkTargets(int minApiLevel) const ...@@ -240,25 +212,6 @@ QStringList AndroidConfigurations::sdkTargets(int minApiLevel) const
return targets; return targets;
} }
QStringList AndroidConfigurations::ndkToolchainVersions() const
{
QRegExp versionRegExp(NDKGccVersionRegExp);
QStringList result;
FileName path = m_config.ndkLocation;
QDirIterator it(path.appendPath(QLatin1String("toolchains")).toString(),
QStringList() << QLatin1String("*"), QDir::Dirs);
while (it.hasNext()) {
const QString &fileName = it.next();
int idx = versionRegExp.indexIn(fileName);
if (idx == -1)
continue;
QString version = fileName.mid(idx+1);
if (!result.contains(version))
result.append(version);
}
return result;
}
FileName AndroidConfigurations::adbToolPath() const FileName AndroidConfigurations::adbToolPath() const
{ {
FileName path = m_config.sdkLocation; FileName path = m_config.sdkLocation;
...@@ -296,71 +249,29 @@ FileName AndroidConfigurations::emulatorToolPath() const ...@@ -296,71 +249,29 @@ FileName AndroidConfigurations::emulatorToolPath() const
return path.appendPath(QLatin1String("tools/emulator" QTC_HOST_EXE_SUFFIX)); return path.appendPath(QLatin1String("tools/emulator" QTC_HOST_EXE_SUFFIX));
} }
FileName AndroidConfigurations::toolPath(Abi::Architecture architecture) const FileName AndroidConfigurations::toolPath(Abi::Architecture architecture, const QString &ndkToolChainVersion) const
{ {
FileName path = m_config.ndkLocation; FileName path = m_config.ndkLocation;
return path.appendPath(QString::fromLatin1("toolchains/%1-%2/prebuilt/%3/bin/%4") return path.appendPath(QString::fromLatin1("toolchains/%1-%2/prebuilt/%3/bin/%4")
.arg(toolchainPrefix(architecture)) .arg(toolchainPrefix(architecture))
.arg(m_config.ndkToolchainVersion) .arg(ndkToolChainVersion)
.arg(ToolchainHost) .arg(ToolchainHost)
.arg(toolsPrefix(architecture))); .arg(toolsPrefix(architecture)));
} }
FileName AndroidConfigurations::stripPath(Abi::Architecture architecture) const FileName AndroidConfigurations::stripPath(Abi::Architecture architecture, const QString &ndkToolChainVersion) const
{ {
return toolPath(architecture).append(QLatin1String("-strip" QTC_HOST_EXE_SUFFIX)); return toolPath(architecture, ndkToolChainVersion).append(QLatin1String("-strip" QTC_HOST_EXE_SUFFIX));
} }
FileName AndroidConfigurations::readelfPath(Abi::Architecture architecture) const FileName AndroidConfigurations::readelfPath(Abi::Architecture architecture, const QString &ndkToolChainVersion) const
{ {
return toolPath(architecture).append(QLatin1String("-readelf" QTC_HOST_EXE_SUFFIX)); return toolPath(architecture, ndkToolChainVersion).append(QLatin1String("-readelf" QTC_HOST_EXE_SUFFIX));
} }
FileName AndroidConfigurations::gccPath(Abi::Architecture architecture) const FileName AndroidConfigurations::gdbPath(Abi::Architecture architecture, const QString &ndkToolChainVersion) const
{ {
return toolPath(architecture).append(QLatin1String("-gcc" QTC_HOST_EXE_SUFFIX)); return toolPath(architecture, ndkToolChainVersion).append(QLatin1String("-gdb" QTC_HOST_EXE_SUFFIX));
}
FileName AndroidConfigurations::gdbServerPath(Abi::Architecture architecture) const
{
FileName gdbServerPath;
switch (architecture) {
case Abi::ArmArchitecture:
gdbServerPath = m_config.armGdbserverLocation;
break;
case Abi::X86Architecture:
gdbServerPath = m_config.x86GdbserverLocation;
break;
default:
gdbServerPath = FileName::fromString(Unknown);
break;
}
if (!gdbServerPath.isEmpty())
return gdbServerPath;
FileName path = m_config.ndkLocation;
return path.appendPath(QString::fromLatin1("toolchains/%1-%2/prebuilt/gdbserver")
.arg(toolchainPrefix(architecture))
.arg(m_config.ndkToolchainVersion));
}
FileName AndroidConfigurations::gdbPath(Abi::Architecture architecture) const
{
FileName gdbPath;
switch (architecture) {
case Abi::ArmArchitecture:
gdbPath = m_config.armGdbLocation;
break;
case Abi::X86Architecture:
gdbPath = m_config.x86GdbLocation;
break;
default:
gdbPath = FileName::fromString(Unknown);
break;
}
if (!gdbPath.isEmpty())
return gdbPath;
return toolPath(architecture).append(QLatin1String("-gdb" QTC_HOST_EXE_SUFFIX));
} }
FileName AndroidConfigurations::openJDKPath() const FileName AndroidConfigurations::openJDKPath() const
......
...@@ -66,12 +66,7 @@ public: ...@@ -66,12 +66,7 @@ public:
Utils::FileName sdkLocation; Utils::FileName sdkLocation;
Utils::FileName ndkLocation; Utils::FileName ndkLocation;
QString ndkToolchainVersion;
Utils::FileName antLocation; Utils::FileName antLocation;
Utils::FileName armGdbLocation;
Utils::FileName armGdbserverLocation;
Utils::FileName x86GdbLocation;
Utils::FileName x86GdbserverLocation;
Utils::FileName openJDKLocation; Utils::FileName openJDKLocation;
Utils::FileName keystoreLocation; Utils::FileName keystoreLocation;
unsigned partitionSize; unsigned partitionSize;
...@@ -93,20 +88,17 @@ public: ...@@ -93,20 +88,17 @@ public:
AndroidConfig config() const { return m_config; } AndroidConfig config() const { return m_config; }
void setConfig(const AndroidConfig &config); void setConfig(const AndroidConfig &config);
QStringList sdkTargets(int minApiLevel = 0) const; QStringList sdkTargets(int minApiLevel = 0) const;
QStringList ndkToolchainVersions() const;
Utils::FileName adbToolPath() const; Utils::FileName adbToolPath() const;
Utils::FileName androidToolPath() const; Utils::FileName androidToolPath() const;
Utils::FileName antToolPath() const; Utils::FileName antToolPath() const;
Utils::FileName emulatorToolPath() const; Utils::FileName emulatorToolPath() const;
Utils::FileName gccPath(ProjectExplorer::Abi::Architecture architecture) const; Utils::FileName gdbPath(ProjectExplorer::Abi::Architecture architecture, const QString &ndkToolChainVersion) const;
Utils::FileName gdbServerPath(ProjectExplorer::Abi::Architecture architecture) const;
Utils::FileName gdbPath(ProjectExplorer::Abi::Architecture architecture) const;
Utils::FileName openJDKPath() const; Utils::FileName openJDKPath() const;
Utils::FileName keytoolPath() const; Utils::FileName keytoolPath() const;
Utils::FileName jarsignerPath() const; Utils::FileName jarsignerPath() const;
Utils::FileName zipalignPath() const; Utils::FileName zipalignPath() const;
Utils::FileName stripPath(ProjectExplorer::Abi::Architecture architecture) const; Utils::FileName stripPath(ProjectExplorer::Abi::Architecture architecture, const QString &ndkToolChainVersion) const;
Utils::FileName readelfPath(ProjectExplorer::Abi::Architecture architecture) const; Utils::FileName readelfPath(ProjectExplorer::Abi::Architecture architecture, const QString &ndkToolChainVersion) const;
QString getDeployDeviceSerialNumber(int *apiLevel) const; QString getDeployDeviceSerialNumber(int *apiLevel) const;
bool createAVD(const QString &target, const QString &name, int sdcardSize) const; bool createAVD(const QString &target, const QString &name, int sdcardSize) const;
bool removeAVD(const QString &name) const; bool removeAVD(const QString &name) const;
...@@ -115,6 +107,7 @@ public: ...@@ -115,6 +107,7 @@ public:
QString startAVD(int *apiLevel, const QString &name = QString()) const; QString startAVD(int *apiLevel, const QString &name = QString()) const;
QString bestMatch(const QString &targetAPI) const; QString bestMatch(const QString &targetAPI) const;
static ProjectExplorer::Abi::Architecture architectureForToolChainPrefix(const QString &toolchainprefix);
static QLatin1String toolchainPrefix(ProjectExplorer::Abi::Architecture architecture); static QLatin1String toolchainPrefix(ProjectExplorer::Abi::Architecture architecture);
static QLatin1String toolsPrefix(ProjectExplorer::Abi::Architecture architecture); static QLatin1String toolsPrefix(ProjectExplorer::Abi::Architecture architecture);
...@@ -125,7 +118,7 @@ public slots: ...@@ -125,7 +118,7 @@ public slots:
bool createAVD(int minApiLevel = 0) const; bool createAVD(int minApiLevel = 0) const;
private: private:
Utils::FileName toolPath(ProjectExplorer::Abi::Architecture architecture) const; Utils::FileName toolPath(ProjectExplorer::Abi::Architecture architecture, const QString &ndkToolChainVersion) const;
Utils::FileName openJDKBinPath() const; Utils::FileName openJDKBinPath() const;
AndroidConfigurations(QObject *parent); AndroidConfigurations(QObject *parent);
......
...@@ -57,6 +57,7 @@ const char ANDROID_SETTINGS_CATEGORY[] = "XA.Android"; ...@@ -57,6 +57,7 @@ const char ANDROID_SETTINGS_CATEGORY[] = "XA.Android";
const char ANDROID_SETTINGS_TR_CATEGORY[] = QT_TRANSLATE_NOOP("Android", "Android"); const char ANDROID_SETTINGS_TR_CATEGORY[] = QT_TRANSLATE_NOOP("Android", "Android");
const char ANDROID_SETTINGS_CATEGORY_ICON[] = ":/android/images/QtAndroid.png"; const char ANDROID_SETTINGS_CATEGORY_ICON[] = ":/android/images/QtAndroid.png";
const char ANDROID_TOOLCHAIN_ID[] = "Qt4ProjectManager.ToolChain.Android"; const char ANDROID_TOOLCHAIN_ID[] = "Qt4ProjectManager.ToolChain.Android";
const char ANDROID_TOOLCHAIN_TYPE[] = "androidgcc";
const char ANDROIDQT[] = "Qt4ProjectManager.QtVersion.Android"; const char ANDROIDQT[] = "Qt4ProjectManager.QtVersion.Android";
const char ANDROID_DEVICE_TYPE[] = "Android.Device.Type"; const char ANDROID_DEVICE_TYPE[] = "Android.Device.Type";
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include "androidpackagecreationstep.h" #include "androidpackagecreationstep.h"
#include "androidrunconfiguration.h" #include "androidrunconfiguration.h"
#include "androidmanager.h" #include "androidmanager.h"
#include "androidtoolchain.h"
#include <coreplugin/messagemanager.h> #include <coreplugin/messagemanager.h>
#include <projectexplorer/buildconfiguration.h> #include <projectexplorer/buildconfiguration.h>
...@@ -114,6 +115,12 @@ bool AndroidDeployStep::init() ...@@ -114,6 +115,12 @@ bool AndroidDeployStep::init()
m_buildDirectory = static_cast<Qt4Project *>(target()->project())->rootQt4ProjectNode()->buildDir(); m_buildDirectory = static_cast<Qt4Project *>(target()->project())->rootQt4ProjectNode()->buildDir();
m_runQASIPackagePath = m_QASIPackagePath; m_runQASIPackagePath = m_QASIPackagePath;
m_runDeployAction = m_deployAction; m_runDeployAction = m_deployAction;
ToolChain *tc = ToolChainKitInformation::toolChain(target()->kit());
if (!tc || tc->type() != QLatin1String(Constants::ANDROID_TOOLCHAIN_TYPE)) {
raiseError(tr("No android toolchain selected"));
return false;
}
m_ndkToolChainVersion = static_cast<AndroidToolChain *>(tc)->ndkToolChainVersion();
return true; return true;
} }
...@@ -352,11 +359,11 @@ void AndroidDeployStep::copyFilesToTemp(QList<DeployItem> *deployList, const QSt ...@@ -352,11 +359,11 @@ void AndroidDeployStep::copyFilesToTemp(QList<DeployItem> *deployList, const QSt
} }
} }
void AndroidDeployStep::stripFiles(const QList<DeployItem> &deployList, Abi::Architecture architecture) void AndroidDeployStep::stripFiles(const QList<DeployItem> &deployList, Abi::Architecture architecture, const QString &ndkToolchainVersion)
{ {
QProcess stripProcess; QProcess stripProcess;
foreach (const DeployItem &item, deployList) { foreach (const DeployItem &item, deployList) {
stripProcess.start(AndroidConfigurations::instance().stripPath(architecture).toString(), stripProcess.start(AndroidConfigurations::instance().stripPath(architecture, ndkToolchainVersion).toString(),
QStringList()<<QLatin1String("--strip-unneeded") << item.localFileName); QStringList()<<QLatin1String("--strip-unneeded") << item.localFileName);
stripProcess.waitForStarted(); stripProcess.waitForStarted();
if (!stripProcess.waitForFinished()) if (!stripProcess.waitForFinished())
...@@ -414,7 +421,7 @@ bool AndroidDeployStep::deployPackage() ...@@ -414,7 +421,7 @@ bool AndroidDeployStep::deployPackage()
fetchRemoteModificationTimes(&deployList); fetchRemoteModificationTimes(&deployList);
filterModificationTimes(&deployList); filterModificationTimes(&deployList);
copyFilesToTemp(&deployList, tempPath, m_qtVersionSourcePath); copyFilesToTemp(&deployList, tempPath, m_qtVersionSourcePath);
stripFiles(deployList, target()->activeRunConfiguration()->abi().architecture()); stripFiles(deployList, target()->activeRunConfiguration()->abi().architecture(), m_ndkToolChainVersion);
deployFiles(deployProc, deployList); deployFiles(deployProc, deployList);
AndroidPackageCreationStep::removeDirectory(tempPath); AndroidPackageCreationStep::removeDirectory(tempPath);
......
...@@ -132,7 +132,7 @@ private: ...@@ -132,7 +132,7 @@ private:
void filterModificationTimes(QList<DeployItem> *deployList); void filterModificationTimes(QList<DeployItem> *deployList);
void copyFilesToTemp(QList<DeployItem> *deployList, const QString &tempDirectory, const QString &sourcePrefix); void copyFilesToTemp(QList<DeployItem> *deployList, const QString &tempDirectory, const QString &sourcePrefix);
void fetchRemoteModificationTimes(QList<DeployItem> *deployList); void fetchRemoteModificationTimes(QList<DeployItem> *deployList);
void stripFiles(const QList<DeployItem> &deployList, ProjectExplorer::Abi::Architecture architecture); void stripFiles(const QList<DeployItem> &deployList, ProjectExplorer::Abi::Architecture architecture, const QString &ndkToolchainVersion);
void deployFiles(QProcess *process, const QList<DeployItem> &deployList); void deployFiles(QProcess *process, const QList<DeployItem> &deployList);
private: private:
...@@ -153,6 +153,7 @@ private: ...@@ -153,6 +153,7 @@ private:
QString m_buildDirectory; QString m_buildDirectory;
QString m_runQASIPackagePath; QString m_runQASIPackagePath;
AndroidDeployAction m_runDeployAction; AndroidDeployAction m_runDeployAction;
QString m_ndkToolChainVersion;
static const Core::Id Id; static const Core::Id Id;
}; };
......
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** 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.
**
** GNU Lesser General Public License Usage
** 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
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include "androidgdbserverkitinformation.h"
#include "androidconstants.h"
#include "androidtoolchain.h"
#include <utils/pathchooser.h>
#include <QDialogButtonBox>
#include <QLabel>
#include <QPushButton>
#include <QMenu>
#include <QDialog>
#include <QVBoxLayout>
#include <QFormLayout>
using namespace Android;
using namespace Android::Internal;
namespace {
static const char ANDROIDGDBSERVER_INFORMATION[] = "Android.GdbServer.Information";
}
AndroidGdbServerKitInformation::AndroidGdbServerKitInformation()
{
}
Core::Id AndroidGdbServerKitInformation::dataId() const
{
return Core::Id(ANDROIDGDBSERVER_INFORMATION);
}
unsigned int AndroidGdbServerKitInformation::priority() const
{
return 27999; // Just one less than Debugger!
}
QVariant AndroidGdbServerKitInformation::defaultValue(ProjectExplorer::Kit *kit) const
{
return autoDetect(kit).toString();
}
QList<ProjectExplorer::Task> AndroidGdbServerKitInformation::validate(const ProjectExplorer::Kit *) const
{
return QList<ProjectExplorer::Task>();
}
ProjectExplorer::KitInformation::ItemList AndroidGdbServerKitInformation::toUserOutput(ProjectExplorer::Kit *kit) const
{
return ProjectExplorer::KitInformation::ItemList()
<< qMakePair(tr("GDBserver"), AndroidGdbServerKitInformation::gdbServer(kit).toUserOutput());
}
ProjectExplorer::KitConfigWidget *AndroidGdbServerKitInformation::createConfigWidget(ProjectExplorer::Kit *kit) const
{
return new AndroidGdbServerKitInformationWidget(kit);
}
Utils::FileName AndroidGdbServerKitInformation::gdbServer(ProjectExplorer::Kit *kit)
{
return Utils::FileName::fromString(kit->value(Core::Id(ANDROIDGDBSERVER_INFORMATION)).toString());
}
void AndroidGdbServerKitInformation::setGdbSever(ProjectExplorer::Kit *kit, const Utils::FileName &gdbServerCommand)
{
kit->setValue(Core::Id(ANDROIDGDBSERVER_INFORMATION),
gdbServerCommand.toString());
}
Utils::FileName AndroidGdbServerKitInformation::autoDetect(ProjectExplorer::Kit *kit)
{
ProjectExplorer::ToolChain *tc = ProjectExplorer::ToolChainKitInformation::toolChain(kit);
if (tc->type() != QLatin1String(Constants::ANDROID_TOOLCHAIN_TYPE))
return Utils::FileName();
AndroidToolChain *atc = static_cast<AndroidToolChain *>(tc);
return atc->suggestedGdbServer();
}
///////////////
// AndroidGdbServerKitInformationWidget
///////////////
AndroidGdbServerKitInformationWidget::AndroidGdbServerKitInformationWidget(ProjectExplorer::Kit *kit)
: ProjectExplorer::KitConfigWidget(kit),
m_label(new QLabel),
m_button(new QPushButton(tr("Manage...")))
{
// ToolButton with Menu, defaulting to 'Autodetect'.
QMenu *buttonMenu = new QMenu(m_button);
QAction *autoDetectAction = buttonMenu->addAction(tr("Auto-detect"));
connect(autoDetectAction, SIGNAL(triggered()), this, SLOT(autoDetectDebugger()));
QAction *changeAction =