Maemo: Remove MaemoToolChain::sysroot() method.

Functionality is already in MaemoQtVersion.
Also move some environment stuff there.

Change-Id: Ibbe91aed5611b1fa60afd3954767596af74b8c80
Reviewed-on: http://codereview.qt.nokia.com/387
Reviewed-by: Tobias Hunger <tobias.hunger@nokia.com>
This commit is contained in:
Christian Kandeler
2011-06-08 15:35:43 +02:00
parent 7939c270bd
commit 033837dca6
5 changed files with 25 additions and 48 deletions

View File

@@ -35,7 +35,7 @@
#include "maemodeployables.h" #include "maemodeployables.h"
#include "maemoglobal.h" #include "maemoglobal.h"
#include "maemopackagecreationstep.h" #include "maemopackagecreationstep.h"
#include "maemotoolchain.h" #include "maemoqtversion.h"
#include "qt4maemodeployconfiguration.h" #include "qt4maemodeployconfiguration.h"
#include <qt4projectmanager/qt4buildconfiguration.h> #include <qt4projectmanager/qt4buildconfiguration.h>
@@ -298,24 +298,23 @@ void MaemoCopyToSysrootStep::run(QFutureInterface<bool> &fi)
return; return;
} }
const MaemoToolChain * const tc const MaemoQtVersion * const qtVersion = dynamic_cast<MaemoQtVersion *>(bc->qtVersion());
= dynamic_cast<MaemoToolChain *>(bc->toolChain()); if (!qtVersion) {
if (!tc) { addOutput(tr("Can't copy to sysroot without valid Qt version."),
addOutput(tr("Can't copy to sysroot without toolchain."),
ErrorMessageOutput); ErrorMessageOutput);
fi.reportResult(false); fi.reportResult(false);
return; return;
} }
emit addOutput(tr("Copying files to sysroot ..."), MessageOutput); emit addOutput(tr("Copying files to sysroot ..."), MessageOutput);
QDir sysrootDir(tc->sysroot()); QDir sysrootDir(qtVersion->systemRoot());
const QSharedPointer<MaemoDeployables> deployables const QSharedPointer<MaemoDeployables> deployables
= qobject_cast<Qt4MaemoDeployConfiguration *>(deployConfiguration())->deployables(); = qobject_cast<Qt4MaemoDeployConfiguration *>(deployConfiguration())->deployables();
const QChar sep = QLatin1Char('/'); const QChar sep = QLatin1Char('/');
for (int i = 0; i < deployables->deployableCount(); ++i) { for (int i = 0; i < deployables->deployableCount(); ++i) {
const MaemoDeployable &deployable = deployables->deployableAt(i); const MaemoDeployable &deployable = deployables->deployableAt(i);
const QFileInfo localFileInfo(deployable.localFilePath); const QFileInfo localFileInfo(deployable.localFilePath);
const QString targetFilePath = tc->sysroot() + sep const QString targetFilePath = qtVersion->systemRoot() + sep
+ deployable.remoteDir + sep + localFileInfo.fileName(); + deployable.remoteDir + sep + localFileInfo.fileName();
sysrootDir.mkpath(deployable.remoteDir.mid(1)); sysrootDir.mkpath(deployable.remoteDir.mid(1));
QString errorMsg; QString errorMsg;

View File

@@ -170,5 +170,23 @@ QString MaemoQtVersion::osType() const
return m_osType; return m_osType;
} }
void MaemoQtVersion::addToEnvironment(Utils::Environment &env) const
{
const QString maddeRoot = MaemoGlobal::maddeRoot(qmakeCommand());
// Needed to make pkg-config stuff work.
env.prependOrSet(QLatin1String("SYSROOT_DIR"), QDir::toNativeSeparators(systemRoot()));
env.prependOrSetPath(QDir::toNativeSeparators(QString("%1/madbin")
.arg(maddeRoot)));
env.prependOrSetPath(QDir::toNativeSeparators(QString("%1/madlib")
.arg(maddeRoot)));
env.prependOrSet(QLatin1String("PERL5LIB"),
QDir::toNativeSeparators(QString("%1/madlib/perl5").arg(maddeRoot)));
env.prependOrSetPath(QDir::toNativeSeparators(QString("%1/bin").arg(maddeRoot)));
env.prependOrSetPath(QDir::toNativeSeparators(QString("%1/bin")
.arg(MaemoGlobal::targetRoot(qmakeCommand()))));
}
} // namespace Internal } // namespace Internal
} // namespace RemoteLinux } // namespace RemoteLinux

