2009-10-16 17:33:12 +02:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2010-03-05 11:25:49 +01:00
|
|
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
2009-10-16 17:33:12 +02:00
|
|
|
**
|
|
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
|
|
|
|
**
|
|
|
|
|
** Commercial Usage
|
|
|
|
|
**
|
|
|
|
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
|
|
|
|
** accordance with the Qt Commercial License Agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and Nokia.
|
|
|
|
|
**
|
|
|
|
|
** 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.
|
|
|
|
|
**
|
|
|
|
|
** If you are unsure which license is appropriate for your use, please
|
|
|
|
|
** contact the sales department at http://qt.nokia.com/contact.
|
|
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "maemotoolchain.h"
|
2010-05-20 15:47:42 +02:00
|
|
|
#include "maemoconstants.h"
|
2009-10-16 17:33:12 +02:00
|
|
|
|
|
|
|
|
#include <QtCore/QDir>
|
2010-03-10 14:29:50 +01:00
|
|
|
#include <QtCore/QStringBuilder>
|
2010-05-20 15:47:42 +02:00
|
|
|
#include <QtCore/QTextStream>
|
2009-10-16 17:33:12 +02:00
|
|
|
|
|
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
using namespace Qt4ProjectManager::Internal;
|
|
|
|
|
|
2010-03-10 12:18:13 +01:00
|
|
|
MaemoToolChain::MaemoToolChain(const QString &targetRoot)
|
|
|
|
|
: GccToolChain(targetRoot % QLatin1String("/bin/gcc"))
|
2009-10-16 17:33:12 +02:00
|
|
|
, m_maddeInitialized(false)
|
|
|
|
|
, m_sysrootInitialized(false)
|
2010-03-10 12:18:13 +01:00
|
|
|
, m_targetRoot(targetRoot)
|
2009-10-16 17:33:12 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MaemoToolChain::~MaemoToolChain()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ToolChain::ToolChainType MaemoToolChain::type() const
|
|
|
|
|
{
|
|
|
|
|
return ToolChain::GCC_MAEMO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MaemoToolChain::addToEnvironment(ProjectExplorer::Environment &env)
|
|
|
|
|
{
|
2009-11-30 12:04:02 +01:00
|
|
|
env.prependOrSetPath(QDir::toNativeSeparators(QString("%1/bin")
|
|
|
|
|
.arg(maddeRoot())));
|
|
|
|
|
env.prependOrSetPath(QDir::toNativeSeparators(QString("%1/bin")
|
|
|
|
|
.arg(targetRoot())));
|
2010-06-02 10:38:18 +02:00
|
|
|
|
|
|
|
|
// put this into environment to make pkg-config stuff work
|
2010-06-01 17:38:15 +02:00
|
|
|
env.prependOrSet(QLatin1String("SYSROOT_DIR"), sysrootRoot());
|
2009-12-16 15:46:18 +01:00
|
|
|
env.prependOrSetPath(QDir::toNativeSeparators(QString("%1/madbin")
|
|
|
|
|
.arg(maddeRoot())));
|
2010-06-01 17:38:15 +02:00
|
|
|
env.prependOrSetPath(QDir::toNativeSeparators(QString("%1/madlib")
|
|
|
|
|
.arg(maddeRoot())));
|
|
|
|
|
env.prependOrSet(QLatin1String("PERL5LIB"),
|
|
|
|
|
QDir::toNativeSeparators(QString("%1/madlib/perl5").arg(maddeRoot())));
|
2009-10-16 17:33:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString MaemoToolChain::makeCommand() const
|
|
|
|
|
{
|
|
|
|
|
return QLatin1String("make" EXEC_SUFFIX);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool MaemoToolChain::equals(ToolChain *other) const
|
|
|
|
|
{
|
|
|
|
|
MaemoToolChain *toolChain = static_cast<MaemoToolChain*> (other);
|
2010-03-10 15:15:54 +01:00
|
|
|
return other->type() == type()
|
2009-10-16 17:33:12 +02:00
|
|
|
&& toolChain->sysrootRoot() == sysrootRoot()
|
2010-03-10 15:15:54 +01:00
|
|
|
&& toolChain->targetRoot() == targetRoot();
|
2009-10-16 17:33:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString MaemoToolChain::maddeRoot() const
|
|
|
|
|
{
|
|
|
|
|
if (!m_maddeInitialized)
|
2010-02-08 11:45:50 +01:00
|
|
|
setMaddeRoot();
|
2009-10-16 17:33:12 +02:00
|
|
|
return m_maddeRoot;
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-20 09:14:40 +02:00
|
|
|
QString MaemoToolChain::madAdminCommand() const
|
|
|
|
|
{
|
|
|
|
|
return maddeRoot() + QLatin1String("/bin/mad-admin");
|
|
|
|
|
}
|
|
|
|
|
|
2009-10-16 17:33:12 +02:00
|
|
|
QString MaemoToolChain::targetRoot() const
|
|
|
|
|
{
|
|
|
|
|
return m_targetRoot;
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-20 09:14:40 +02:00
|
|
|
QString MaemoToolChain::targetName() const
|
|
|
|
|
{
|
|
|
|
|
return QDir(targetRoot()).dirName();
|
|
|
|
|
}
|
|
|
|
|
|
2009-10-16 17:33:12 +02:00
|
|
|
QString MaemoToolChain::sysrootRoot() const
|
|
|
|
|
{
|
|
|
|
|
if (!m_sysrootInitialized)
|
2010-03-10 15:15:54 +01:00
|
|
|
setSysroot();
|
2009-10-16 17:33:12 +02:00
|
|
|
return m_sysrootRoot;
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-23 15:37:17 +02:00
|
|
|
MaemoToolChain::MaemoVersion MaemoToolChain::version() const
|
|
|
|
|
{
|
|
|
|
|
const QString &name = targetName();
|
|
|
|
|
if (name.startsWith(QLatin1String("fremantle")))
|
|
|
|
|
return Maemo5;
|
|
|
|
|
if (name.startsWith(QLatin1String("harmattan")))
|
|
|
|
|
return Maemo6;
|
|
|
|
|
qWarning("Unknown Maemo version!");
|
|
|
|
|
return static_cast<MaemoVersion>(-1);
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-08 11:45:50 +01:00
|
|
|
void MaemoToolChain::setMaddeRoot() const
|
2009-10-16 17:33:12 +02:00
|
|
|
{
|
|
|
|
|
QDir dir(targetRoot());
|
|
|
|
|
dir.cdUp(); dir.cdUp();
|
|
|
|
|
|
|
|
|
|
m_maddeInitialized = true;
|
|
|
|
|
m_maddeRoot = dir.absolutePath();
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-10 15:15:54 +01:00
|
|
|
void MaemoToolChain::setSysroot() const
|
2009-10-16 17:33:12 +02:00
|
|
|
{
|
|
|
|
|
QFile file(QDir::cleanPath(targetRoot()) + 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)
|
|
|
|
|
continue;
|
|
|
|
|
if (list.at(0) == QLatin1String("sysroot")) {
|
|
|
|
|
m_sysrootRoot = maddeRoot() + QLatin1String("/sysroots/")
|
|
|
|
|
+ list.at(1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_sysrootInitialized = true;
|
|
|
|
|
}
|