1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
16 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 ** In addition, as a special exception, Nokia gives you certain additional
26 ** rights. These rights are described in the Nokia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
32 **************************************************************************/
34 #include "maemotoolchain.h"
36 #include "maemoconstants.h"
37 #include "maemoglobal.h"
39 #include <QtCore/QDir>
40 #include <QtCore/QStringBuilder>
41 #include <QtCore/QTextStream>
43 using namespace ProjectExplorer;
45 namespace Qt4ProjectManager {
48 MaemoToolChain::MaemoToolChain(const QtVersion *qtVersion)
49 : GccToolChain(MaemoGlobal::targetRoot(qtVersion) % QLatin1String("/bin/gcc"))
50 , m_sysrootInitialized(false)
51 , m_qtVersion(qtVersion)
55 MaemoToolChain::~MaemoToolChain()
59 ProjectExplorer::ToolChainType MaemoToolChain::type() const
61 return ProjectExplorer::ToolChain_GCC_MAEMO;
64 void MaemoToolChain::addToEnvironment(Utils::Environment &env)
66 const QString maddeRoot = MaemoGlobal::maddeRoot(m_qtVersion);
67 env.prependOrSetPath(QDir::toNativeSeparators(QString("%1/bin")
69 env.prependOrSetPath(QDir::toNativeSeparators(QString("%1/bin")
70 .arg(MaemoGlobal::targetRoot(m_qtVersion))));
72 // put this into environment to make pkg-config stuff work
73 env.prependOrSet(QLatin1String("SYSROOT_DIR"), sysroot());
74 env.prependOrSetPath(QDir::toNativeSeparators(QString("%1/madbin")
76 env.prependOrSetPath(QDir::toNativeSeparators(QString("%1/madlib")
78 env.prependOrSet(QLatin1String("PERL5LIB"),
79 QDir::toNativeSeparators(QString("%1/madlib/perl5").arg(maddeRoot)));
82 QString MaemoToolChain::makeCommand() const
84 return QLatin1String("make" EXEC_SUFFIX);
87 bool MaemoToolChain::equals(const ToolChain *other) const
89 const MaemoToolChain *toolChain = static_cast<const MaemoToolChain*> (other);
90 return other->type() == type() && toolChain->m_qtVersion == m_qtVersion;
93 QString MaemoToolChain::sysroot() const
95 if (!m_sysrootInitialized)
100 void MaemoToolChain::setSysroot() const
102 QFile file(QDir::cleanPath(MaemoGlobal::targetRoot(m_qtVersion))
103 + QLatin1String("/information"));
104 if (file.exists() && file.open(QIODevice::ReadOnly | QIODevice::Text)) {
105 QTextStream stream(&file);
106 while (!stream.atEnd()) {
107 const QString &line = stream.readLine().trimmed();
108 const QStringList &list = line.split(QLatin1Char(' '));
109 if (list.count() <= 1)
111 if (list.at(0) == QLatin1String("sysroot")) {
112 m_sysrootRoot = MaemoGlobal::maddeRoot(m_qtVersion)
113 + QLatin1String("/sysroots/") + list.at(1);
118 m_sysrootInitialized = true;
121 } // namespace Internal
122 } // namespace Qt4ProjectManager