View File

@@ -52,6 +52,7 @@ public:
virtual QString systemRoot() const; virtual QString systemRoot() const;
virtual QList<ProjectExplorer::Abi> qtAbis() const; virtual QList<ProjectExplorer::Abi> qtAbis() const;
void addToEnvironment(Utils::Environment &env) const;
virtual bool supportsTargetId(const QString &id) const; virtual bool supportsTargetId(const QString &id) const;
virtual QSet<QString> supportedTargetIds() const; virtual QSet<QString> supportedTargetIds() const;

View File

@@ -100,24 +100,6 @@ bool MaemoToolChain::canClone() const
void MaemoToolChain::addToEnvironment(Utils::Environment &env) const void MaemoToolChain::addToEnvironment(Utils::Environment &env) const
{ {
QtSupport::BaseQtVersion *v = QtSupport::QtVersionManager::instance()->version(m_qtVersionId);
if (!v)
return;
const QString maddeRoot = MaemoGlobal::maddeRoot(v->qmakeCommand());
// put this into environment to make pkg-config stuff work
env.prependOrSet(QLatin1String("SYSROOT_DIR"), QDir::toNativeSeparators(sysroot()));
env.prependOrSetPath(QDir::toNativeSeparators(QString("%1/madbin")
.arg(maddeRoot)));
env.prependOrSetPath(QDir::toNativeSeparators(QString("%1/madlib")
.arg(maddeRoot)));
env.prependOrSet(QLatin1String("PERL5LIB"),
QDir::toNativeSeparators(QString("%1/madlib/perl5").arg(maddeRoot)));
env.prependOrSetPath(QDir::toNativeSeparators(QString("%1/bin").arg(maddeRoot)));
env.prependOrSetPath(QDir::toNativeSeparators(QString("%1/bin")
.arg(MaemoGlobal::targetRoot(v->qmakeCommand()))));
const QString manglePathsKey = QLatin1String("GCCWRAPPER_PATHMANGLE"); const QString manglePathsKey = QLatin1String("GCCWRAPPER_PATHMANGLE");
if (!env.hasKey(manglePathsKey)) { if (!env.hasKey(manglePathsKey)) {
const QStringList pathsToMangle = QStringList() << QLatin1String("/lib") const QStringList pathsToMangle = QStringList() << QLatin1String("/lib")
@@ -128,27 +110,6 @@ void MaemoToolChain::addToEnvironment(Utils::Environment &env) const
} }
} }
QString MaemoToolChain::sysroot() const
{
QtSupport::BaseQtVersion *v = QtSupport::QtVersionManager::instance()->version(m_qtVersionId);
if (!v)
return QString();
if (m_sysroot.isEmpty()) {
QFile file(QDir::cleanPath(MaemoGlobal::targetRoot(v->qmakeCommand())) + QLatin1String("/information"));
if (file.exists() && file.open(QIODevice::ReadOnly | QIODevice::Text)) {
QTextStream stream(&file);
while (!stream.atEnd()) {
const QString &line = stream.readLine().trimmed();
const QStringList &list = line.split(QLatin1Char(' '));
if (list.count() > 1 && list.at(0) == QLatin1String("sysroot"))
m_sysroot = MaemoGlobal::maddeRoot(v->qmakeCommand()) + QLatin1String("/sysroots/") + list.at(1);
}
}
}
return m_sysroot;
}
bool MaemoToolChain::operator ==(const ProjectExplorer::ToolChain &tc) const bool MaemoToolChain::operator ==(const ProjectExplorer::ToolChain &tc) const
{ {
if (!ToolChain::operator ==(tc)) if (!ToolChain::operator ==(tc))

View File

@@ -57,13 +57,11 @@ public:
bool canClone() const; bool canClone() const;
void addToEnvironment(Utils::Environment &env) const; void addToEnvironment(Utils::Environment &env) const;
QString sysroot() const;
bool operator ==(const ProjectExplorer::ToolChain &) const; bool operator ==(const ProjectExplorer::ToolChain &) const;
ProjectExplorer::ToolChainConfigWidget *configurationWidget(); ProjectExplorer::ToolChainConfigWidget *configurationWidget();
QVariantMap toMap() const; QVariantMap toMap() const;
bool fromMap(const QVariantMap &data); bool fromMap(const QVariantMap &data);