1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
|
/****************************************************************************
**
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** 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.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include "iosrunconfiguration.h"
#include "iosmanager.h"
#include "iosdeploystep.h"
#include <projectexplorer/kitinformation.h>
#include <projectexplorer/target.h>
#include <projectexplorer/deployconfiguration.h>
#include <projectexplorer/buildstep.h>
#include <projectexplorer/buildsteplist.h>
#include <qmakeprojectmanager/qmakebuildconfiguration.h>
#include <qmakeprojectmanager/qmakeproject.h>
#include <qmakeprojectmanager/qmakenodes.h>
#include <qtsupport/qtoutputformatter.h>
#include <qtsupport/qtkitinformation.h>
#include "ui_iosrunconfiguration.h"
#include <QList>
#include <utils/qtcprocess.h>
#include <utils/qtcassert.h>
using namespace ProjectExplorer;
using namespace QmakeProjectManager;
namespace Ios {
namespace Internal {
const QLatin1String runConfigurationKey("Ios.run_arguments");
class IosRunConfigurationWidget : public RunConfigWidget
{
Q_OBJECT
public:
IosRunConfigurationWidget(IosRunConfiguration *runConfiguration);
~IosRunConfigurationWidget();
QString argListToString(const QStringList &args) const;
QStringList stringToArgList(const QString &args) const;
QString displayName() const;
private slots:
void argumentsLineEditTextEdited();
void updateValues();
private:
Ui::IosRunConfiguration *m_ui;
IosRunConfiguration *m_runConfiguration;
};
IosRunConfiguration::IosRunConfiguration(Target *parent, Core::Id id, const QString &path)
: RunConfiguration(parent, id)
, m_profilePath(path)
{
init();
}
IosRunConfiguration::IosRunConfiguration(Target *parent, IosRunConfiguration *source)
: RunConfiguration(parent, source)
, m_profilePath(source->m_profilePath)
, m_arguments(source->m_arguments)
{
init();
}
void IosRunConfiguration::init()
{
setDefaultDisplayName(defaultDisplayName());
}
QWidget *IosRunConfiguration::createConfigurationWidget()
{
return new IosRunConfigurationWidget(this);
}
Utils::OutputFormatter *IosRunConfiguration::createOutputFormatter() const
{
return new QtSupport::QtOutputFormatter(target()->project());
}
QStringList IosRunConfiguration::commandLineArguments()
{
return m_arguments;
}
QString IosRunConfiguration::defaultDisplayName()
{
ProjectExplorer::IDevice::ConstPtr dev =
ProjectExplorer::DeviceKitInformation::device(target()->kit());
const QString devName = dev.isNull() ? IosDevice::name() : dev->displayName();
return tr("Run on %1").arg(devName);
}
IosDeployStep *IosRunConfiguration::deployStep() const
{
IosDeployStep * step = 0;
DeployConfiguration *config = target()->activeDeployConfiguration();
ProjectExplorer::BuildStepList *bsl = config->stepList();
if (bsl) {
const QList<ProjectExplorer::BuildStep *> &buildSteps = bsl->steps();
for (int i = buildSteps.count() - 1; i >= 0; --i) {
step = qobject_cast<IosDeployStep *>(buildSteps.at(i));
if (step)
break;
}
}
Q_ASSERT_X(step, Q_FUNC_INFO, "Impossible: iOS build configuration without deploy step.");
return step;
}
QString IosRunConfiguration::profilePath() const
{
return m_profilePath;
}
QString IosRunConfiguration::appName() const
{
QmakeProject *pro = qobject_cast<QmakeProject *>(target()->project());
if (pro) {
const QmakeProFileNode *node = pro->rootQmakeProjectNode()->findProFileFor(profilePath());
if (node) {
TargetInformation ti = node->targetInformation();
if (ti.valid)
return ti.target;
}
}
qDebug() << "IosRunConfiguration::appName failed";
return QString();
}
Utils::FileName IosRunConfiguration::bundleDir() const
{
Utils::FileName res;
Core::Id devType = ProjectExplorer::DeviceTypeKitInformation::deviceTypeId(target()->kit());
bool isDevice = (devType == Constants::IOS_DEVICE_TYPE);
if (!isDevice && devType != Constants::IOS_SIMULATOR_TYPE) {
qDebug() << "unexpected device type in bundleDirForTarget: " << devType.toString();
return res;
}
QmakeBuildConfiguration *bc =
qobject_cast<QmakeBuildConfiguration *>(target()->activeBuildConfiguration());
if (bc) {
res = bc->buildDirectory();
switch (bc->buildType()) {
case BuildConfiguration::Debug :
case BuildConfiguration::Unknown :
if (isDevice)
res.appendPath(QLatin1String("Debug-iphoneos"));
else
res.appendPath(QLatin1String("Debug-iphonesimulator"));
break;
case BuildConfiguration::Release :
if (isDevice)
res.appendPath(QLatin1String("Release-iphoneos"));
else
res.appendPath(QLatin1String("/Release-iphonesimulator"));
break;
default:
qDebug() << "IosBuildStep had an unknown buildType "
<< target()->activeBuildConfiguration()->buildType();
}
}
res.appendPath(appName() + QLatin1String(".app"));
return res;
}
Utils::FileName IosRunConfiguration::exePath() const
{
return bundleDir().appendPath(appName());
}
bool IosRunConfiguration::fromMap(const QVariantMap &map)
{
m_arguments = map.value(runConfigurationKey).toStringList();
return RunConfiguration::fromMap(map);
}
QVariantMap IosRunConfiguration::toMap() const
{
QVariantMap res = RunConfiguration::toMap();
res[runConfigurationKey] = m_arguments;
return res;
}
IosRunConfigurationWidget::IosRunConfigurationWidget(IosRunConfiguration *runConfiguration) :
m_ui(new Ui::IosRunConfiguration), m_runConfiguration(runConfiguration)
{
m_ui->setupUi(this);
updateValues();
connect(m_ui->argumentsLineEdit, SIGNAL(editingFinished()),
SLOT(argumentsLineEditTextEdited()));
connect(runConfiguration->target(), SIGNAL(buildDirectoryChanged()),
SLOT(updateValues()));
}
IosRunConfigurationWidget::~IosRunConfigurationWidget()
{
delete m_ui;
}
QString IosRunConfigurationWidget::argListToString(const QStringList &args) const
{
return Utils::QtcProcess::joinArgs(args);
}
QStringList IosRunConfigurationWidget::stringToArgList(const QString &args) const
{
Utils::QtcProcess::SplitError err;
QStringList res = Utils::QtcProcess::splitArgs(args, false, &err);
switch (err) {
case Utils::QtcProcess::SplitOk:
break;
case Utils::QtcProcess::BadQuoting:
if (args.at(args.size()-1) == QLatin1Char('\\')) {
res = Utils::QtcProcess::splitArgs(args + QLatin1Char('\\'), false, &err);
if (err != Utils::QtcProcess::SplitOk)
res = Utils::QtcProcess::splitArgs(args + QLatin1Char('\\') + QLatin1Char('\''),
false, &err);
if (err != Utils::QtcProcess::SplitOk)
res = Utils::QtcProcess::splitArgs(args + QLatin1Char('\\') + QLatin1Char('\"'),
false, &err);
}
if (err != Utils::QtcProcess::SplitOk)
res = Utils::QtcProcess::splitArgs(args + QLatin1Char('\''), false, &err);
if (err != Utils::QtcProcess::SplitOk)
res = Utils::QtcProcess::splitArgs(args + QLatin1Char('\"'), false, &err);
break;
case Utils::QtcProcess::FoundMeta:
qDebug() << "IosRunConfigurationWidget FoundMeta (should not happen)";
break;
}
return res;
}
QString IosRunConfigurationWidget::displayName() const
{
return tr("iOS run settings");
}
void IosRunConfigurationWidget::argumentsLineEditTextEdited()
{
QString argsString = m_ui->argumentsLineEdit->text();
QStringList args = stringToArgList(argsString);
m_runConfiguration->m_arguments = args;
m_ui->argumentsLineEdit->setText(argListToString(args));
}
void IosRunConfigurationWidget::updateValues()
{
QStringList args = m_runConfiguration->m_arguments;
QString argsString = argListToString(args);
m_ui->argumentsLineEdit->setText(argsString);
m_ui->executableLineEdit->setText(m_runConfiguration->exePath().toUserOutput());
}
} // namespace Internal
} // namespace Ios
#include "iosrunconfiguration.moc"
|