~bzoltan/kubuntu-packaging/decouple_cmake_plugin

« back to all changes in this revision

Viewing changes to src/plugins/madde/maemoqtversion.cpp

  • Committer: Timo Jyrinki
  • Date: 2013-11-15 12:25:23 UTC
  • mfrom: (1.1.28)
  • Revision ID: timo.jyrinki@canonical.com-20131115122523-i2kyamsu4gs2mu1m
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/****************************************************************************
2
 
**
3
 
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
4
 
** Contact: http://www.qt-project.org/legal
5
 
**
6
 
** This file is part of Qt Creator.
7
 
**
8
 
** Commercial License Usage
9
 
** Licensees holding valid commercial Qt licenses may use this file in
10
 
** accordance with the commercial license agreement provided with the
11
 
** Software or, alternatively, in accordance with the terms contained in
12
 
** a written agreement between you and Digia.  For licensing terms and
13
 
** conditions see http://qt.digia.com/licensing.  For further information
14
 
** use the contact form at http://qt.digia.com/contact-us.
15
 
**
16
 
** GNU Lesser General Public License Usage
17
 
** Alternatively, this file may be used under the terms of the GNU Lesser
18
 
** General Public License version 2.1 as published by the Free Software
19
 
** Foundation and appearing in the file LICENSE.LGPL included in the
20
 
** packaging of this file.  Please review the following information to
21
 
** ensure the GNU Lesser General Public License version 2.1 requirements
22
 
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23
 
**
24
 
** In addition, as a special exception, Digia gives you certain additional
25
 
** rights.  These rights are described in the Digia Qt LGPL Exception
26
 
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
27
 
**
28
 
****************************************************************************/
29
 
#include "maemoqtversion.h"
30
 
 
31
 
#include "maemoconstants.h"
32
 
#include "maemoglobal.h"
33
 
 
34
 
#include <projectexplorer/kitinformation.h>
35
 
#include <qt4projectmanager/qt4projectmanagerconstants.h>
36
 
#include <qtsupport/qtsupportconstants.h>
37
 
#include <coreplugin/featureprovider.h>
38
 
#include <utils/hostosinfo.h>
39
 
 
40
 
#include <QCoreApplication>
41
 
#include <QFile>
42
 
#include <QDir>
43
 
#include <QTextStream>
44
 
 
45
 
using namespace Qt4ProjectManager;
46
 
 
47
 
namespace Madde {
48
 
namespace Internal {
49
 
 
50
 
MaemoQtVersion::MaemoQtVersion()
51
 
    : QtSupport::BaseQtVersion(),
52
 
      m_isvalidVersion(false),
53
 
      m_initialized(false)
54
 
{
55
 
 
56
 
}
57
 
 
58
 
MaemoQtVersion::MaemoQtVersion(const Utils::FileName &path, bool isAutodetected, const QString &autodetectionSource)
59
 
    : QtSupport::BaseQtVersion(path, isAutodetected, autodetectionSource),
60
 
      m_deviceType(MaemoGlobal::deviceType(path.toString())),
61
 
      m_isvalidVersion(false),
62
 
