-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathphpqt5qmakebuildstep.cpp
More file actions
181 lines (143 loc) · 5.38 KB
/
Copy pathphpqt5qmakebuildstep.cpp
File metadata and controls
181 lines (143 loc) · 5.38 KB
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
#include "phpqt5qmakebuildstep.h"
#include "PHPQt5QMakebuildstep.h"
#include "phpqt5buildconfiguration.h"
#include "PHPQt5QMakebuildstepconfigwidget.h"
#include "phpqt5constants.h"
#include "phpqt5project.h"
#include <projectexplorer/buildconfiguration.h>
#include <utils/qtcassert.h>
#include <QDir>
using namespace ProjectExplorer;
using namespace Utils;
namespace PHPQt5 {
PHPQt5QMakeBuildStep::PHPQt5QMakeBuildStep(BuildStepList *parentList)
: AbstractProcessStep(parentList, Constants::C_PHPQt5QMAKEBUILDSTEP_ID)
{
setDefaultDisplayName(Constants::C_PHPQt5QMAKEBUILDSTEP_DISPLAY);
setDisplayName(Constants::C_PHPQt5QMAKEBUILDSTEP_DISPLAY);
auto bc = qobject_cast<PHPQt5BuildConfiguration *>(buildConfiguration());
connect(bc, &PHPQt5BuildConfiguration::buildDirectoryChanged,
this, &PHPQt5QMakeBuildStep::updateProcessParameters);
connect(this, &PHPQt5QMakeBuildStep::outFilePathChanged,
bc, &PHPQt5BuildConfiguration::outFilePathChanged);
updateProcessParameters();
}
PHPQt5QMakeBuildStep::DefaultBuildOptions PHPQt5QMakeBuildStep::defaultCompilerOptions() const
{
return m_defaultOptions;
}
void PHPQt5QMakeBuildStep::setDefaultCompilerOptions(PHPQt5QMakeBuildStep::DefaultBuildOptions options)
{
if (m_defaultOptions == options)
return;
m_defaultOptions = options;
emit defaultCompilerOptionsChanged(options);
updateProcessParameters();
}
BuildStepConfigWidget *PHPQt5QMakeBuildStep::createConfigWidget()
{
return new PHPQt5QMakeBuildStepConfigWidget(this);
}
bool PHPQt5QMakeBuildStep::fromMap(const QVariantMap &map)
{
AbstractProcessStep::fromMap(map);
m_userCompilerOptions = map[Constants::C_PHPQt5QMAKEBUILDSTEP_USERCOMPILEROPTIONS].toString().split(QLatin1Char('|'));
updateProcessParameters();
return true;
}
QVariantMap PHPQt5QMakeBuildStep::toMap() const
{
QVariantMap result = AbstractProcessStep::toMap();
result[Constants::C_PHPQt5QMAKEBUILDSTEP_USERCOMPILEROPTIONS] = m_userCompilerOptions.join(QLatin1Char('|'));
return result;
}
QStringList PHPQt5QMakeBuildStep::userCompilerOptions() const
{
return m_userCompilerOptions;
}
void PHPQt5QMakeBuildStep::setUserCompilerOptions(const QStringList &options)
{
m_userCompilerOptions = options;
emit userCompilerOptionsChanged(options);
updateProcessParameters();
}
FileName PHPQt5QMakeBuildStep::outFilePath() const
{
return m_outFilePath;
}
void PHPQt5QMakeBuildStep::setOutFilePath(const FileName &outFilePath)
{
if (outFilePath == m_outFilePath)
return;
m_outFilePath = outFilePath;
emit outFilePathChanged(outFilePath);
}
void PHPQt5QMakeBuildStep::updateProcessParameters()
{
updateOutFilePath();
updateCommand();
updateArguments();
updateWorkingDirectory();
updateEnvironment();
emit processParametersChanged();
}
void PHPQt5QMakeBuildStep::updateOutFilePath()
{
auto bc = qobject_cast<PHPQt5BuildConfiguration *>(buildConfiguration());
QTC_ASSERT(bc, return);
//const QString targetName = Utils::HostOsInfo::withExecutableSuffix(m_targetPHPQt5File.toFileInfo().baseName());
//FileName outFilePath = bc->buildDirectory().appendPath(targetName);
FileName outFilePath = bc->buildDirectory().appendPath("");
setOutFilePath(outFilePath);
}
void PHPQt5QMakeBuildStep::updateCommand()
{
#ifdef Q_OS_WIN
processParameters()->setCommand(QStringLiteral("qmake.exe"));
#else
processParameters()->setCommand(QStringLiteral("qmake"));
#endif
}
void PHPQt5QMakeBuildStep::updateWorkingDirectory()
{
auto bc = qobject_cast<PHPQt5BuildConfiguration *>(buildConfiguration());
QTC_ASSERT(bc, return);
processParameters()->setWorkingDirectory(bc->buildDirectory().toString());
}
void PHPQt5QMakeBuildStep::updateArguments()
{
PHPQt5BuildConfiguration *bc = qobject_cast<PHPQt5BuildConfiguration *>(buildConfiguration());
QTC_ASSERT(bc, return);
QStringList arguments;
PHPQt5Project *p = qobject_cast<PHPQt5Project *>(project());
arguments << QStringLiteral("\"%1/%2\"").arg(bc->buildDirectory().toString()).arg(p->projectFilePath().fileName().replace(QRegExp("\\.phpqt5$"), ".pro"));
arguments << QStringLiteral("-spec win32-msvc2015");
if (m_defaultOptions == Debug) {
// arguments << QStringLiteral("\"CONFIG+=debug\"");
// arguments << QStringLiteral("\"CONFIG+=qml_debug\"");
}
// arguments << QStringLiteral("&&");
// arguments << QStringLiteral("jom.exe");
// arguments << QStringLiteral("qmake_all");
// arguments << QStringLiteral("&&");
// arguments << QStringLiteral("jom.exe");
arguments << m_userCompilerOptions;
// Remove empty args
auto predicate = [](const QString &str) { return str.isEmpty(); };
auto it = std::remove_if(arguments.begin(), arguments.end(), predicate);
arguments.erase(it, arguments.end());
processParameters()->setArguments(arguments.join(QChar::Space));
}
void PHPQt5QMakeBuildStep::updateEnvironment()
{
PHPQt5BuildConfiguration * bc = qobject_cast<PHPQt5BuildConfiguration *>(buildConfiguration());
QTC_ASSERT(bc, return);
Utils::Environment env = bc->environment();
QDir applicationDirPath(QCoreApplication::applicationDirPath());
applicationDirPath.cdUp();
applicationDirPath.cdUp();
applicationDirPath.cdUp();
env.appendOrSetPath(applicationDirPath.canonicalPath() + "/PHPQt5");
processParameters()->setEnvironment(env);
}
}