Changeset View
Changeset View
Standalone View
Standalone View
plugins/meson/mesonbuilder.cpp
Show All 16 Lines | 1 | /* This file is part of KDevelop | |||
---|---|---|---|---|---|
17 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 17 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301, USA. | 18 | Boston, MA 02110-1301, USA. | ||
19 | */ | 19 | */ | ||
20 | 20 | | |||
21 | #include "mesonbuilder.h" | 21 | #include "mesonbuilder.h" | ||
22 | #include "mesonconfig.h" | 22 | #include "mesonconfig.h" | ||
23 | #include "mesonjob.h" | 23 | #include "mesonjob.h" | ||
24 | #include "mesonjobprune.h" | 24 | #include "mesonjobprune.h" | ||
25 | #include "mesonmanager.h" | ||||
25 | #include <QDir> | 26 | #include <QDir> | ||
26 | #include <QFileInfo> | 27 | #include <QFileInfo> | ||
27 | #include <debug.h> | 28 | #include <debug.h> | ||
28 | #include <executecompositejob.h> | 29 | #include <executecompositejob.h> | ||
29 | #include <interfaces/icore.h> | 30 | #include <interfaces/icore.h> | ||
30 | #include <interfaces/iplugincontroller.h> | 31 | #include <interfaces/iplugincontroller.h> | ||
31 | #include <interfaces/iproject.h> | 32 | #include <interfaces/iproject.h> | ||
32 | #include <klocalizedstring.h> | 33 | #include <klocalizedstring.h> | ||
▲ Show 20 Lines • Show All 109 Lines • ▼ Show 20 Line(s) | 139 | for (auto const& i : configured) { | |||
142 | if (!currFI.exists()) { | 143 | if (!currFI.exists()) { | ||
143 | return MESON_FAILED_CONFIGURATION; | 144 | return MESON_FAILED_CONFIGURATION; | ||
144 | } | 145 | } | ||
145 | } | 146 | } | ||
146 | 147 | | |||
147 | return MESON_CONFIGURED; | 148 | return MESON_CONFIGURED; | ||
148 | } | 149 | } | ||
149 | 150 | | |||
150 | KJob* MesonBuilder::configure(IProject* project, const Meson::BuildDir& buildDir, DirectoryStatus status) | 151 | KJob* MesonBuilder::configure(IProject* project, const Meson::BuildDir& buildDir, QStringList args, | ||
152 | DirectoryStatus status) | ||||
151 | { | 153 | { | ||
152 | Q_ASSERT(project); | 154 | Q_ASSERT(project); | ||
153 | 155 | | |||
154 | if (!buildDir.isValid()) { | 156 | if (!buildDir.isValid()) { | ||
155 | return new ErrorJob(this, i18n("The current build directory for %1 is invalid", project->name())); | 157 | return new ErrorJob(this, i18n("The current build directory for %1 is invalid", project->name())); | ||
156 | } | 158 | } | ||
157 | 159 | | |||
158 | if (status == ___UNDEFINED___) { | 160 | if (status == ___UNDEFINED___) { | ||
159 | status = evaluateBuildDirectory(buildDir.buildDir, buildDir.mesonBackend); | 161 | status = evaluateBuildDirectory(buildDir.buildDir, buildDir.mesonBackend); | ||
160 | } | 162 | } | ||
161 | 163 | | |||
162 | KJob* job = nullptr; | 164 | KJob* job = nullptr; | ||
163 | 165 | | |||
164 | switch (status) { | 166 | switch (status) { | ||
165 | case DOES_NOT_EXIST: | 167 | case DOES_NOT_EXIST: | ||
166 | case CLEAN: | 168 | case CLEAN: | ||
167 | case MESON_FAILED_CONFIGURATION: | 169 | case MESON_FAILED_CONFIGURATION: | ||
168 | job = new MesonJob(buildDir, project, MesonJob::CONFIGURE, {}, this); | 170 | job = new MesonJob(buildDir, project, MesonJob::CONFIGURE, args, this); | ||
169 | connect(job, &KJob::result, this, [this, project]() { emit configured(project); }); | 171 | connect(job, &KJob::result, this, [this, project]() { emit configured(project); }); | ||
170 | return job; | 172 | return job; | ||
171 | case MESON_CONFIGURED: | 173 | case MESON_CONFIGURED: | ||
172 | job = new MesonJob(buildDir, project, MesonJob::RE_CONFIGURE, {}, this); | 174 | job = new MesonJob(buildDir, project, MesonJob::RE_CONFIGURE, args, this); | ||
173 | connect(job, &KJob::result, this, [this, project]() { emit configured(project); }); | 175 | connect(job, &KJob::result, this, [this, project]() { emit configured(project); }); | ||
174 | return job; | 176 | return job; | ||
175 | case DIR_NOT_EMPTY: | 177 | case DIR_NOT_EMPTY: | ||
176 | return new ErrorJob( | 178 | return new ErrorJob( | ||
177 | this, | 179 | this, | ||
178 | i18n("The directory '%1' is not empty and does not seem to be an already configured build directory", | 180 | i18n("The directory '%1' is not empty and does not seem to be an already configured build directory", | ||
179 | buildDir.buildDir.toLocalFile())); | 181 | buildDir.buildDir.toLocalFile())); | ||
180 | case INVALID_BUILD_DIR: | 182 | case INVALID_BUILD_DIR: | ||
Show All 12 Lines | 192 | i18n("Congratulations: You have reached unreachable code!\n" | |||
193 | QStringLiteral(__FILE__), __LINE__)); | 195 | QStringLiteral(__FILE__), __LINE__)); | ||
194 | } | 196 | } | ||
195 | } | 197 | } | ||
196 | 198 | | |||
197 | KJob* MesonBuilder::configure(KDevelop::IProject* project) | 199 | KJob* MesonBuilder::configure(KDevelop::IProject* project) | ||
198 | { | 200 | { | ||
199 | Q_ASSERT(project); | 201 | Q_ASSERT(project); | ||
200 | auto buildDir = Meson::currentBuildDir(project); | 202 | auto buildDir = Meson::currentBuildDir(project); | ||
201 | return configure(project, buildDir); | 203 | if(!buildDir.isValid()) { | ||
204 | auto *bsm = project->buildSystemManager(); | ||||
205 | MesonManager *manager = dynamic_cast<MesonManager *>(bsm); | ||||
206 | if(!manager) { | ||||
207 | return new ErrorJob(this, i18n("Internal error: The buildsystem manager is not the MesonManager")); | ||||
208 | } | ||||
209 | | ||||
210 | KJob *newBDJob = manager->newBuildDirectory(project); | ||||
211 | if(!newBDJob) { | ||||
212 | return new ErrorJob(this, i18n("Failed to create a new build directory")); | ||||
213 | } | ||||
214 | return newBDJob; | ||||
215 | } | ||||
216 | return configure(project, buildDir, {}); | ||||
202 | } | 217 | } | ||
203 | 218 | | |||
204 | KJob* MesonBuilder::configureIfRequired(KDevelop::IProject* project, KJob* realJob) | 219 | KJob* MesonBuilder::configureIfRequired(KDevelop::IProject* project, KJob* realJob) | ||
205 | { | 220 | { | ||
206 | Q_ASSERT(project); | 221 | Q_ASSERT(project); | ||
207 | Meson::BuildDir buildDir = Meson::currentBuildDir(project); | 222 | Meson::BuildDir buildDir = Meson::currentBuildDir(project); | ||
208 | DirectoryStatus status = evaluateBuildDirectory(buildDir.buildDir, buildDir.mesonBackend); | 223 | DirectoryStatus status = evaluateBuildDirectory(buildDir.buildDir, buildDir.mesonBackend); | ||
209 | 224 | | |||
210 | if (status == MESON_CONFIGURED) { | 225 | if (status == MESON_CONFIGURED) { | ||
211 | return realJob; | 226 | return realJob; | ||
212 | } | 227 | } | ||
213 | 228 | | |||
229 | KJob *configureJob = nullptr; | ||||
230 | if(buildDir.isValid()) { | ||||
231 | configureJob = configure(project, buildDir, {}, status); | ||||
232 | } else { | ||||
233 | // Create a new build directory | ||||
234 | auto *bsm = project->buildSystemManager(); | ||||
235 | MesonManager *manager = dynamic_cast<MesonManager *>(bsm); | ||||
236 | if(!manager) { | ||||
237 | return new ErrorJob(this, i18n("Internal error: The buildsystem manager is not the MesonManager")); | ||||
238 | } | ||||
239 | | ||||
240 | configureJob = manager->newBuildDirectory(project); | ||||
241 | if(!configureJob) { | ||||
242 | return new ErrorJob(this, i18n("Failed to create a new build directory")); | ||||
243 | } | ||||
244 | } | ||||
245 | | ||||
214 | QList<KJob*> jobs = { | 246 | QList<KJob*> jobs = { | ||
215 | configure(project, buildDir, status), // First configure the build directory | 247 | configure(project, buildDir, {}, status), // First configure the build directory | ||
216 | realJob // If this succeeds execute the real job | 248 | realJob // If this succeeds execute the real job | ||
217 | }; | 249 | }; | ||
218 | 250 | | |||
219 | return new ExecuteCompositeJob(this, jobs); | 251 | return new ExecuteCompositeJob(this, jobs); | ||
220 | } | 252 | } | ||
221 | 253 | | |||
222 | KJob* MesonBuilder::build(KDevelop::ProjectBaseItem* item) | 254 | KJob* MesonBuilder::build(KDevelop::ProjectBaseItem* item) | ||
223 | { | 255 | { | ||
▲ Show 20 Lines • Show All 49 Lines • Show Last 20 Lines |