forked from qt-creator/qt-creator
Maemo: Correctly deploy subdirs projects.
Task-number: QTCREATORBUG-1614, QTCREATORBUG-1810 Reviewed-by: kh1
This commit is contained in:
@@ -12,3 +12,10 @@ CONFIG += ordered
|
||||
|
||||
SUBDIRS = src share
|
||||
WITH_TESTS:SUBDIRS += tests
|
||||
|
||||
|
||||
target.path += \
|
||||
/usr/local/bin
|
||||
|
||||
INSTALLS += \
|
||||
target
|
||||
@@ -29,51 +29,33 @@
|
||||
|
||||
#include "maemodeployablelistmodel.h"
|
||||
|
||||
#include "maemopackagecreationstep.h"
|
||||
#include "maemotoolchain.h"
|
||||
#include "profilewrapper.h"
|
||||
|
||||
#include <qt4projectmanager/qt4buildconfiguration.h>
|
||||
#include <qt4projectmanager/qt4project.h>
|
||||
#include <qt4projectmanager/qt4target.h>
|
||||
#include <qt4projectmanager/qt4nodes.h>
|
||||
|
||||
#include <QtCore/QCryptographicHash>
|
||||
#include <QtCore/QFile>
|
||||
#include <QtCore/QFileInfo>
|
||||
|
||||
namespace Qt4ProjectManager {
|
||||
namespace Internal {
|
||||
|
||||
MaemoDeployableListModel::MaemoDeployableListModel(MaemoPackageCreationStep *packageStep)
|
||||
: QAbstractTableModel(packageStep),
|
||||
m_packageStep(packageStep),
|
||||
m_modified(false),
|
||||
m_initialized(false)
|
||||
MaemoDeployableListModel::MaemoDeployableListModel(const Qt4ProFileNode *proFileNode,
|
||||
QObject *parent)
|
||||
: QAbstractTableModel(parent), m_proFileNode(proFileNode), m_modified(false)
|
||||
{
|
||||
buildModel();
|
||||
}
|
||||
|
||||
MaemoDeployableListModel::~MaemoDeployableListModel() {}
|
||||
|
||||
bool MaemoDeployableListModel::buildModel() const
|
||||
bool MaemoDeployableListModel::buildModel()
|
||||
{
|
||||
if (m_initialized)
|
||||
return true;
|
||||
|
||||
m_deployables.clear();
|
||||
|
||||
// TODO: The pro file path comes from the outside.
|
||||
if (!m_proFileWrapper) {
|
||||
const Qt4ProFileNode * const proFileNode = m_packageStep
|
||||
->qt4BuildConfiguration()->qt4Target()->qt4Project()
|
||||
->rootProjectNode();
|
||||
m_proFileWrapper.reset(new ProFileWrapper(proFileNode->path()));
|
||||
}
|
||||
m_proFileWrapper.reset(new ProFileWrapper(m_proFileNode->path()));
|
||||
const ProFileWrapper::InstallsList &installs = m_proFileWrapper->installs();
|
||||
if (installs.targetPath.isEmpty()) {
|
||||
const Qt4ProFileNode * const proFileNode
|
||||
= m_packageStep->qt4BuildConfiguration()->qt4Target()
|
||||
->qt4Project()->rootProjectNode();
|
||||
const QString remoteDir = proFileNode->projectType() == LibraryTemplate
|
||||
const QString remoteDir = m_proFileNode->projectType() == LibraryTemplate
|
||||
? QLatin1String("/usr/local/lib")
|
||||
: QLatin1String("/usr/local/bin");
|
||||
m_deployables.prepend(MaemoDeployable(localExecutableFilePath(),
|
||||
@@ -93,7 +75,6 @@ bool MaemoDeployableListModel::buildModel() const
|
||||
}
|
||||
}
|
||||
|
||||
m_initialized = true;
|
||||
m_modified = true; // ???
|
||||
return true;
|
||||
}
|
||||
@@ -143,7 +124,6 @@ bool MaemoDeployableListModel::removeDeployableAt(int row, QString *error)
|
||||
|
||||
int MaemoDeployableListModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
buildModel();
|
||||
return parent.isValid() ? 0 : m_deployables.count();
|
||||
}
|
||||
|
||||
@@ -203,26 +183,41 @@ QVariant MaemoDeployableListModel::headerData(int section,
|
||||
|
||||
QString MaemoDeployableListModel::localExecutableFilePath() const
|
||||
{
|
||||
// TODO: This information belongs to this class.
|
||||
return m_packageStep->localExecutableFilePath();
|
||||
const TargetInformation &ti = m_proFileNode->targetInformation();
|
||||
if (!ti.valid)
|
||||
return QString();
|
||||
|
||||
const bool isLib = m_proFileNode->projectType() == LibraryTemplate;
|
||||
bool isStatic;
|
||||
QString fileName;
|
||||
if (isLib) {
|
||||
fileName += QLatin1String("lib");
|
||||
const QStringList &config
|
||||
= m_proFileWrapper->varValues(QLatin1String("CONFIG"));
|
||||
isStatic = config.contains(QLatin1String("static"))
|
||||
|| config.contains(QLatin1String("staticlib"))
|
||||
|| config.contains(QLatin1String("plugin"));
|
||||
}
|
||||
fileName += ti.target;
|
||||
if (isLib)
|
||||
fileName += QLatin1String(isStatic ? ".a" : ".so");
|
||||
return ti.buildDir + '/' + fileName;
|
||||
}
|
||||
|
||||
QString MaemoDeployableListModel::remoteExecutableFilePath() const
|
||||
{
|
||||
return buildModel() ? deployableAt(0).remoteDir + '/'
|
||||
+ m_packageStep->executableFileName() : QString();
|
||||
return deployableAt(0).remoteDir + '/'
|
||||
+ QFileInfo(localExecutableFilePath()).fileName();
|
||||
}
|
||||
|
||||
QString MaemoDeployableListModel::projectName() const
|
||||
{
|
||||
// TODO: This must return our own sub project name.
|
||||
return m_packageStep->qt4BuildConfiguration()->qt4Target()->qt4Project()
|
||||
->rootProjectNode()->displayName();
|
||||
return m_proFileNode->displayName();
|
||||
}
|
||||
|
||||
QString MaemoDeployableListModel::projectDir() const
|
||||
{
|
||||
return m_proFileWrapper->projectDir();
|
||||
return m_proFileNode->path();
|
||||
}
|
||||
|
||||
} // namespace Qt4ProjectManager
|
||||
|
||||
@@ -40,14 +40,15 @@
|
||||
|
||||
namespace Qt4ProjectManager {
|
||||
namespace Internal {
|
||||
class MaemoPackageCreationStep;
|
||||
class ProFileWrapper;
|
||||
class Qt4ProFileNode;
|
||||
|
||||
class MaemoDeployableListModel : public QAbstractTableModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MaemoDeployableListModel(MaemoPackageCreationStep *packageStep);
|
||||
MaemoDeployableListModel(const Qt4ProFileNode *proFileNode,
|
||||
QObject *parent);
|
||||
~MaemoDeployableListModel();
|
||||
|
||||
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
||||
@@ -72,13 +73,12 @@ private:
|
||||
virtual bool setData(const QModelIndex &index, const QVariant &value,
|
||||
int role = Qt::EditRole);
|
||||
|
||||
bool buildModel() const;
|
||||
bool buildModel();
|
||||
|
||||
const MaemoPackageCreationStep * const m_packageStep;
|
||||
mutable QList<MaemoDeployable> m_deployables;
|
||||
const Qt4ProFileNode * const m_proFileNode;
|
||||
QList<MaemoDeployable> m_deployables;
|
||||
mutable bool m_modified;
|
||||
mutable bool m_initialized;
|
||||
mutable QScopedPointer<ProFileWrapper> m_proFileWrapper;
|
||||
QScopedPointer<ProFileWrapper> m_proFileWrapper;
|
||||
};
|
||||
|
||||
} // namespace Qt4ProjectManager
|
||||
|
||||
@@ -81,7 +81,6 @@ MaemoDeployableListWidget::~MaemoDeployableListWidget()
|
||||
|
||||
void MaemoDeployableListWidget::addFile()
|
||||
{
|
||||
// TODO: Make all this stuff subproject-specific.
|
||||
const QString title = tr("Choose a local file");
|
||||
const QString localFile = QFileDialog::getOpenFileName(this, title, m_model->projectDir()); // TODO: Support directories.
|
||||
if (localFile.isEmpty())
|
||||
|
||||
@@ -42,16 +42,55 @@
|
||||
#include "maemodeployables.h"
|
||||
|
||||
#include "maemodeployablelistmodel.h"
|
||||
#include "maemopackagecreationstep.h"
|
||||
|
||||
#include <qt4projectmanager/qt4buildconfiguration.h>
|
||||
#include <qt4projectmanager/qt4nodes.h>
|
||||
#include <qt4projectmanager/qt4project.h>
|
||||
#include <qt4projectmanager/qt4target.h>
|
||||
|
||||
#include <QtCore/QTimer>
|
||||
|
||||
namespace Qt4ProjectManager {
|
||||
namespace Internal {
|
||||
|
||||
MaemoDeployables::MaemoDeployables(MaemoPackageCreationStep *packagingStep)
|
||||
: m_packagingStep(packagingStep)
|
||||
{
|
||||
// TODO: Enumerate sub projects and create one list model for each app or lib template.
|
||||
// Their constructurs will then take this object as parent and the
|
||||
// project node
|
||||
m_listModels << new MaemoDeployableListModel(packagingStep);
|
||||
QTimer::singleShot(0, this, SLOT(createModels()));
|
||||
}
|
||||
|
||||
void MaemoDeployables::createModels()
|
||||
{
|
||||
const Qt4ProFileNode *rootNode = m_packagingStep->qt4BuildConfiguration()
|
||||
->qt4Target()->qt4Project()->rootProjectNode();
|
||||
createModels(rootNode);
|
||||
emit modelsCreated();
|
||||
}
|
||||
|
||||
void MaemoDeployables::createModels(const Qt4ProFileNode *proFileNode)
|
||||
{
|
||||
const Qt4ProjectType type = proFileNode->projectType() ;
|
||||
switch (type) {
|
||||
case ApplicationTemplate:
|
||||
case LibraryTemplate:
|
||||
case ScriptTemplate:
|
||||
m_listModels << new MaemoDeployableListModel(proFileNode, this);
|
||||
break;
|
||||
case SubDirsTemplate: {
|
||||
const QList<ProjectExplorer::ProjectNode *> &subProjects
|
||||
= proFileNode->subProjectNodes();
|
||||
foreach (const ProjectExplorer::ProjectNode *subProject, subProjects) {
|
||||
const Qt4ProFileNode * const qt4SubProject
|
||||
= qobject_cast<const Qt4ProFileNode *>(subProject);
|
||||
if (qt4SubProject && !qt4SubProject->path()
|
||||
.endsWith(QLatin1String(".pri")))
|
||||
createModels(qt4SubProject);
|
||||
}
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void MaemoDeployables::setUnmodified()
|
||||
|
||||
@@ -51,6 +51,7 @@ namespace Qt4ProjectManager {
|
||||
namespace Internal {
|
||||
class MaemoDeployableListModel;
|
||||
class MaemoPackageCreationStep;
|
||||
class Qt4ProFileNode;
|
||||
|
||||
class MaemoDeployables : public QObject
|
||||
{
|
||||
@@ -65,8 +66,15 @@ public:
|
||||
int modelCount() const { return m_listModels.count(); }
|
||||
MaemoDeployableListModel *modelAt(int i) const { return m_listModels.at(i); }
|
||||
|
||||
signals:
|
||||
void modelsCreated();
|
||||
|
||||
private:
|
||||
Q_SLOT void createModels();
|
||||
void createModels(const Qt4ProFileNode *proFileNode);
|
||||
|
||||
QList<MaemoDeployableListModel *> m_listModels;
|
||||
MaemoPackageCreationStep * const m_packagingStep;
|
||||
};
|
||||
|
||||
} // namespace Qt4ProjectManager
|
||||
|
||||
@@ -179,7 +179,7 @@ bool MaemoPackageCreationStep::createPackage()
|
||||
|
||||
if (!QFileInfo(buildDir + QLatin1String("/debian")).exists()) {
|
||||
const QString command = QLatin1String("dh_make -s -n -p ")
|
||||
% executableFileName().toLower() % QLatin1Char('_') % versionString();
|
||||
% projectName() % QLatin1Char('_') % versionString();
|
||||
if (!runCommand(command))
|
||||
return false;
|
||||
|
||||
@@ -297,35 +297,15 @@ const Qt4BuildConfiguration *MaemoPackageCreationStep::qt4BuildConfiguration() c
|
||||
return static_cast<Qt4BuildConfiguration *>(buildConfiguration());
|
||||
}
|
||||
|
||||
QString MaemoPackageCreationStep::localExecutableFilePath() const
|
||||
{
|
||||
const TargetInformation &ti = qt4BuildConfiguration()->qt4Target()
|
||||
->qt4Project()->rootProjectNode()->targetInformation();
|
||||
if (!ti.valid)
|
||||
return QString();
|
||||
return QDir::toNativeSeparators(QDir::cleanPath(ti.workingDir
|
||||
+ QLatin1Char('/') + executableFileName()));
|
||||
}
|
||||
|
||||
QString MaemoPackageCreationStep::buildDirectory() const
|
||||
{
|
||||
const TargetInformation &ti = qt4BuildConfiguration()->qt4Target()
|
||||
->qt4Project()->rootProjectNode()->targetInformation();
|
||||
return ti.valid ? ti.buildDir : QString();
|
||||
return qt4BuildConfiguration()->buildDirectory();
|
||||
}
|
||||
|
||||
QString MaemoPackageCreationStep::executableFileName() const
|
||||
QString MaemoPackageCreationStep::projectName() const
|
||||
{
|
||||
const Qt4Project * const project
|
||||
= qt4BuildConfiguration()->qt4Target()->qt4Project();
|
||||
const TargetInformation &ti
|
||||
= project->rootProjectNode()->targetInformation();
|
||||
if (!ti.valid)
|
||||
return QString();
|
||||
|
||||
return project->rootProjectNode()->projectType() == LibraryTemplate
|
||||
? QLatin1String("lib") + ti.target + QLatin1String(".so")
|
||||
: ti.target;
|
||||
return qt4BuildConfiguration()->qt4Target()->qt4Project()
|
||||
->rootProjectNode()->displayName().toLower();
|
||||
}
|
||||
|
||||
const MaemoToolChain *MaemoPackageCreationStep::maemoToolChain() const
|
||||
@@ -362,7 +342,7 @@ bool MaemoPackageCreationStep::packagingNeeded() const
|
||||
|
||||
QString MaemoPackageCreationStep::packageFilePath() const
|
||||
{
|
||||
return buildDirectory() % '/' % executableFileName().toLower()
|
||||
return buildDirectory() % '/' % projectName()
|
||||
% QLatin1Char('_') % versionString() % QLatin1String("_armel.deb");
|
||||
}
|
||||
|
||||
|
||||
@@ -69,8 +69,6 @@ public:
|
||||
~MaemoPackageCreationStep();
|
||||
|
||||
QString packageFilePath() const;
|
||||
QString localExecutableFilePath() const;
|
||||
QString executableFileName() const;
|
||||
MaemoDeployables *deployables() const { return m_deployables; }
|
||||
const Qt4BuildConfiguration *qt4BuildConfiguration() const;
|
||||
|
||||
@@ -104,6 +102,7 @@ private:
|
||||
void raiseError(const QString &shortMsg,
|
||||
const QString &detailedMsg = QString());
|
||||
QString buildDirectory() const;
|
||||
QString projectName() const;
|
||||
|
||||
static const QLatin1String CreatePackageId;
|
||||
|
||||
|
||||
@@ -69,12 +69,13 @@ MaemoPackageCreationWidget::MaemoPackageCreationWidget(MaemoPackageCreationStep
|
||||
m_ui->major->setValue(list.value(0, QLatin1String("0")).toInt());
|
||||
m_ui->minor->setValue(list.value(1, QLatin1String("0")).toInt());
|
||||
m_ui->patch->setValue(list.value(2, QLatin1String("0")).toInt());
|
||||
versionInfoChanged(); // workaround for missing minor and patch update notifications
|
||||
for (int i = 0; i < step->deployables()->modelCount(); ++i) {
|
||||
MaemoDeployableListModel * const model
|
||||
= step->deployables()->modelAt(i);
|
||||
m_ui->tabWidget->addTab(new MaemoDeployableListWidget(this, model),
|
||||
model->projectName());
|
||||
versionInfoChanged();
|
||||
|
||||
if (step->deployables()->modelCount() > 0) {
|
||||
handleModelsCreated();
|
||||
} else {
|
||||
connect(m_step->deployables(), SIGNAL(modelsCreated()), this,
|
||||
SLOT(handleModelsCreated()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,5 +105,15 @@ void MaemoPackageCreationWidget::versionInfoChanged()
|
||||
emit updateSummary();
|
||||
}
|
||||
|
||||
void MaemoPackageCreationWidget::handleModelsCreated()
|
||||
{
|
||||
for (int i = 0; i < m_step->deployables()->modelCount(); ++i) {
|
||||
MaemoDeployableListModel * const model
|
||||
= m_step->deployables()->modelAt(i);
|
||||
m_ui->tabWidget->addTab(new MaemoDeployableListWidget(this, model),
|
||||
model->projectName());
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Qt4ProjectManager
|
||||
|
||||
@@ -66,6 +66,7 @@ public:
|
||||
private slots:
|
||||
void handleSkipButtonToggled(bool checked);
|
||||
void versionInfoChanged();
|
||||
void handleModelsCreated();
|
||||
|
||||
private:
|
||||
MaemoPackageCreationStep * const m_step;
|
||||
|
||||
@@ -238,10 +238,9 @@ QString AbstractMaemoRunControl::packageFilePath() const
|
||||
|
||||
QString AbstractMaemoRunControl::executableFilePathOnTarget() const
|
||||
{
|
||||
// TODO: The local executable is known directly by us (from RunConfiguration::target(),
|
||||
// so we must not rely on the packaging step for this information (which will
|
||||
// no longer provide it, anyway)/
|
||||
return m_runConfig->packageStep()->deployables()->remoteExecutableFilePath(m_runConfig->packageStep()->localExecutableFilePath());
|
||||
const MaemoDeployables * const deployables
|
||||
= m_runConfig->packageStep()->deployables();
|
||||
return deployables->remoteExecutableFilePath(m_runConfig->executable());
|
||||
}
|
||||
|
||||
bool AbstractMaemoRunControl::isCleaning() const
|
||||
|
||||
@@ -136,6 +136,9 @@ QStringList ProFileWrapper::varValues(const QString &var) const
|
||||
|
||||
bool ProFileWrapper::addVarValue(const QString &var, const QString &value)
|
||||
{
|
||||
if (varValues(var).contains(value))
|
||||
return true;
|
||||
|
||||
if (!readProFileContents())
|
||||
return false;
|
||||
ProWriter::addVarValues(m_proFile, &m_proFileContents, m_proDir,
|
||||
|
||||
@@ -53,7 +53,6 @@ public:
|
||||
const QString &newValue);
|
||||
|
||||
QString absFilePath(const QString &relFilePath) const;
|
||||
QString projectDir() const { return m_proDir.path(); }
|
||||
|
||||
private:
|
||||
enum ParseType { ParseFromFile, ParseFromLines };
|
||||
|
||||
Reference in New Issue
Block a user