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
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
|
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** 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 The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#include "qmakestep.h"
#include "ui_qmakestep.h"
#include "qmakemakestep.h"
#include "qmakebuildconfiguration.h"
#include "qmakekitinformation.h"
#include "qmakenodes.h"
#include "qmakeparser.h"
#include "qmakeproject.h"
#include "qmakeprojectmanagerconstants.h"
#include <projectexplorer/buildmanager.h>
#include <projectexplorer/buildsteplist.h>
#include <projectexplorer/gnumakeparser.h>
#include <projectexplorer/processparameters.h>
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/target.h>
#include <projectexplorer/toolchain.h>
#include <coreplugin/icore.h>
#include <coreplugin/icontext.h>
#include <coreplugin/variablechooser.h>
#include <qtsupport/qtkitinformation.h>
#include <qtsupport/qtversionmanager.h>
#include <qtsupport/qtsupportconstants.h>
#include <utils/algorithm.h>
#include <utils/hostosinfo.h>
#include <utils/qtcprocess.h>
#include <utils/utilsicons.h>
#include <QDir>
#include <QMessageBox>
using namespace QmakeProjectManager;
using namespace QmakeProjectManager::Internal;
using namespace QtSupport;
using namespace ProjectExplorer;
using namespace Utils;
namespace {
const char QMAKE_BS_ID[] = "QtProjectManager.QMakeBuildStep";
const char QMAKE_ARGUMENTS_KEY[] = "QtProjectManager.QMakeBuildStep.QMakeArguments";
const char QMAKE_FORCED_KEY[] = "QtProjectManager.QMakeBuildStep.QMakeForced";
const char QMAKE_USE_QTQUICKCOMPILER[] = "QtProjectManager.QMakeBuildStep.UseQtQuickCompiler";
const char QMAKE_SEPARATEDEBUGINFO_KEY[] = "QtProjectManager.QMakeBuildStep.SeparateDebugInfo";
const char QMAKE_QMLDEBUGLIBAUTO_KEY[] = "QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto";
const char QMAKE_QMLDEBUGLIB_KEY[] = "QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary";
}
QMakeStep::QMakeStep(BuildStepList *bsl) : AbstractProcessStep(bsl, QMAKE_BS_ID)
{
//: QMakeStep default display name
setDefaultDisplayName(tr("qmake"));
}
QmakeBuildConfiguration *QMakeStep::qmakeBuildConfiguration() const
{
return static_cast<QmakeBuildConfiguration *>(buildConfiguration());
}
///
/// Returns all arguments
/// That is: possbile subpath
/// spec
/// config arguemnts
/// moreArguments
/// user arguments
QString QMakeStep::allArguments(const BaseQtVersion *v, ArgumentFlags flags) const
{
QTC_ASSERT(v, return QString());
QmakeBuildConfiguration *bc = qmakeBuildConfiguration();
QStringList arguments;
if (bc->subNodeBuild())
arguments << bc->subNodeBuild()->filePath().toUserOutput();
else if (flags & ArgumentFlag::OmitProjectPath)
arguments << project()->projectFilePath().fileName();
else
arguments << project()->projectFilePath().toUserOutput();
if (v->qtVersion() < QtVersionNumber(5, 0, 0))
arguments << "-r";
bool userProvidedMkspec = false;
for (QtcProcess::ConstArgIterator ait(m_userArgs); ait.next(); ) {
if (ait.value() == "-spec") {
if (ait.next()) {
userProvidedMkspec = true;
break;
}
}
}
FileName specArg = mkspec();
if (!userProvidedMkspec && !specArg.isEmpty())
arguments << "-spec" << specArg.toUserOutput();
// Find out what flags we pass on to qmake
arguments << bc->configCommandLineArguments();
arguments << deducedArguments().toArguments();
QString args = QtcProcess::joinArgs(arguments);
// User arguments
QtcProcess::addArgs(&args, m_userArgs);
foreach (QString arg, m_extraArgs)
QtcProcess::addArgs(&args, arg);
return (flags & ArgumentFlag::Expand) ? bc->macroExpander()->expand(args) : args;
}
QMakeStepConfig QMakeStep::deducedArguments() const
{
ProjectExplorer::Kit *kit = target()->kit();
QMakeStepConfig config;
ProjectExplorer::ToolChain *tc
= ProjectExplorer::ToolChainKitInformation::toolChain(kit, ProjectExplorer::Constants::CXX_LANGUAGE_ID);
ProjectExplorer::Abi targetAbi;
if (tc) {
targetAbi = tc->targetAbi();
if (HostOsInfo::isWindowsHost()
&& tc->typeId() == ProjectExplorer::Constants::CLANG_TOOLCHAIN_TYPEID) {
config.sysRoot = ProjectExplorer::SysRootKitInformation::sysRoot(kit).toString();
config.targetTriple = tc->originalTargetTriple();
}
}
BaseQtVersion *version = QtKitInformation::qtVersion(target()->kit());
config.archConfig = QMakeStepConfig::targetArchFor(targetAbi, version);
config.osType = QMakeStepConfig::osTypeFor(targetAbi, version);
if (linkQmlDebuggingLibrary() && version && version->qtVersion().majorVersion >= 5)
config.linkQmlDebuggingQQ2 = true;
if (useQtQuickCompiler() && version)
config.useQtQuickCompiler = true;
if (separateDebugInfo())
config.separateDebugInfo = true;
return config;
}
bool QMakeStep::init()
{
QmakeBuildConfiguration *qmakeBc = qmakeBuildConfiguration();
const BaseQtVersion *qtVersion = QtKitInformation::qtVersion(target()->kit());
if (!qtVersion) {
emit addOutput(tr("No Qt version configured."), BuildStep::OutputFormat::ErrorMessage);
return false;
}
QString workingDirectory;
if (qmakeBc->subNodeBuild())
workingDirectory = qmakeBc->subNodeBuild()->buildDir();
else
workingDirectory = qmakeBc->buildDirectory().toString();
m_qmakeExecutable = qtVersion->qmakeCommand().toString();
m_qmakeArguments = allArguments(qtVersion);
m_runMakeQmake = (qtVersion->qtVersion() >= QtVersionNumber(5, 0 ,0));
QString makefile = workingDirectory + '/';
if (qmakeBc->subNodeBuild()) {
QmakeProFileNode *pro = qmakeBc->subNodeBuild();
if (pro && !pro->makefile().isEmpty())
makefile.append(pro->makefile());
else
makefile.append("Makefile");
} else if (!qmakeBc->makefile().isEmpty()) {
makefile.append(qmakeBc->makefile());
} else {
makefile.append("Makefile");
}
if (m_runMakeQmake) {
m_makeExecutable = makeCommand();
if (m_makeExecutable.isEmpty()) {
emit addOutput(tr("Could not determine which \"make\" command to run. "
"Check the \"make\" step in the build configuration."),
BuildStep::OutputFormat::ErrorMessage);
return false;
}
m_makeArguments = makeArguments(makefile);
} else {
m_makeExecutable.clear();
m_makeArguments.clear();
}
// Check whether we need to run qmake
bool makefileOutDated = (qmakeBc->compareToImportFrom(makefile) != QmakeBuildConfiguration::MakefileMatches);
if (m_forced || makefileOutDated)
m_needToRunQMake = true;
m_forced = false;
ProcessParameters *pp = processParameters();
pp->setMacroExpander(qmakeBc->macroExpander());
pp->setWorkingDirectory(workingDirectory);
pp->setEnvironment(qmakeBc->environment());
setOutputParser(new QMakeParser);
QmakeProFileNode *node = static_cast<QmakeProject *>(qmakeBc->target()->project())->rootProjectNode();
if (qmakeBc->subNodeBuild())
node = qmakeBc->subNodeBuild();
QTC_ASSERT(node, return false);
QString proFile = node->filePath().toString();
QList<ProjectExplorer::Task> tasks = qtVersion->reportIssues(proFile, workingDirectory);
Utils::sort(tasks);
if (!tasks.isEmpty()) {
bool canContinue = true;
foreach (const ProjectExplorer::Task &t, tasks) {
emit addTask(t);
if (t.type == Task::Error)
canContinue = false;
}
if (!canContinue) {
emitFaultyConfigurationMessage();
return false;
}
}
m_scriptTemplate = node->projectType() == ProjectType::ScriptTemplate;
return AbstractProcessStep::init();
}
void QMakeStep::doRun()
{
if (m_scriptTemplate) {
emit finished(true);
return;
}
if (!m_needToRunQMake) {
emit addOutput(tr("Configuration unchanged, skipping qmake step."), BuildStep::OutputFormat::NormalMessage);
emit finished(true);
return;
}
m_needToRunQMake = false;
m_nextState = State::RUN_QMAKE;
runNextCommand();
}
void QMakeStep::setForced(bool b)
{
m_forced = b;
}
ProjectExplorer::BuildStepConfigWidget *QMakeStep::createConfigWidget()
{
return new QMakeStepConfigWidget(this);
}
void QMakeStep::processStartupFailed()
{
m_needToRunQMake = true;
AbstractProcessStep::processStartupFailed();
}
bool QMakeStep::processSucceeded(int exitCode, QProcess::ExitStatus status)
{
bool result = AbstractProcessStep::processSucceeded(exitCode, status);
if (!result)
m_needToRunQMake = true;
auto *project = static_cast<QmakeProject *>(qmakeBuildConfiguration()->target()->project());
project->emitBuildDirectoryInitialized();
return result;
}
void QMakeStep::doCancel()
{
AbstractProcessStep::doCancel();
}
void QMakeStep::finish(bool success)
{
m_wasSuccess = success;
runNextCommand();
}
void QMakeStep::startOneCommand(const QString &command, const QString &args)
{
ProcessParameters *pp = processParameters();
pp->setCommand(command);
pp->setArguments(args);
pp->resolveAll();
AbstractProcessStep::doRun();
}
void QMakeStep::runNextCommand()
{
if (isCanceled())
m_wasSuccess = false;
if (!m_wasSuccess)
m_nextState = State::POST_PROCESS;
emit progress(static_cast<int>(m_nextState) * 100 / static_cast<int>(State::POST_PROCESS),
QString());
switch (m_nextState) {
case State::IDLE:
return;
case State::RUN_QMAKE:
setOutputParser(new QMakeParser);
m_nextState = (m_runMakeQmake ? State::RUN_MAKE_QMAKE_ALL : State::POST_PROCESS);
startOneCommand(m_qmakeExecutable, m_qmakeArguments);
return;
case State::RUN_MAKE_QMAKE_ALL:
{
auto *parser = new GnuMakeParser;
parser->setWorkingDirectory(processParameters()->workingDirectory());
setOutputParser(parser);
m_nextState = State::POST_PROCESS;
startOneCommand(m_makeExecutable, m_makeArguments);
}
return;
case State::POST_PROCESS:
m_nextState = State::IDLE;
emit finished(m_wasSuccess);
return;
}
}
void QMakeStep::setUserArguments(const QString &arguments)
{
if (m_userArgs == arguments)
return;
m_userArgs = arguments;
emit userArgumentsChanged();
qmakeBuildConfiguration()->emitQMakeBuildConfigurationChanged();
qmakeBuildConfiguration()->emitProFileEvaluateNeeded();
}
QStringList QMakeStep::extraArguments() const
{
return m_extraArgs;
}
void QMakeStep::setExtraArguments(const QStringList &args)
{
if (m_extraArgs != args) {
m_extraArgs = args;
emit extraArgumentsChanged();
qmakeBuildConfiguration()->emitQMakeBuildConfigurationChanged();
qmakeBuildConfiguration()->emitProFileEvaluateNeeded();
}
}
bool QMakeStep::linkQmlDebuggingLibrary() const
{
return m_linkQmlDebuggingLibrary;
}
void QMakeStep::setLinkQmlDebuggingLibrary(bool enable)
{
if (enable == m_linkQmlDebuggingLibrary)
return;
m_linkQmlDebuggingLibrary = enable;
emit linkQmlDebuggingLibraryChanged();
qmakeBuildConfiguration()->emitQMakeBuildConfigurationChanged();
qmakeBuildConfiguration()->emitProFileEvaluateNeeded();
}
bool QMakeStep::useQtQuickCompiler() const
{
return m_useQtQuickCompiler;
}
void QMakeStep::setUseQtQuickCompiler(bool enable)
{
if (enable == m_useQtQuickCompiler)
return;
m_useQtQuickCompiler = enable;
emit useQtQuickCompilerChanged();
qmakeBuildConfiguration()->emitQMakeBuildConfigurationChanged();
qmakeBuildConfiguration()->emitProFileEvaluateNeeded();
}
bool QMakeStep::separateDebugInfo() const
{
return m_separateDebugInfo;
}
void QMakeStep::setSeparateDebugInfo(bool enable)
{
if (enable == m_separateDebugInfo)
return;
m_separateDebugInfo = enable;
emit separateDebugInfoChanged();
qmakeBuildConfiguration()->emitQMakeBuildConfigurationChanged();
qmakeBuildConfiguration()->emitProFileEvaluateNeeded();
}
QString QMakeStep::makeCommand() const
{
auto *ms = qobject_cast<BuildStepList *>(parent())->firstOfType<MakeStep>();
return ms ? ms->effectiveMakeCommand() : QString();
}
QString QMakeStep::makeArguments(const QString &makefile) const
{
QString args;
if (!makefile.isEmpty()) {
Utils::QtcProcess::addArg(&args, "-f");
Utils::QtcProcess::addArg(&args, makefile);
}
Utils::QtcProcess::addArg(&args, "qmake_all");
return args;
}
QString QMakeStep::effectiveQMakeCall() const
{
BaseQtVersion *qtVersion = QtKitInformation::qtVersion(target()->kit());
QString qmake = qtVersion ? qtVersion->qmakeCommand().toUserOutput() : QString();
if (qmake.isEmpty())
qmake = tr("<no Qt version>");
QString make = makeCommand();
if (make.isEmpty())
make = tr("<no Make step found>");
QString result = qmake;
if (qtVersion) {
QmakeBuildConfiguration *qmakeBc = qmakeBuildConfiguration();
const QString makefile = qmakeBc ? qmakeBc->makefile() : QString();
result += ' ' + allArguments(qtVersion, ArgumentFlag::Expand);
if (qtVersion->qtVersion() >= QtVersionNumber(5, 0, 0))
result.append(QString::fromLatin1(" && %1 %2").arg(make).arg(makeArguments(makefile)));
}
return result;
}
QStringList QMakeStep::parserArguments()
{
QStringList result;
BaseQtVersion *qt = QtKitInformation::qtVersion(target()->kit());
QTC_ASSERT(qt, return QStringList());
for (QtcProcess::ConstArgIterator ait(allArguments(qt, ArgumentFlag::Expand)); ait.next(); ) {
if (ait.isSimple())
result << ait.value();
}
return result;
}
QString QMakeStep::userArguments()
{
return m_userArgs;
}
FileName QMakeStep::mkspec() const
{
QString additionalArguments = m_userArgs;
QtcProcess::addArgs(&additionalArguments, m_extraArgs);
for (QtcProcess::ArgIterator ait(&additionalArguments); ait.next(); ) {
if (ait.value() == "-spec") {
if (ait.next())
return FileName::fromUserInput(ait.value());
}
}
return QmakeProjectManager::QmakeKitInformation::effectiveMkspec(target()->kit());
}
QVariantMap QMakeStep::toMap() const
{
QVariantMap map(AbstractProcessStep::toMap());
map.insert(QMAKE_ARGUMENTS_KEY, m_userArgs);
map.insert(QMAKE_QMLDEBUGLIB_KEY, m_linkQmlDebuggingLibrary);
map.insert(QMAKE_FORCED_KEY, m_forced);
map.insert(QMAKE_USE_QTQUICKCOMPILER, m_useQtQuickCompiler);
map.insert(QMAKE_SEPARATEDEBUGINFO_KEY, m_separateDebugInfo);
return map;
}
bool QMakeStep::fromMap(const QVariantMap &map)
{
m_userArgs = map.value(QMAKE_ARGUMENTS_KEY).toString();
m_forced = map.value(QMAKE_FORCED_KEY, false).toBool();
m_useQtQuickCompiler = map.value(QMAKE_USE_QTQUICKCOMPILER, false).toBool();
// QMAKE_QMLDEBUGLIBAUTO_KEY was used in versions 2.3 to 3.5 (both included) to automatically
// change the qml_debug CONFIG flag based no the qmake build configuration.
if (map.value(QMAKE_QMLDEBUGLIBAUTO_KEY, false).toBool()) {
m_linkQmlDebuggingLibrary =
project()->projectLanguages().contains(
ProjectExplorer::Constants::QMLJS_LANGUAGE_ID) &&
(qmakeBuildConfiguration()->qmakeBuildConfiguration() & BaseQtVersion::DebugBuild);
} else {
m_linkQmlDebuggingLibrary = map.value(QMAKE_QMLDEBUGLIB_KEY, false).toBool();
}
m_separateDebugInfo = map.value(QMAKE_SEPARATEDEBUGINFO_KEY, false).toBool();
return BuildStep::fromMap(map);
}
////
// QMakeStepConfigWidget
////
QMakeStepConfigWidget::QMakeStepConfigWidget(QMakeStep *step)
: BuildStepConfigWidget(step), m_ui(new Internal::Ui::QMakeStep), m_step(step)
{
m_ui->setupUi(this);
m_ui->qmakeAdditonalArgumentsLineEdit->setText(m_step->userArguments());
m_ui->qmlDebuggingLibraryCheckBox->setChecked(m_step->linkQmlDebuggingLibrary());
m_ui->qtQuickCompilerCheckBox->setChecked(m_step->useQtQuickCompiler());
m_ui->separateDebugInfoCheckBox->setChecked(m_step->separateDebugInfo());
const QPixmap warning = Utils::Icons::WARNING.pixmap();
m_ui->qmlDebuggingWarningIcon->setPixmap(warning);
m_ui->qtQuickCompilerWarningIcon->setPixmap(warning);
qmakeBuildConfigChanged();
updateSummaryLabel();
updateEffectiveQMakeCall();
updateQmlDebuggingOption();
updateQtQuickCompilerOption();
connect(m_ui->qmakeAdditonalArgumentsLineEdit, &QLineEdit::textEdited,
this, &QMakeStepConfigWidget::qmakeArgumentsLineEdited);
connect(m_ui->buildConfigurationComboBox,
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
this, &QMakeStepConfigWidget::buildConfigurationSelected);
connect(m_ui->qmlDebuggingLibraryCheckBox, &QCheckBox::toggled,
this, &QMakeStepConfigWidget::linkQmlDebuggingLibraryChecked);
connect(m_ui->qmlDebuggingLibraryCheckBox, &QCheckBox::clicked,
this, [this] { askForRebuild(tr("QML Debugging")); });
connect(m_ui->qtQuickCompilerCheckBox, &QAbstractButton::toggled,
this, &QMakeStepConfigWidget::useQtQuickCompilerChecked);
connect(m_ui->qtQuickCompilerCheckBox, &QCheckBox::clicked,
this, [this] { askForRebuild(tr("QML Debugging")); });
connect(m_ui->separateDebugInfoCheckBox, &QAbstractButton::toggled,
this, &QMakeStepConfigWidget::separateDebugInfoChecked);
connect(m_ui->separateDebugInfoCheckBox, &QCheckBox::clicked,
this, [this] { askForRebuild(tr("QMake Configuration")); });
connect(step, &QMakeStep::userArgumentsChanged,
this, &QMakeStepConfigWidget::userArgumentsChanged);
connect(step, &QMakeStep::linkQmlDebuggingLibraryChanged,
this, &QMakeStepConfigWidget::linkQmlDebuggingLibraryChanged);
connect(step->project(), &Project::projectLanguagesUpdated,
this, &QMakeStepConfigWidget::linkQmlDebuggingLibraryChanged);
connect(step, &QMakeStep::useQtQuickCompilerChanged,
this, &QMakeStepConfigWidget::useQtQuickCompilerChanged);
connect(step, &QMakeStep::separateDebugInfoChanged,
this, &QMakeStepConfigWidget::separateDebugInfoChanged);
connect(step->qmakeBuildConfiguration(), &QmakeBuildConfiguration::qmakeBuildConfigurationChanged,
this, &QMakeStepConfigWidget::qmakeBuildConfigChanged);
connect(step->target(), &Target::kitChanged, this, &QMakeStepConfigWidget::qtVersionChanged);
connect(QtVersionManager::instance(), &QtVersionManager::dumpUpdatedFor,
this, &QMakeStepConfigWidget::qtVersionChanged);
auto chooser = new Core::VariableChooser(m_ui->qmakeAdditonalArgumentsLineEdit);
chooser->addMacroExpanderProvider([step] { return step->macroExpander(); });
chooser->addSupportedWidget(m_ui->qmakeAdditonalArgumentsLineEdit);
}
QMakeStepConfigWidget::~QMakeStepConfigWidget()
{
delete m_ui;
}
void QMakeStepConfigWidget::qtVersionChanged()
{
updateSummaryLabel();
updateEffectiveQMakeCall();
updateQmlDebuggingOption();
updateQtQuickCompilerOption();
}
void QMakeStepConfigWidget::qmakeBuildConfigChanged()
{
QmakeBuildConfiguration *bc = m_step->qmakeBuildConfiguration();
bool debug = bc->qmakeBuildConfiguration() & BaseQtVersion::DebugBuild;
m_ignoreChange = true;
m_ui->buildConfigurationComboBox->setCurrentIndex(debug? 0 : 1);
m_ignoreChange = false;
updateSummaryLabel();
updateEffectiveQMakeCall();
}
void QMakeStepConfigWidget::userArgumentsChanged()
{
if (m_ignoreChange)
return;
m_ui->qmakeAdditonalArgumentsLineEdit->setText(m_step->userArguments());
updateSummaryLabel();
updateEffectiveQMakeCall();
}
void QMakeStepConfigWidget::linkQmlDebuggingLibraryChanged()
{
if (m_ignoreChange)
return;
m_ui->qmlDebuggingLibraryCheckBox->setChecked(m_step->linkQmlDebuggingLibrary());
updateSummaryLabel();
updateEffectiveQMakeCall();
updateQmlDebuggingOption();
}
void QMakeStepConfigWidget::useQtQuickCompilerChanged()
{
if (m_ignoreChange)
return;
updateSummaryLabel();
updateEffectiveQMakeCall();
updateQtQuickCompilerOption();
updateQmlDebuggingOption();
}
void QMakeStepConfigWidget::separateDebugInfoChanged()
{
if (m_ignoreChange)
return;
updateSummaryLabel();
updateEffectiveQMakeCall();
}
void QMakeStepConfigWidget::qmakeArgumentsLineEdited()
{
m_ignoreChange = true;
m_step->setUserArguments(m_ui->qmakeAdditonalArgumentsLineEdit->text());
m_ignoreChange = false;
updateSummaryLabel();
updateEffectiveQMakeCall();
}
void QMakeStepConfigWidget::buildConfigurationSelected()
{
if (m_ignoreChange)
return;
QmakeBuildConfiguration *bc = m_step->qmakeBuildConfiguration();
BaseQtVersion::QmakeBuildConfigs buildConfiguration = bc->qmakeBuildConfiguration();
if (m_ui->buildConfigurationComboBox->currentIndex() == 0) { // debug
buildConfiguration = buildConfiguration | BaseQtVersion::DebugBuild;
} else {
buildConfiguration = buildConfiguration & ~BaseQtVersion::DebugBuild;
}
m_ignoreChange = true;
bc->setQMakeBuildConfiguration(buildConfiguration);
m_ignoreChange = false;
updateSummaryLabel();
updateEffectiveQMakeCall();
}
void QMakeStepConfigWidget::linkQmlDebuggingLibraryChecked(bool checked)
{
if (m_ignoreChange)
return;
m_ignoreChange = true;
m_step->setLinkQmlDebuggingLibrary(checked);
m_ignoreChange = false;
updateSummaryLabel();
updateEffectiveQMakeCall();
updateQmlDebuggingOption();
}
void QMakeStepConfigWidget::askForRebuild(const QString &title)
{
auto *question = new QMessageBox(Core::ICore::mainWindow());
question->setWindowTitle(title);
question->setText(tr("The option will only take effect if the project is recompiled. Do you want to recompile now?"));
question->setStandardButtons(QMessageBox::Yes | QMessageBox::No);
question->setModal(true);
connect(question, &QDialog::finished, this, &QMakeStepConfigWidget::recompileMessageBoxFinished);
question->show();
}
void QMakeStepConfigWidget::useQtQuickCompilerChecked(bool checked)
{
if (m_ignoreChange)
return;
m_ignoreChange = true;
m_step->setUseQtQuickCompiler(checked);
m_ignoreChange = false;
updateSummaryLabel();
updateEffectiveQMakeCall();
updateQmlDebuggingOption();
updateQtQuickCompilerOption();
}
void QMakeStepConfigWidget::separateDebugInfoChecked(bool checked)
{
if (m_ignoreChange)
return;
m_ignoreChange = true;
m_step->setSeparateDebugInfo(checked);
m_ignoreChange = false;
updateSummaryLabel();
updateEffectiveQMakeCall();
}
void QMakeStepConfigWidget::updateSummaryLabel()
{
BaseQtVersion *qtVersion = QtKitInformation::qtVersion(m_step->target()->kit());
if (!qtVersion) {
setSummaryText(tr("<b>qmake:</b> No Qt version set. Cannot run qmake."));
return;
}
// We don't want the full path to the .pro file
const QString args = m_step->allArguments(
qtVersion,
QMakeStep::ArgumentFlag::OmitProjectPath
| QMakeStep::ArgumentFlag::Expand);
// And we only use the .pro filename not the full path
const QString program = qtVersion->qmakeCommand().fileName();
setSummaryText(tr("<b>qmake:</b> %1 %2").arg(program, args));
}
void QMakeStepConfigWidget::updateQmlDebuggingOption()
{
QString warningText;
bool supported = BaseQtVersion::isQmlDebuggingSupported(m_step->target()->kit(),
&warningText);
m_ui->qmlDebuggingLibraryCheckBox->setEnabled(supported);
m_ui->debuggingLibraryLabel->setText(tr("Enable QML debugging and profiling:"));
if (supported && m_step->linkQmlDebuggingLibrary())
warningText = tr("Might make your application vulnerable. Only use in a safe environment.");
m_ui->qmlDebuggingWarningText->setText(warningText);
m_ui->qmlDebuggingWarningIcon->setVisible(!warningText.isEmpty());
updateQtQuickCompilerOption(); // show or clear compiler warning text
}
void QMakeStepConfigWidget::updateQtQuickCompilerOption()
{
QString warningText;
bool supported = BaseQtVersion::isQtQuickCompilerSupported(m_step->target()->kit(),
&warningText);
m_ui->qtQuickCompilerCheckBox->setEnabled(supported);
m_ui->qtQuickCompilerLabel->setText(tr("Enable Qt Quick Compiler:"));
if (supported && m_step->useQtQuickCompiler() && m_step->linkQmlDebuggingLibrary())
warningText = tr("Disables QML debugging. QML profiling will still work.");
m_ui->qtQuickCompilerWarningText->setText(warningText);
m_ui->qtQuickCompilerWarningIcon->setVisible(!warningText.isEmpty());
}
void QMakeStepConfigWidget::updateEffectiveQMakeCall()
{
m_ui->qmakeArgumentsEdit->setPlainText(m_step->effectiveQMakeCall());
}
void QMakeStepConfigWidget::recompileMessageBoxFinished(int button)
{
if (button == QMessageBox::Yes) {
QmakeBuildConfiguration *bc = m_step->qmakeBuildConfiguration();
if (!bc)
return;
QList<ProjectExplorer::BuildStepList *> stepLists;
const Core::Id clean = ProjectExplorer::Constants::BUILDSTEPS_CLEAN;
const Core::Id build = ProjectExplorer::Constants::BUILDSTEPS_BUILD;
stepLists << bc->stepList(clean) << bc->stepList(build);
BuildManager::buildLists(stepLists, QStringList() << ProjectExplorerPlugin::displayNameForStepId(clean)
<< ProjectExplorerPlugin::displayNameForStepId(build));
}
}
////
// QMakeStepFactory
////
QMakeStepFactory::QMakeStepFactory()
{
registerStep<QMakeStep>(QMAKE_BS_ID);
setSupportedConfiguration(Constants::QMAKE_BC_ID);
setSupportedStepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD);
setDisplayName(QMakeStep::tr("qmake"));
setFlags(BuildStepInfo::UniqueStep);
}
QMakeStepConfig::TargetArchConfig QMakeStepConfig::targetArchFor(const Abi &targetAbi, const BaseQtVersion *version)
{
QMakeStepConfig::TargetArchConfig arch = QMakeStepConfig::NoArch;
if (!version || version->type() != QtSupport::Constants::DESKTOPQT)
return arch;
if ((targetAbi.os() == ProjectExplorer::Abi::DarwinOS)
&& (targetAbi.binaryFormat() == ProjectExplorer::Abi::MachOFormat)) {
if (targetAbi.architecture() == ProjectExplorer::Abi::X86Architecture) {
if (targetAbi.wordWidth() == 32)
arch = QMakeStepConfig::X86;
else if (targetAbi.wordWidth() == 64)
arch = QMakeStepConfig::X86_64;
} else if (targetAbi.architecture() == ProjectExplorer::Abi::PowerPCArchitecture) {
if (targetAbi.wordWidth() == 32)
arch = QMakeStepConfig::PowerPC;
else if (targetAbi.wordWidth() == 64)
arch = QMakeStepConfig::PowerPC64;
}
}
return arch;
}
QMakeStepConfig::OsType QMakeStepConfig::osTypeFor(const ProjectExplorer::Abi &targetAbi, const BaseQtVersion *version)
{
QMakeStepConfig::OsType os = QMakeStepConfig::NoOsType;
const char IOSQT[] = "Qt4ProjectManager.QtVersion.Ios";
if (!version || version->type() != IOSQT)
return os;
if ((targetAbi.os() == ProjectExplorer::Abi::DarwinOS)
&& (targetAbi.binaryFormat() == ProjectExplorer::Abi::MachOFormat)) {
if (targetAbi.architecture() == ProjectExplorer::Abi::X86Architecture) {
os = QMakeStepConfig::IphoneSimulator;
} else if (targetAbi.architecture() == ProjectExplorer::Abi::ArmArchitecture) {
os = QMakeStepConfig::IphoneOS;
}
}
return os;
}
QStringList QMakeStepConfig::toArguments() const
{
QStringList arguments;
if (archConfig == X86)
arguments << "CONFIG+=x86";
else if (archConfig == X86_64)
arguments << "CONFIG+=x86_64";
else if (archConfig == PowerPC)
arguments << "CONFIG+=ppc";
else if (archConfig == PowerPC64)
arguments << "CONFIG+=ppc64";
// TODO: make that depend on the actual Qt version that is used
if (osType == IphoneSimulator)
arguments << "CONFIG+=iphonesimulator" << "CONFIG+=simulator" /*since Qt 5.7*/;
else if (osType == IphoneOS)
arguments << "CONFIG+=iphoneos" << "CONFIG+=device" /*since Qt 5.7*/;
if (linkQmlDebuggingQQ2)
arguments << "CONFIG+=qml_debug";
if (useQtQuickCompiler)
arguments << "CONFIG+=qtquickcompiler";
if (separateDebugInfo)
arguments << "CONFIG+=force_debug_info" << "CONFIG+=separate_debug_info";
if (!sysRoot.isEmpty()) {
arguments << ("QMAKE_CFLAGS+=--sysroot=\"" + sysRoot + "\"");
arguments << ("QMAKE_CXXFLAGS+=--sysroot=\"" + sysRoot + "\"");
arguments << ("QMAKE_LFLAGS+=--sysroot=\"" + sysRoot + "\"");
if (!targetTriple.isEmpty()) {
arguments << ("QMAKE_CFLAGS+=--target=" + targetTriple);
arguments << ("QMAKE_CXXFLAGS+=--target=" + targetTriple);
arguments << ("QMAKE_LFLAGS+=--target=" + targetTriple);
}
}
return arguments;
}
|