forked from qt-creator/qt-creator
Android: Pass BuildSystem to CreateAndroidManifectWizard
Instead of a Target and hoping that its activeBuildystem is the right one. Change-Id: Ieb384d89e8f580b24205ce46a38f151aa72e2f6e Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io> Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -256,7 +256,7 @@ QWidget *AndroidBuildApkWidget::createCreateTemplatesGroup()
|
|||||||
|
|
||||||
auto createAndroidTemplatesButton = new QPushButton(tr("Create Templates"));
|
auto createAndroidTemplatesButton = new QPushButton(tr("Create Templates"));
|
||||||
connect(createAndroidTemplatesButton, &QAbstractButton::clicked, this, [this] {
|
connect(createAndroidTemplatesButton, &QAbstractButton::clicked, this, [this] {
|
||||||
CreateAndroidManifestWizard wizard(m_step->target());
|
CreateAndroidManifestWizard wizard(m_step->buildConfiguration()->buildSystem());
|
||||||
wizard.exec();
|
wizard.exec();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -31,6 +31,7 @@
|
|||||||
|
|
||||||
#include <coreplugin/editormanager/editormanager.h>
|
#include <coreplugin/editormanager/editormanager.h>
|
||||||
|
|
||||||
|
#include <projectexplorer/buildsystem.h>
|
||||||
#include <projectexplorer/project.h>
|
#include <projectexplorer/project.h>
|
||||||
#include <projectexplorer/projectnodes.h>
|
#include <projectexplorer/projectnodes.h>
|
||||||
#include <projectexplorer/runconfiguration.h>
|
#include <projectexplorer/runconfiguration.h>
|
||||||
@@ -80,13 +81,13 @@ ChooseProFilePage::ChooseProFilePage(CreateAndroidManifestWizard *wizard)
|
|||||||
label->setText(tr("Select the .pro file for which you want to create the Android template files."));
|
label->setText(tr("Select the .pro file for which you want to create the Android template files."));
|
||||||
fl->addRow(label);
|
fl->addRow(label);
|
||||||
|
|
||||||
Target *target = wizard->target();
|
BuildSystem *buildSystem = wizard->buildSystem();
|
||||||
QString currentBuildTarget;
|
QString currentBuildTarget;
|
||||||
if (RunConfiguration *rc = target->activeRunConfiguration())
|
if (RunConfiguration *rc = buildSystem->target()->activeRunConfiguration())
|
||||||
currentBuildTarget = rc->buildKey();
|
currentBuildTarget = rc->buildKey();
|
||||||
|
|
||||||
m_comboBox = new QComboBox(this);
|
m_comboBox = new QComboBox(this);
|
||||||
for (const BuildTargetInfo &bti : wizard->target()->applicationTargets()) {
|
for (const BuildTargetInfo &bti : buildSystem->applicationTargets()) {
|
||||||
const QString displayName = bti.buildKey;
|
const QString displayName = bti.buildKey;
|
||||||
m_comboBox->addItem(displayName, QVariant(bti.buildKey)); // TODO something more?
|
m_comboBox->addItem(displayName, QVariant(bti.buildKey)); // TODO something more?
|
||||||
if (bti.buildKey == currentBuildTarget)
|
if (bti.buildKey == currentBuildTarget)
|
||||||
@@ -147,7 +148,7 @@ ChooseDirectoryPage::ChooseDirectoryPage(CreateAndroidManifestWizard *wizard)
|
|||||||
void ChooseDirectoryPage::checkPackageSourceDir()
|
void ChooseDirectoryPage::checkPackageSourceDir()
|
||||||
{
|
{
|
||||||
const QString buildKey = m_wizard->buildKey();
|
const QString buildKey = m_wizard->buildKey();
|
||||||
const BuildTargetInfo bti = m_wizard->target()->buildTarget(buildKey);
|
const BuildTargetInfo bti = m_wizard->buildSystem()->buildTarget(buildKey);
|
||||||
const QString projectDir = bti.projectFilePath.toFileInfo().absolutePath();
|
const QString projectDir = bti.projectFilePath.toFileInfo().absolutePath();
|
||||||
|
|
||||||
const QString newDir = m_androidPackageSourceDir->path();
|
const QString newDir = m_androidPackageSourceDir->path();
|
||||||
@@ -168,7 +169,7 @@ bool ChooseDirectoryPage::isComplete() const
|
|||||||
|
|
||||||
void ChooseDirectoryPage::initializePage()
|
void ChooseDirectoryPage::initializePage()
|
||||||
{
|
{
|
||||||
const Target *target = m_wizard->target();
|
const Target *target = m_wizard->buildSystem()->target();
|
||||||
const QString buildKey = m_wizard->buildKey();
|
const QString buildKey = m_wizard->buildKey();
|
||||||
const BuildTargetInfo bti = target->buildTarget(buildKey);
|
const BuildTargetInfo bti = target->buildTarget(buildKey);
|
||||||
const QString projectDir = bti.projectFilePath.toFileInfo().absolutePath();
|
const QString projectDir = bti.projectFilePath.toFileInfo().absolutePath();
|
||||||
@@ -198,13 +199,13 @@ void ChooseDirectoryPage::initializePage()
|
|||||||
//
|
//
|
||||||
// CreateAndroidManifestWizard
|
// CreateAndroidManifestWizard
|
||||||
//
|
//
|
||||||
CreateAndroidManifestWizard::CreateAndroidManifestWizard(ProjectExplorer::Target *target)
|
CreateAndroidManifestWizard::CreateAndroidManifestWizard(BuildSystem *buildSystem)
|
||||||
: m_target(target), m_copyState(Ask)
|
: m_buildSystem(buildSystem), m_copyState(Ask)
|
||||||
{
|
{
|
||||||
setWindowTitle(tr("Create Android Template Files Wizard"));
|
setWindowTitle(tr("Create Android Template Files Wizard"));
|
||||||
|
|
||||||
const QList<BuildTargetInfo> buildTargets = target->applicationTargets();
|
const QList<BuildTargetInfo> buildTargets = buildSystem->applicationTargets();
|
||||||
QtSupport::BaseQtVersion *version = QtSupport::QtKitAspect::qtVersion(target->kit());
|
QtSupport::BaseQtVersion *version = QtSupport::QtKitAspect::qtVersion(buildSystem->kit());
|
||||||
m_copyGradle = version && version->qtVersion() >= QtSupport::QtVersionNumber(5, 4, 0);
|
m_copyGradle = version && version->qtVersion() >= QtSupport::QtVersionNumber(5, 4, 0);
|
||||||
|
|
||||||
if (buildTargets.isEmpty()) {
|
if (buildTargets.isEmpty()) {
|
||||||
@@ -308,7 +309,8 @@ void CreateAndroidManifestWizard::createAndroidTemplateFiles()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
QStringList addedFiles;
|
QStringList addedFiles;
|
||||||
QtSupport::BaseQtVersion *version = QtSupport::QtKitAspect::qtVersion(m_target->kit());
|
Target *target = m_buildSystem->target();
|
||||||
|
QtSupport::BaseQtVersion *version = QtSupport::QtKitAspect::qtVersion(target->kit());
|
||||||
if (!version)
|
if (!version)
|
||||||
return;
|
return;
|
||||||
if (version->qtVersion() < QtSupport::QtVersionNumber(5, 4, 0)) {
|
if (version->qtVersion() < QtSupport::QtVersionNumber(5, 4, 0)) {
|
||||||
@@ -331,12 +333,12 @@ void CreateAndroidManifestWizard::createAndroidTemplateFiles()
|
|||||||
nullptr, [this, &addedFiles](QFileInfo src, QFileInfo dst, QString *){return copy(src, dst, &addedFiles);});
|
nullptr, [this, &addedFiles](QFileInfo src, QFileInfo dst, QString *){return copy(src, dst, &addedFiles);});
|
||||||
}
|
}
|
||||||
|
|
||||||
AndroidManager::updateGradleProperties(m_target, m_buildKey);
|
AndroidManager::updateGradleProperties(target, m_buildKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString androidPackageDir;
|
QString androidPackageDir;
|
||||||
ProjectNode *node = m_target->project()->findNodeForBuildKey(m_buildKey);
|
ProjectNode *node = target->project()->findNodeForBuildKey(m_buildKey);
|
||||||
if (node) {
|
if (node) {
|
||||||
node->addFiles(addedFiles);
|
node->addFiles(addedFiles);
|
||||||
androidPackageDir = node->data(Android::Constants::AndroidPackageSourceDir).toString();
|
androidPackageDir = node->data(Android::Constants::AndroidPackageSourceDir).toString();
|
||||||
@@ -344,7 +346,7 @@ void CreateAndroidManifestWizard::createAndroidTemplateFiles()
|
|||||||
|
|
||||||
if (androidPackageDir.isEmpty()) {
|
if (androidPackageDir.isEmpty()) {
|
||||||
// and now time for some magic
|
// and now time for some magic
|
||||||
const BuildTargetInfo bti = m_target->buildTarget(m_buildKey);
|
const BuildTargetInfo bti = target->buildTarget(m_buildKey);
|
||||||
const QString value = "$$PWD/" + bti.projectFilePath.toFileInfo().absoluteDir().relativeFilePath(m_directory);
|
const QString value = "$$PWD/" + bti.projectFilePath.toFileInfo().absoluteDir().relativeFilePath(m_directory);
|
||||||
bool result = node->setData(Android::Constants::AndroidPackageSourceDir, value);
|
bool result = node->setData(Android::Constants::AndroidPackageSourceDir, value);
|
||||||
|
|
||||||
@@ -357,9 +359,9 @@ void CreateAndroidManifestWizard::createAndroidTemplateFiles()
|
|||||||
Core::EditorManager::openEditor(m_directory + QLatin1String("/AndroidManifest.xml"));
|
Core::EditorManager::openEditor(m_directory + QLatin1String("/AndroidManifest.xml"));
|
||||||
}
|
}
|
||||||
|
|
||||||
ProjectExplorer::Target *CreateAndroidManifestWizard::target() const
|
BuildSystem *CreateAndroidManifestWizard::buildSystem() const
|
||||||
{
|
{
|
||||||
return m_target;
|
return m_buildSystem;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreateAndroidManifestWizard::accept()
|
void CreateAndroidManifestWizard::accept()
|
||||||
|
@@ -41,7 +41,7 @@ namespace Utils {
|
|||||||
class InfoLabel;
|
class InfoLabel;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace ProjectExplorer { class Target; }
|
namespace ProjectExplorer { class BuildSystem; }
|
||||||
|
|
||||||
namespace Android {
|
namespace Android {
|
||||||
|
|
||||||
@@ -92,7 +92,7 @@ class ANDROID_EXPORT CreateAndroidManifestWizard : public Utils::Wizard
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
CreateAndroidManifestWizard(ProjectExplorer::Target *target);
|
CreateAndroidManifestWizard(ProjectExplorer::BuildSystem *buildSystem);
|
||||||
|
|
||||||
QString buildKey() const;
|
QString buildKey() const;
|
||||||
void setBuildKey(const QString &buildKey);
|
void setBuildKey(const QString &buildKey);
|
||||||
@@ -103,7 +103,7 @@ public:
|
|||||||
void setDirectory(const QString &directory);
|
void setDirectory(const QString &directory);
|
||||||
void setCopyGradle(bool copy);
|
void setCopyGradle(bool copy);
|
||||||
|
|
||||||
ProjectExplorer::Target *target() const;
|
ProjectExplorer::BuildSystem *buildSystem() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum CopyState {
|
enum CopyState {
|
||||||
@@ -115,7 +115,7 @@ private:
|
|||||||
|
|
||||||
void createAndroidManifestFile();
|
void createAndroidManifestFile();
|
||||||
void createAndroidTemplateFiles();
|
void createAndroidTemplateFiles();
|
||||||
ProjectExplorer::Target *m_target;
|
ProjectExplorer::BuildSystem *m_buildSystem;
|
||||||
QString m_buildKey;
|
QString m_buildKey;
|
||||||
QString m_directory;
|
QString m_directory;
|
||||||
CopyState m_copyState;
|
CopyState m_copyState;
|
||||||
|
Reference in New Issue
Block a user