Commit 64e5a543 authored by BogDan Vatra's avatar BogDan Vatra Committed by Daniel Teske

Move qmake specific part to qmake plugin, generalize android support

- Split up androiddeployqt into two steps: One building the apk,
  and one deploying it to the device.
- The build apk step base class AndroidBuildApkStep is ihneritaged by
  the qmake specific class QmakeAndroidBuildApkStep.
- The deployment step is still called androiddeployqt
- Move all qmake specific code to the qmakeprojectmanager plguin
- Flip the depencency between the android and qmake plugin, now
  the qmake plugin depends on the android plugin, implementing
  a interface the android plugin provides.

- Note: This removes the debug deployment for now.

Change-Id: I1c386640159ed14b637668abde8eb3b9009ab803
Reviewed-by: default avatarBogDan Vatra <bogdan@kde.org>
parent 4657ac74
......@@ -16,8 +16,6 @@ HEADERS += \
androidsettingspage.h \
androidsettingswidget.h \
androidtoolchain.h \
androidpackageinstallationstep.h \
androidpackageinstallationfactory.h \
androiderrormessage.h \
androidglobal.h \
androidrunner.h \
......@@ -41,9 +39,7 @@ HEADERS += \
androiddeployqtstep.h \
certificatesmodel.h \
androiddeployqtwidget.h \
createandroidmanifestwizard.h \
androidpotentialkit.h \
androidextralibrarylistmodel.h \
androidsignaloperation.h \
javaeditor.h \
javaeditorfactory.h \
......@@ -53,9 +49,8 @@ HEADERS += \
javafilewizard.h \
avddialog.h \
android_global.h \
qmakeandroidsupport.h \
qmakeandroidrunfactories.h \
qmakeandroidrunconfiguration.h
androidbuildapkstep.h \
androidbuildapkwidget.h
SOURCES += \
androidconfigurations.cpp \
......@@ -66,8 +61,6 @@ SOURCES += \
androidsettingspage.cpp \
androidsettingswidget.cpp \
androidtoolchain.cpp \
androidpackageinstallationstep.cpp \
androidpackageinstallationfactory.cpp \
androiderrormessage.cpp \
androidrunner.cpp \
androiddebugsupport.cpp \
......@@ -90,9 +83,7 @@ SOURCES += \
androiddeployqtstep.cpp \
certificatesmodel.cpp \
androiddeployqtwidget.cpp \
createandroidmanifestwizard.cpp \
androidpotentialkit.cpp \
androidextralibrarylistmodel.cpp \
androidsignaloperation.cpp \
javaeditor.cpp \
javaeditorfactory.cpp \
......@@ -101,16 +92,17 @@ SOURCES += \
javacompletionassistprovider.cpp \
javafilewizard.cpp \
avddialog.cpp \
qmakeandroidsupport.cpp \
qmakeandroidrunfactories.cpp \
qmakeandroidrunconfiguration.cpp
androidbuildapkstep.cpp \
androidbuildapkwidget.cpp
FORMS += \
androidsettingswidget.ui \
addnewavddialog.ui \
androidcreatekeystorecertificate.ui \
androiddevicedialog.ui \
androiddeployqtwidget.ui
androiddeployqtwidget.ui \
androidbuildapkwidget.ui
RESOURCES = android.qrc
DEFINES += ANDROID_LIBRARY
......@@ -5,19 +5,15 @@ import QtcPlugin
QtcPlugin {
name: "Android"
Depends { name: "Qt"; submodules: ["widgets", "xml", "network"] }
Depends { name: "AnalyzerBase" }
Depends { name: "Core" }
Depends { name: "ProjectExplorer" }
Depends { name: "QmakeProjectManager" }
Depends { name: "Debugger" }
Depends { name: "ProjectExplorer" }
Depends { name: "QmlDebug" }
Depends { name: "QtSupport" }
Depends { name: "TextEditor" }
Depends { name: "AnalyzerBase" }
Depends { name: "Utils" }
Depends { name: "Qt"; submodules: ["widgets", "xml", "network"] }
property bool enable: false
pluginspecreplacements: ({"ANDROID_EXPERIMENTAL_STR": (enable ? "false": "true")})
files: [
"android_global.h",
......@@ -31,6 +27,11 @@ QtcPlugin {
"androidcreatekeystorecertificate.cpp",
"androidcreatekeystorecertificate.h",
"androidcreatekeystorecertificate.ui",
"androidbuildapkstep.cpp",
"androidbuildapkstep.h",
"androidbuildapkwidget.cpp",
"androidbuildapkwidget.h",
"androidbuildapkwidget.ui",
"androiddeployqtstep.cpp",
"androiddeployqtstep.h",
"androiddebugsupport.cpp",
......@@ -49,8 +50,6 @@ QtcPlugin {
"androiddevicefactory.h",
"androiderrormessage.h",
"androiderrormessage.cpp",
"androidextralibrarylistmodel.cpp",
"androidextralibrarylistmodel.h",
"androidgdbserverkitinformation.cpp",
"androidgdbserverkitinformation.h",
"androidglobal.h",
......@@ -64,10 +63,6 @@ QtcPlugin {
"androidmanifesteditorfactory.h",
"androidmanifesteditorwidget.cpp",
"androidmanifesteditorwidget.h",
"androidpackageinstallationfactory.cpp",
"androidpackageinstallationfactory.h",
"androidpackageinstallationstep.cpp",
"androidpackageinstallationstep.h",
"androidplugin.cpp",
"androidplugin.h",
"androidpotentialkit.cpp",
......@@ -100,8 +95,6 @@ QtcPlugin {
"avddialog.h",
"certificatesmodel.cpp",
"certificatesmodel.h",
"createandroidmanifestwizard.cpp",
"createandroidmanifestwizard.h",
"javaautocompleter.cpp",
"javaautocompleter.h",
"javacompletionassistprovider.cpp",
......@@ -116,12 +109,5 @@ QtcPlugin {
"javaindenter.h",
"javaparser.cpp",
"javaparser.h",
"qmakeandroidrunconfiguration.cpp",
"qmakeandroidrunconfiguration.h",
"qmakeandroidrunfactories.cpp",
"qmakeandroidrunfactories.h",
"qmakeandroidsupport.cpp",
"qmakeandroidsupport.h",
]
}
......@@ -3,7 +3,6 @@ QTC_PLUGIN_DEPENDS += \
coreplugin \
debugger \
projectexplorer \
qmakeprojectmanager \
qtsupport \
texteditor \
analyzerbase
......
......@@ -40,7 +40,6 @@ namespace Android {
class AndroidRunConfiguration;
namespace Internal {
class AndroidRunner;
class AndroidAnalyzeSupport : public AndroidRunSupport
......
This diff is collapsed.
/**************************************************************************
**
** Copyright (c) 2014 BogDan Vatra <bog_dan_ro@yahoo.com>
** Copyright (C) 2014 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.
**
****************************************************************************/
#ifndef ANDROIDBUILDAPKSTEP_H
#define ANDROIDBUILDAPKSTEP_H
#include "android_global.h"
#include <projectexplorer/abstractprocessstep.h>
#include <qtsupport/baseqtversion.h>
QT_BEGIN_NAMESPACE
class QAbstractItemModel;
QT_END_NAMESPACE
namespace Android {
class ANDROID_EXPORT AndroidBuildApkStep : public ProjectExplorer::AbstractProcessStep
{
Q_OBJECT
public:
AndroidBuildApkStep(ProjectExplorer::BuildStepList *bc, const Core::Id id);
enum AndroidDeployAction
{
MinistroDeployment, // use ministro
DebugDeployment,
BundleLibrariesDeployment
};
bool fromMap(const QVariantMap &map);
QVariantMap toMap() const;
AndroidDeployAction deployAction() const;
// signing
Utils::FileName keystorePath();
void setKeystorePath(const Utils::FileName &path);
void setKeystorePassword(const QString &pwd);
void setCertificateAlias(const QString &alias);
void setCertificatePassword(const QString &pwd);
QAbstractItemModel *keystoreCertificates();
bool signPackage() const;
void setSignPackage(bool b);
bool openPackageLocation() const;
void setOpenPackageLocation(bool open);
bool verboseOutput() const;
void setVerboseOutput(bool verbose);
bool runInGuiThread() const;
QString buildTargetSdk() const;
void setBuildTargetSdk(const QString &sdk);
public slots:
void setDeployAction(AndroidDeployAction deploy);
protected slots:
void showInGraphicalShell();
protected:
AndroidBuildApkStep(ProjectExplorer::BuildStepList *bc,
AndroidBuildApkStep *other);
bool keystorePassword();
bool certificatePassword();
bool init();
ProjectExplorer::BuildStepConfigWidget *createConfigWidget();
bool immutable() const { return true; }
void processFinished(int exitCode, QProcess::ExitStatus status);
virtual Utils::FileName androidPackageSourceDir() const = 0;
protected:
AndroidDeployAction m_deployAction;
bool m_signPackage;
bool m_verbose;
bool m_openPackageLocation;
bool m_openPackageLocationForRun;
QString m_buildTargetSdk;
Utils::FileName m_keystorePath;
QString m_keystorePasswd;
QString m_certificateAlias;
QString m_certificatePasswd;
QString m_apkPath;
};
} // namespace Android
#endif // ANDROIDBUILDAPKSTEP_H
/**************************************************************************
**
** Copyright (c) 2014 BogDan Vatra <bog_dan_ro@yahoo.com>
** Copyright (C) 2014 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 "androidbuildapkstep.h"
#include "androidbuildapkwidget.h"
#include "androidconfigurations.h"
#include "androidcreatekeystorecertificate.h"
#include "androidmanager.h"
#include "ui_androidbuildapkwidget.h"
#include <projectexplorer/buildconfiguration.h>
#include <projectexplorer/project.h>
#include <projectexplorer/target.h>
#include <qtsupport/qtkitinformation.h>
#include <utils/fancylineedit.h>
#include <utils/pathchooser.h>
#include <QFileDialog>
#include <algorithm>
using namespace Android;
using namespace Internal;
AndroidBuildApkWidget::AndroidBuildApkWidget(AndroidBuildApkStep *step)
: ProjectExplorer::BuildStepConfigWidget(),
m_ui(new Ui::AndroidBuildApkWidget),
m_step(step)
{
m_ui->setupUi(this);
// Target sdk combobox
int minApiLevel = 9;
QStringList targets = AndroidConfig::apiLevelNamesFor(AndroidConfigurations::currentConfig().sdkTargets(minApiLevel));
m_ui->targetSDKComboBox->addItems(targets);
m_ui->targetSDKComboBox->setCurrentIndex(targets.indexOf(AndroidManager::buildTargetSDK(step->target())));
// deployment option
switch (m_step->deployAction()) {
case AndroidBuildApkStep::MinistroDeployment:
m_ui->ministroOption->setChecked(true);
break;
case AndroidBuildApkStep::DebugDeployment:
m_ui->temporaryQtOption->setChecked(true);
break;
case AndroidBuildApkStep::BundleLibrariesDeployment:
m_ui->bundleQtOption->setChecked(true);
break;
default:
// can't happen
break;
}
// signing
m_ui->signPackageCheckBox->setChecked(m_step->signPackage());
m_ui->KeystoreLocationPathChooser->setExpectedKind(Utils::PathChooser::File);
m_ui->KeystoreLocationPathChooser->lineEdit()->setReadOnly(true);
m_ui->KeystoreLocationPathChooser->setPath(m_step->keystorePath().toUserOutput());
m_ui->KeystoreLocationPathChooser->setInitialBrowsePathBackup(QDir::homePath());
m_ui->KeystoreLocationPathChooser->setPromptDialogFilter(tr("Keystore files (*.keystore *.jks)"));
m_ui->KeystoreLocationPathChooser->setPromptDialogTitle(tr("Select Keystore File"));
m_ui->signingDebugWarningIcon->hide();
m_ui->signingDebugWarningLabel->hide();
signPackageCheckBoxToggled(m_step->signPackage());
m_ui->verboseOutputCheckBox->setChecked(m_step->verboseOutput());
m_ui->openPackageLocationCheckBox->setChecked(m_step->openPackageLocation());
// target sdk
connect(m_ui->targetSDKComboBox, SIGNAL(activated(QString)), SLOT(setTargetSdk(QString)));
// deployment options
connect(m_ui->ministroOption, SIGNAL(clicked()), SLOT(setMinistro()));
connect(m_ui->temporaryQtOption, SIGNAL(clicked()), SLOT(setDeployLocalQtLibs()));
connect(m_ui->bundleQtOption, SIGNAL(clicked()), SLOT(setBundleQtLibs()));
connect(m_ui->openPackageLocationCheckBox, SIGNAL(toggled(bool)),
this, SLOT(openPackageLocationCheckBoxToggled(bool)));
connect(m_ui->verboseOutputCheckBox, SIGNAL(toggled(bool)),
this, SLOT(verboseOutputCheckBoxToggled(bool)));
//signing
connect(m_ui->signPackageCheckBox, SIGNAL(toggled(bool)),
this, SLOT(signPackageCheckBoxToggled(bool)));
connect(m_ui->KeystoreCreatePushButton, SIGNAL(clicked()),
this, SLOT(createKeyStore()));
connect(m_ui->KeystoreLocationPathChooser, SIGNAL(pathChanged(QString)),
SLOT(updateKeyStorePath(QString)));
connect(m_ui->certificatesAliasComboBox, SIGNAL(activated(QString)),
this, SLOT(certificatesAliasComboBoxActivated(QString)));
connect(m_ui->certificatesAliasComboBox, SIGNAL(currentIndexChanged(QString)),
this, SLOT(certificatesAliasComboBoxCurrentIndexChanged(QString)));
connect(m_step->buildConfiguration(), SIGNAL(buildTypeChanged()),
this, SLOT(updateSigningWarning()));
updateSigningWarning();
QtSupport::BaseQtVersion *qt = QtSupport::QtKitInformation::qtVersion(step->target()->kit());
m_ui->temporaryQtOption->setVisible(qt->qtVersion() >= QtSupport::QtVersionNumber(5, 4, 0));
}
AndroidBuildApkWidget::~AndroidBuildApkWidget()
{
delete m_ui;
}
QString AndroidBuildApkWidget::displayName() const
{
return tr("<b>Build Android APK</b>");
}
QString AndroidBuildApkWidget::summaryText() const
{
return displayName();
}
void AndroidBuildApkWidget::setTargetSdk(const QString &sdk)
{
m_step->setBuildTargetSdk(sdk);
}
void AndroidBuildApkWidget::setMinistro()
{
m_step->setDeployAction(AndroidBuildApkStep::MinistroDeployment);
}
void AndroidBuildApkWidget::setDeployLocalQtLibs()
{
m_step->setDeployAction(AndroidBuildApkStep::DebugDeployment);
}
void AndroidBuildApkWidget::setBundleQtLibs()
{
m_step->setDeployAction(AndroidBuildApkStep::BundleLibrariesDeployment);
}
void AndroidBuildApkWidget::signPackageCheckBoxToggled(bool checked)
{
m_ui->certificatesAliasComboBox->setEnabled(checked);
m_step->setSignPackage(checked);
updateSigningWarning();
if (!checked)
return;
if (!m_step->keystorePath().isEmpty())
setCertificates();
}
void AndroidBuildApkWidget::createKeyStore()
{
AndroidCreateKeystoreCertificate d;
if (d.exec() != QDialog::Accepted)
return;
m_ui->KeystoreLocationPathChooser->setPath(d.keystoreFilePath().toUserOutput());
m_step->setKeystorePath(d.keystoreFilePath());
m_step->setKeystorePassword(d.keystorePassword());
m_step->setCertificateAlias(d.certificateAlias());
m_step->setCertificatePassword(d.certificatePassword());
setCertificates();
}
void AndroidBuildApkWidget::setCertificates()
{
QAbstractItemModel *certificates = m_step->keystoreCertificates();
m_ui->signPackageCheckBox->setChecked(certificates);
m_ui->certificatesAliasComboBox->setModel(certificates);
}
void AndroidBuildApkWidget::updateKeyStorePath(const QString &path)
{
Utils::FileName file = Utils::FileName::fromString(path);
m_step->setKeystorePath(file);
m_ui->signPackageCheckBox->setChecked(!file.isEmpty());
if (!file.isEmpty())
setCertificates();
}
void AndroidBuildApkWidget::certificatesAliasComboBoxActivated(const QString &alias)
{
if (alias.length())
m_step->setCertificateAlias(alias);
}
void AndroidBuildApkWidget::certificatesAliasComboBoxCurrentIndexChanged(const QString &alias)
{
if (alias.length())
m_step->setCertificateAlias(alias);
}
void AndroidBuildApkWidget::openPackageLocationCheckBoxToggled(bool checked)
{
m_step->setOpenPackageLocation(checked);
}
void AndroidBuildApkWidget::verboseOutputCheckBoxToggled(bool checked)
{
m_step->setVerboseOutput(checked);
}
void AndroidBuildApkWidget::updateSigningWarning()
{
bool debug = m_step->buildConfiguration()->buildType() == ProjectExplorer::BuildConfiguration::Debug;
if (m_step->signPackage() && debug) {
m_ui->signingDebugWarningIcon->setVisible(true);
m_ui->signingDebugWarningLabel->setVisible(true);
} else {
m_ui->signingDebugWarningIcon->setVisible(false);
m_ui->signingDebugWarningLabel->setVisible(false);
}
}
/**************************************************************************
**
** Copyright (c) 2014 BogDan Vatra <bog_dan_ro@yahoo.com>
** Copyright (C) 2014 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.
**
****************************************************************************/
#ifndef ANDROIDBUILDAPKWIDGET_H
#define ANDROIDBUILDAPKWIDGET_H
#include "android_global.h"
#include <projectexplorer/buildstep.h>
#include <QWidget>
QT_BEGIN_NAMESPACE
namespace Ui { class AndroidBuildApkWidget; }
QT_END_NAMESPACE
namespace QmakeProjectManager { class QmakeBuildConfiguration; }
namespace Android {
class AndroidBuildApkStep;
class ANDROID_EXPORT AndroidBuildApkWidget : public ProjectExplorer::BuildStepConfigWidget
{
Q_OBJECT
public:
AndroidBuildApkWidget(AndroidBuildApkStep *step);
~AndroidBuildApkWidget();
private slots:
void setTargetSdk(const QString &sdk);
void setMinistro();
void setDeployLocalQtLibs();
void setBundleQtLibs();
void createKeyStore();
void certificatesAliasComboBoxCurrentIndexChanged(const QString &alias);
void certificatesAliasComboBoxActivated(const QString &alias);
void updateSigningWarning();
void openPackageLocationCheckBoxToggled(bool checked);
void verboseOutputCheckBoxToggled(bool checked);
void updateKeyStorePath(const QString &path);
void signPackageCheckBoxToggled(bool checked);
private:
virtual QString summaryText() const;
virtual QString displayName() const;
void setCertificates();
Ui::AndroidBuildApkWidget *m_ui;
AndroidBuildApkStep *m_step;
};
}
#endif // ANDROIDBUILDAPKWIDGET_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AndroidBuildApkWidget</class>
<widget class="QWidget" name="AndroidBuildApkWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>819</width>
<height>390</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>