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

#include "qt4symbiantargetfactory.h"
#include "qt4projectmanagerconstants.h"
#include "qt4project.h"
36
#include "buildconfigurationinfo.h"
37
38
39
40
41
42
43
44
45
46

#include "qt-s60/s60deployconfiguration.h"
#include "qt-s60/s60devicerunconfiguration.h"
#include "qt-s60/s60emulatorrunconfiguration.h"
#include "qt-s60/s60createpackagestep.h"
#include "qt-s60/s60deploystep.h"
#include "qt-s60/qt4symbiantarget.h"

#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/customexecutablerunconfiguration.h>
47
#include <projectexplorer/toolchainmanager.h>
48
49

using ProjectExplorer::idFromMap;
50
using ProjectExplorer::Task;
51
52
53
54
55
56
57
58
59
60
using namespace Qt4ProjectManager;
using namespace Qt4ProjectManager::Internal;

// -------------------------------------------------------------------------
// Qt4SymbianTargetFactory
// -------------------------------------------------------------------------

Qt4SymbianTargetFactory::Qt4SymbianTargetFactory(QObject *parent) :
    Qt4BaseTargetFactory(parent)
{
61
    connect(QtSupport::QtVersionManager::instance(), SIGNAL(qtVersionsChanged(QList<int>)),
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
            this, SIGNAL(supportedTargetIdsChanged()));
}

Qt4SymbianTargetFactory::~Qt4SymbianTargetFactory()
{
}

bool Qt4SymbianTargetFactory::supportsTargetId(const QString &id) const
{
    return id == QLatin1String(Constants::S60_DEVICE_TARGET_ID)
            || id == QLatin1String(Constants::S60_EMULATOR_TARGET_ID);
}

QStringList Qt4SymbianTargetFactory::supportedTargetIds(ProjectExplorer::Project *parent) const
{
dt's avatar
dt committed
77
    if (parent && !qobject_cast<Qt4Project *>(parent))
78
79
80
        return QStringList();

    QStringList ids;
81
    // The QtVersionManager will just check whether theres
82
    if (QtSupport::QtVersionManager::instance()->supportsTargetId(Constants::S60_DEVICE_TARGET_ID))
83
        ids << QLatin1String(Constants::S60_DEVICE_TARGET_ID);
84
    if (QtSupport::QtVersionManager::instance()->supportsTargetId(Constants::S60_EMULATOR_TARGET_ID))
85
86
87
88
89
90
91
92
93
94
        ids << QLatin1String(Constants::S60_EMULATOR_TARGET_ID);

    return ids;
}

QString Qt4SymbianTargetFactory::displayNameForId(const QString &id) const
{
    return Qt4SymbianTarget::defaultDisplayName(id);
}

95
96
97
98
99
100
101
102
103
QIcon Qt4SymbianTargetFactory::iconForId(const QString &id) const
{
    if (id == QLatin1String(Constants::S60_EMULATOR_TARGET_ID))
        return QIcon(":/projectexplorer/images/SymbianEmulator.png");
    if (id == QLatin1String(Constants::S60_DEVICE_TARGET_ID))
        return QIcon(":/projectexplorer/images/SymbianDevice.png");
    return QIcon();
}

104
105
106
107
108
109
110
111
112
113
114
115
bool Qt4SymbianTargetFactory::canCreate(ProjectExplorer::Project *parent, const QString &id) const
{
    if (!qobject_cast<Qt4Project *>(parent))
        return false;
    return supportsTargetId(id);
}

bool Qt4SymbianTargetFactory::canRestore(ProjectExplorer::Project *parent, const QVariantMap &map) const
{
    return canCreate(parent, idFromMap(map));
}

116
ProjectExplorer::Target *Qt4SymbianTargetFactory::restore(ProjectExplorer::Project *parent, const QVariantMap &map)
117
118
119
120
121
122
123
124
125
126
127
128
129
{
    if (!canRestore(parent, map))
        return 0;

    Qt4Project *qt4project = static_cast<Qt4Project *>(parent);
    Qt4SymbianTarget *target = new Qt4SymbianTarget(qt4project, idFromMap(map));

    if (target->fromMap(map))
        return target;
    delete target;
    return 0;
}

130
QString Qt4SymbianTargetFactory::shadowBuildDirectory(const QString &profilePath, const QString &id, const QString &suffix)
131
{
dt's avatar
dt committed
132
    Q_UNUSED(id);
133
    Q_UNUSED(suffix);
134
    return QFileInfo(profilePath).absolutePath();
135
136
}

