maemoqtversion.cpp 6.86 KB
Newer Older
dt's avatar
dt committed
1
2
3
4
5
6
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
**
7
** Contact: Nokia Corporation (qt-info@nokia.com)
dt's avatar
dt committed
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
**
**
** GNU Lesser General Public License Usage
**
** 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.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
** If you have questions regarding the use of this file, please contact
29
** Nokia at qt-info@nokia.com.
dt's avatar
dt committed
30
31
**
**************************************************************************/
32
#include "maemoqtversion.h"
dt's avatar
dt committed
33

34
#include "maemoconstants.h"
35
36
37
#include "maemoglobal.h"

#include <qt4projectmanager/qt4projectmanagerconstants.h>
38
39
#include <qtsupport/qtsupportconstants.h>

dt's avatar
dt committed
40
41
42
#include <QtCore/QCoreApplication>
#include <QtCore/QFile>
#include <QtCore/QDir>
43
#include <QtCore/QTextStream>
dt's avatar
dt committed
44
45
46

using namespace Qt4ProjectManager;

47
namespace Madde {
48
49
50
namespace Internal {

MaemoQtVersion::MaemoQtVersion() : QtSupport::BaseQtVersion()
dt's avatar
dt committed
51
52
53
54
{

}

55
MaemoQtVersion::MaemoQtVersion(const Utils::FileName &path, bool isAutodetected, const QString &autodetectionSource)
56
    : QtSupport::BaseQtVersion(path, isAutodetected, autodetectionSource),
57
58
      m_osType(MaemoGlobal::osType(path.toString())),
      m_isvalidVersion(MaemoGlobal::isValidMaemoQtVersion(path.toString(), m_osType))
dt's avatar
dt committed
59
60
61
62
63
64
65
66
67
{

}

MaemoQtVersion::~MaemoQtVersion()
{

}

dt's avatar
dt committed
68
69
void MaemoQtVersion::fromMap(const QVariantMap &map)
{
70
    QtSupport::BaseQtVersion::fromMap(map);
71
    QString path = qmakeCommand().toString();
72
73
    m_osType = MaemoGlobal::osType(path);
    m_isvalidVersion = MaemoGlobal::isValidMaemoQtVersion(path, m_osType);
dt's avatar
dt committed
74
75
}

dt's avatar
dt committed
76
77
QString MaemoQtVersion::type() const
{
78
    return QtSupport::Constants::MAEMOQT;
dt's avatar
dt committed
79
80
}

81
82
83
84
85
bool MaemoQtVersion::isValid() const
{
    return BaseQtVersion::isValid() && m_isvalidVersion;
}

dt's avatar
dt committed
86
87
88
89
90
91
92
93
MaemoQtVersion *MaemoQtVersion::clone() const
{
    return new MaemoQtVersion(*this);
}

QString MaemoQtVersion::systemRoot() const
{
    if (m_systemRoot.isNull()) {
94
        QFile file(QDir::cleanPath(MaemoGlobal::targetRoot(qmakeCommand().toString()))
dt's avatar
dt committed
95
96
97
98
99
100
101
102
103
                   + 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")) {
104
                    m_systemRoot = MaemoGlobal::maddeRoot(qmakeCommand().toString())
dt's avatar
dt committed
105
106
107
108
109
110
111
112
                            + QLatin1String("/sysroots/") + list.at(1);
                }
            }
        }
    }
    return m_systemRoot;
}

113
QList<ProjectExplorer::Abi> MaemoQtVersion::detectQtAbis() const
dt's avatar
dt committed
114
115
{
    QList<ProjectExplorer::Abi> result;
dt's avatar
dt committed
116
117
    if (!m_isvalidVersion)
        return result;
118
    if (m_osType == QLatin1String(Maemo5OsType)) {
dt's avatar
dt committed
119
120
121
        result.append(ProjectExplorer::Abi(ProjectExplorer::Abi::ArmArchitecture, ProjectExplorer::Abi::LinuxOS,
                                           ProjectExplorer::Abi::MaemoLinuxFlavor, ProjectExplorer::Abi::ElfFormat,
                                           32));
122
    } else if (m_osType == QLatin1String(HarmattanOsType)) {
dt's avatar
dt committed
123
124
125
126
        result.append(ProjectExplorer::Abi(ProjectExplorer::Abi::ArmArchitecture, ProjectExplorer::Abi::LinuxOS,
                                           ProjectExplorer::Abi::HarmattanLinuxFlavor,
                                           ProjectExplorer::Abi::ElfFormat,
                                           32));
127
    } else if (m_osType == QLatin1String(MeeGoOsType)) {
dt's avatar
dt committed
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
        result.append(ProjectExplorer::Abi(ProjectExplorer::Abi::ArmArchitecture, ProjectExplorer::Abi::LinuxOS,
                                           ProjectExplorer::Abi::MeegoLinuxFlavor,
                                           ProjectExplorer::Abi::ElfFormat, 32));
    }
    return result;
}

bool MaemoQtVersion::supportsTargetId(const QString &id) const
{
    return supportedTargetIds().contains(id);
}

QSet<QString> MaemoQtVersion::supportedTargetIds() const
{
    QSet<QString> result;
dt's avatar
dt committed
143
144
    if (!m_isvalidVersion)
        return result;
145
    if (m_osType == QLatin1String(Maemo5OsType)) {
dt's avatar
dt committed
146
        result.insert(QLatin1String(Constants::MAEMO5_DEVICE_TARGET_ID));
147
    } else if (m_osType == QLatin1String(HarmattanOsType)) {
dt's avatar
dt committed
148
        result.insert(QLatin1String(Constants::HARMATTAN_DEVICE_TARGET_ID));
149
    } else if (m_osType == QLatin1String(MeeGoOsType)) {
dt's avatar
dt committed
150
151
152
153
154
155
156
        result.insert(QLatin1String(Constants::MEEGO_DEVICE_TARGET_ID));
    }
    return result;
}

QString MaemoQtVersion::description() const
{
157
    if (m_osType == QLatin1String(Maemo5OsType))
dt's avatar
dt committed
158
        return QCoreApplication::translate("QtVersion", "Maemo", "Qt Version is meant for Maemo5");
159
    else if (m_osType == QLatin1String(HarmattanOsType))
dt's avatar
dt committed
160
        return QCoreApplication::translate("QtVersion", "Harmattan ", "Qt Version is meant for Harmattan");
161
    else if (m_osType == QLatin1String(MeeGoOsType))
162
        return QCoreApplication::translate("QtVersion", "MeeGo", "Qt Version is meant for MeeGo");
dt's avatar
dt committed
163
164
165
166
167
168
169
170
171
172
    return QString();
}

bool MaemoQtVersion::supportsShadowBuilds() const
{
#ifdef Q_OS_WIN
    return false;
#endif
    return true;
}
dt's avatar
dt committed
173

174
QString MaemoQtVersion::osType() const
dt's avatar
dt committed
175
{
176
    return m_osType;
dt's avatar
dt committed
177
}
178

179
180
void MaemoQtVersion::addToEnvironment(Utils::Environment &env) const
{
181
    const QString maddeRoot = MaemoGlobal::maddeRoot(qmakeCommand().toString());
182
183
184
185
186
187
188
189
190
191
192
193

    // 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")
194
        .arg(MaemoGlobal::targetRoot(qmakeCommand().toString()))));
195
196
}

197
} // namespace Internal
198
} // namespace Madde