-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathphpqt5makebuildstep.cpp
More file actions
191 lines (152 loc) · 5.64 KB
/
Copy pathphpqt5makebuildstep.cpp
File metadata and controls
191 lines (152 loc) · 5.64 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
179
180
181
182
183
184
185
186
187
188
189
#include "phpqt5makebuildstep.h"
#include "phpqt5makebuildstep.h"
#include "phpqt5buildconfiguration.h"
#include "phpqt5makebuildstepconfigwidget.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 {
PHPQt5MakeBuildStep::PHPQt5MakeBuildStep(BuildStepList *parentList)
: AbstractProcessStep(parentList, Constants::C_PHPQt5MAKEBUILDSTEP_ID)
{
setDefaultDisplayName(tr(Constants::C_PHPQt5MAKEBUILDSTEP_DISPLAY));
setDisplayName(tr(Constants::C_PHPQt5MAKEBUILDSTEP_DISPLAY));
auto bc = qobject_cast<PHPQt5BuildConfiguration *>(buildConfiguration());
connect(bc, &PHPQt5BuildConfiguration::buildDirectoryChanged,
this, &PHPQt5MakeBuildStep::updateProcessParameters);
connect(this, &PHPQt5MakeBuildStep::outFilePathChanged,
bc, &PHPQt5BuildConfiguration::outFilePathChanged);
updateProcessParameters();
}
BuildStepConfigWidget *PHPQt5MakeBuildStep::createConfigWidget()
{
return new PHPQt5MakeBuildStepConfigWidget(this);
}
bool PHPQt5MakeBuildStep::fromMap(const QVariantMap &map)
{
AbstractProcessStep::fromMap(map);
m_userCompilerOptions = map[Constants::C_PHPQt5MAKEBUILDSTEP_USERCOMPILEROPTIONS].toString().split(QLatin1Char('|'));
m_defaultOptions = static_cast<DefaultBuildOptions>(map[Constants::C_PHPQt5MAKEBUILDSTEP_DEFAULTBUILDOPTIONS].toInt());
updateProcessParameters();
return true;
}
QVariantMap PHPQt5MakeBuildStep::toMap() const
{
QVariantMap result = AbstractProcessStep::toMap();
result[Constants::C_PHPQt5MAKEBUILDSTEP_USERCOMPILEROPTIONS] = m_userCompilerOptions.join(QLatin1Char('|'));
result[Constants::C_PHPQt5MAKEBUILDSTEP_DEFAULTBUILDOPTIONS] = m_defaultOptions;
return result;
}
QStringList PHPQt5MakeBuildStep::userCompilerOptions() const
{
return m_userCompilerOptions;
}
void PHPQt5MakeBuildStep::setUserCompilerOptions(const QStringList &options)
{
m_userCompilerOptions = options;
emit userCompilerOptionsChanged(options);
updateProcessParameters();
}
PHPQt5MakeBuildStep::DefaultBuildOptions PHPQt5MakeBuildStep::defaultCompilerOptions() const
{
return m_defaultOptions;
}
void PHPQt5MakeBuildStep::setDefaultCompilerOptions(PHPQt5MakeBuildStep::DefaultBuildOptions options)
{
if (m_defaultOptions == options)
return;
m_defaultOptions = options;
emit defaultCompilerOptionsChanged(options);
updateProcessParameters();
}
FileName PHPQt5MakeBuildStep::outFilePath() const
{
return m_outFilePath;
}
FileName PHPQt5MakeBuildStep::projectFilePath() const
{
PHPQt5Project *p = qobject_cast<PHPQt5Project *>(project());
return p->projectFilePath();
}
void PHPQt5MakeBuildStep::setOutFilePath(const FileName &outFilePath)
{
if (outFilePath == m_outFilePath)
return;
m_outFilePath = outFilePath;
emit outFilePathChanged(outFilePath);
}
void PHPQt5MakeBuildStep::updateProcessParameters()
{
updateOutFilePath();
updateCommand();
updateArguments();
updateWorkingDirectory();
updateEnvironment();
emit processParametersChanged();
}
void PHPQt5MakeBuildStep::updateOutFilePath()
{
PHPQt5BuildConfiguration *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 PHPQt5MakeBuildStep::updateCommand()
{
#ifdef Q_OS_WIN
processParameters()->setCommand(QStringLiteral("PHPQt5Make.exe"));
#else
processParameters()->setCommand(QStringLiteral("PHPQt5Make"));
#endif
}
void PHPQt5MakeBuildStep::updateWorkingDirectory()
{
auto bc = qobject_cast<PHPQt5BuildConfiguration *>(buildConfiguration());
QTC_ASSERT(bc, return);
processParameters()->setWorkingDirectory(bc->buildDirectory().toString());
}
void PHPQt5MakeBuildStep::updateArguments()
{
PHPQt5BuildConfiguration *bc = qobject_cast<PHPQt5BuildConfiguration *>(buildConfiguration());
QTC_ASSERT(bc, return);
QStringList arguments;
switch (m_defaultOptions) {
case Release:
bc->setBuildType(BuildConfiguration::BuildType::Release);
break;
case Debug:
bc->setBuildType(BuildConfiguration::BuildType::Debug);
arguments << QStringLiteral("--debug");
break;
default:
break;
}
PHPQt5Project *p = qobject_cast<PHPQt5Project *>(project());
arguments << QStringLiteral("--projectPath:\"%1\"").arg(p->projectFilePath().toString());
arguments << QStringLiteral("--buildPath:\"%1\"").arg(m_outFilePath.toString());
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 PHPQt5MakeBuildStep::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() + "/Tools/PHPQt5");
processParameters()->setEnvironment(env);
}
}