      m_initialized(false)
63
 
{
64
 
    setDisplayName(defaultDisplayName(qtVersionString(), path, false));
65
 
}
66
 
 
67
 
MaemoQtVersion::~MaemoQtVersion()
68
 
{
69
 
 
70
 
}
71
 
 
72
 
void MaemoQtVersion::fromMap(const QVariantMap &map)
73
 
{
74
 
    QtSupport::BaseQtVersion::fromMap(map);
75
 
    QString path = qmakeCommand().toString();
76
 
    m_deviceType = MaemoGlobal::deviceType(path);
77
 
}
78
 
 
79
 
QString MaemoQtVersion::type() const
80
 
{
81
 
    return QLatin1String(QtSupport::Constants::MAEMOQT);
82
 
}
83
 
 
84
 
bool MaemoQtVersion::isValid() const
85
 
{
86
 
    if (!BaseQtVersion::isValid())
87
 
        return false;
88
 
    if (!m_initialized) {
89
 
        m_isvalidVersion = MaemoGlobal::isValidMaemoQtVersion(qmakeCommand().toString(), m_deviceType);
90
 
        m_initialized = true;
91
 
    }
92
 
    return m_isvalidVersion;
93
 
}
94
 
 
95
 
MaemoQtVersion *MaemoQtVersion::clone() const
96
 
{
97
 
    return new MaemoQtVersion(*this);
98
 
}
99
 
 
100
 
QList<ProjectExplorer::Abi> MaemoQtVersion::detectQtAbis() const
101
 
{
102
 
    QList<ProjectExplorer::Abi> result;
103
 
    if (!isValid())
104
 
        return result;
105
 
    if (m_deviceType == Maemo5OsType) {
106
 
        result.append(ProjectExplorer::Abi(ProjectExplorer::Abi::ArmArchitecture, ProjectExplorer::Abi::LinuxOS,
107
 
                                           ProjectExplorer::Abi::MaemoLinuxFlavor, ProjectExplorer::Abi::ElfFormat,
108
 
                                           32));
109
 
    } else if (m_deviceType == HarmattanOsType) {
110
 
        result.append(ProjectExplorer::Abi(ProjectExplorer::Abi::ArmArchitecture, ProjectExplorer::Abi::LinuxOS,
111
 
                                           ProjectExplorer::Abi::HarmattanLinuxFlavor,
112
 
                                           ProjectExplorer::Abi::ElfFormat,
113
 
                                           32));
114
 
    }
115
 
    return result;
116
 
}
117
 
 
118
 
QString MaemoQtVersion::description() const
119
 
{
120
 
    if (m_deviceType == Maemo5OsType)
121
 
        return QCoreApplication::translate("QtVersion", "Maemo", "Qt Version is meant for Maemo5");
122
 
    if (m_deviceType == HarmattanOsType)
123
 
        return QCoreApplication::translate("QtVersion", "Harmattan ", "Qt Version is meant for Harmattan");
124
 
    return QString();
125
 
}
126
 
 
127
 
bool MaemoQtVersion::supportsShadowBuilds() const
128
 
{
129
 
    return !Utils::HostOsInfo::isWindowsHost();
130
 
}
131
 
 
132
 
Core::Id MaemoQtVersion::deviceType() const
133
 
{
134
 
    return m_deviceType;
135
 
}
136
 
 
137
 
Core::FeatureSet MaemoQtVersion::availableFeatures() const
138
 
{
139
 
    Core::FeatureSet features = QtSupport::BaseQtVersion::availableFeatures();
140
 
    if (qtVersion() >= QtSupport::QtVersionNumber(4, 7, 4)) //no reliable test for components, yet.
141
 
        features |= Core::FeatureSet(QtSupport::Constants::FEATURE_QTQUICK_COMPONENTS_MEEGO);
142
 
    features |= Core::FeatureSet(QtSupport::Constants::FEATURE_MOBILE);
143
 
 
144
 
    if (deviceType() != Maemo5OsType) //Only Maemo5 has proper support for Widgets
145
 
        features.remove(Core::Feature(QtSupport::Constants::FEATURE_QWIDGETS));
146
 
 
147
 
    return features;
148
 
}
149
 
 
150
 
QString MaemoQtVersion::platformName() const
151
 
{
152
 
    if (m_deviceType == Maemo5OsType)
153
 
        return QLatin1String(QtSupport::Constants::MAEMO_FREMANTLE_PLATFORM);
154
 
    return QLatin1String(QtSupport::Constants::MEEGO_HARMATTAN_PLATFORM);
155
 
}
156
 
 
157
 
QString MaemoQtVersion::platformDisplayName() const
158
 
{
159
 
    if (m_deviceType == Maemo5OsType)
160
 
        return QLatin1String(QtSupport::Constants::MAEMO_FREMANTLE_PLATFORM_TR);
161
 
    return QLatin1String(QtSupport::Constants::MEEGO_HARMATTAN_PLATFORM_TR);
162
 
}
163
 
 
164
 
void MaemoQtVersion::addToEnvironment(const ProjectExplorer::Kit *k, Utils::Environment &env) const
165
 
{
166
 
    Q_UNUSED(k);
167
 
    const QString maddeRoot = MaemoGlobal::maddeRoot(qmakeCommand().toString());
168
 
 
169
 
    // Needed to make pkg-config stuff work.
170
 
    Utils::FileName sysRoot = ProjectExplorer::SysRootKitInformation::sysRoot(k);
171
 
    env.prependOrSet(QLatin1String("SYSROOT_DIR"), sysRoot.toUserOutput());
172
 
    env.prependOrSetPath(QDir::toNativeSeparators(QString::fromLatin1("%1/madbin")
173
 
        .arg(maddeRoot)));
174
 
    env.prependOrSetPath(QDir::toNativeSeparators(QString::fromLatin1("%1/madlib")
175
 
        .arg(maddeRoot)));
176
 
    env.prependOrSet(QLatin1String("PERL5LIB"),
177
 
        QDir::toNativeSeparators(QString::fromLatin1("%1/madlib/perl5").arg(maddeRoot)));
178
 
 
179
 
    env.prependOrSetPath(QDir::toNativeSeparators(QString::fromLatin1("%1/bin").arg(maddeRoot)));
180
 
    env.prependOrSetPath(QDir::toNativeSeparators(QString::fromLatin1("%1/bin")
181
 
        .arg(MaemoGlobal::targetRoot(qmakeCommand().toString()))));
182
 
 
183
 
    // Actually this is tool chain related, but since we no longer have a tool chain...
184
 
    const QString manglePathsKey = QLatin1String("GCCWRAPPER_PATHMANGLE");
185
 
    if (!env.hasKey(manglePathsKey)) {
186
 
        const QStringList pathsToMangle = QStringList() << QLatin1String("/lib")
187
 
            << QLatin1String("/opt") << QLatin1String("/usr");
188
 
        env.set(manglePathsKey, pathsToMangle.join(QLatin1String(":")));
189
 
    }
190
 
}
191
 
 
192
 
} // namespace Internal
193
 
} // namespace Madde