137
138
139
140
141
142
143
144
145
146
147
148
149
QList<ProjectExplorer::Task> Qt4SymbianTargetFactory::reportIssues(const QString &proFile)
{
    QList<ProjectExplorer::Task> results;
    // Warn of strange characters in project name and path:
    const QString projectName = proFile.mid(proFile.lastIndexOf(QLatin1Char('/')) + 1);
    QString projectPath = proFile.left(proFile.lastIndexOf(QLatin1Char('/')));
#if defined (Q_OS_WIN)
    if (projectPath.at(1) == QChar(':') && projectPath.at(0).toUpper() >= QChar('A') && projectPath.at(0).toUpper() <= QChar('Z'))
        projectPath = projectPath.mid(2);
#endif
    if (projectPath.contains(QLatin1Char(' '))) {
        results.append(Task(Task::Warning,
                            QCoreApplication::translate("ProjectExplorer::Internal::S60ProjectChecker",
150
                                                        "The Symbian tool chain does not handle spaces "
151
152
153
154
155
156
                                                        "in the project path '%1'.").arg(projectPath),
                            QString(), -1, ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM));
    }
    if (projectName.contains(QRegExp("[^a-zA-Z0-9.-]"))) {
        results.append(Task(Task::Warning,
                            QCoreApplication::translate("ProjectExplorer::Internal::S60ProjectChecker",
157
                                                        "The Symbian tool chain does not handle special "
158
159
160
161
162
163
164
                                                        "characters in the project name '%1' well.")
                            .arg(projectName),
                            QString(), -1, ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM));
    }
    return results;
}

165
QList<BuildConfigurationInfo> Qt4SymbianTargetFactory::availableBuildConfigurations(const QString &id, const QString &proFilePath, const QtSupport::QtVersionNumber &minimumQtVersion)
166
{
167
168
169
170
171
172
    QList<BuildConfigurationInfo> infos = Qt4BaseTargetFactory::availableBuildConfigurations(id, proFilePath, minimumQtVersion);
    if (id != Constants::S60_EMULATOR_TARGET_ID)
        return infos;
    // For emulator filter out all non debug builds
    QList<BuildConfigurationInfo> tmp;
    foreach (const BuildConfigurationInfo &info, infos)
173
        if (info.buildConfig & QtSupport::BaseQtVersion::DebugBuild)
174
175
            tmp << info;
    return tmp;
176
177
}

178
179
180
181
182
bool Qt4SymbianTargetFactory::selectByDefault(const QString &id) const
{
    return id != QLatin1String(Constants::S60_EMULATOR_TARGET_ID);
}

183
QSet<QString> Qt4SymbianTargetFactory::targetFeatures(const QString & /*id*/) const
dt's avatar
dt committed
184
{
185
186
187
188
189
    QSet<QString> features;
    features << Constants::MOBILE_TARGETFEATURE_ID;
    // ideally we should check whether they're really installed
    features << Constants::QTQUICKCOMPONENTS_SYMBIAN_TARGETFEATURE_ID;
    return features;
190
191
}

192
ProjectExplorer::Target *Qt4SymbianTargetFactory::create(ProjectExplorer::Project *parent, const QString &id)
193
194
195
196
{
    if (!canCreate(parent, id))
        return 0;

197
    QList<QtSupport::BaseQtVersion *> knownVersions = QtSupport::QtVersionManager::instance()->versionsForTargetId(id);
198
199
200
    if (knownVersions.isEmpty())
        return 0;

201
202
    QtSupport::BaseQtVersion *qtVersion = knownVersions.first();
    QtSupport::BaseQtVersion::QmakeBuildConfigs config = qtVersion->defaultBuildConfig();
203
204

    QList<BuildConfigurationInfo> infos;
205
    if (id != Constants::S60_EMULATOR_TARGET_ID) {
206
        infos.append(BuildConfigurationInfo(qtVersion, config, QString(), QString()));
207
        infos.append(BuildConfigurationInfo(qtVersion, config ^ QtSupport::BaseQtVersion::DebugBuild, QString(), QString()));
208
    } else {
209
        if (config & QtSupport::BaseQtVersion::DebugBuild)
210
211
            infos.append(BuildConfigurationInfo(qtVersion, config, QString(), QString()));
        else
212
            infos.append(BuildConfigurationInfo(qtVersion, config ^ QtSupport::BaseQtVersion::DebugBuild, QString(), QString()));
213
    }
214
215
216
217

    return create(parent, id, infos);
}

218
ProjectExplorer::Target *Qt4SymbianTargetFactory::create(ProjectExplorer::Project *parent, const QString &id, const QList<BuildConfigurationInfo> &infos)
219
220
221
222
{
    if (!canCreate(parent, id))
        return 0;
    Qt4SymbianTarget *t = new Qt4SymbianTarget(static_cast<Qt4Project *>(parent), id);
223
    foreach (const BuildConfigurationInfo &info, infos)
224
        t->addQt4BuildConfiguration(msgBuildConfigurationName(info), QString(),
225
226
                                    info.version, info.buildConfig,
                                    info.additionalArguments, info.directory);
227

Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
228
    t->addDeployConfiguration(t->createDeployConfiguration(QLatin1String(Qt4ProjectManager::Constants::S60_DEVICE_TARGET_ID)));
229
230
231
232
233
234
235

    t->createApplicationProFiles();

    if (t->runConfigurations().isEmpty())
        t->addRunConfiguration(new ProjectExplorer::CustomExecutableRunConfiguration(t));
    return t;
}
dt's avatar
dt committed
236

237
ProjectExplorer::Target *Qt4SymbianTargetFactory::create(ProjectExplorer::Project *parent, const QString &id, Qt4TargetSetupWidget *widget)
dt's avatar
dt committed
238
239
240
241
242
243
{
    if (!widget->isTargetSelected())
        return 0;
    Qt4DefaultTargetSetupWidget *w = static_cast<Qt4DefaultTargetSetupWidget *>(widget);
    return create(parent, id, w->buildConfigurationInfos());
}