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 102 Lines • ▼ Show 20 Line(s) | 132 | for (auto const& i : configured) { | |||
135 | if (!currFI.exists()) { | 136 | if (!currFI.exists()) { | ||
136 | return MESON_FAILED_CONFIGURATION; | 137 | return MESON_FAILED_CONFIGURATION; | ||
137 | } | 138 | } | ||
138 | } | 139 | } | ||
139 | 140 | | |||
140 | return MESON_CONFIGURED; | 141 | return MESON_CONFIGURED; | ||
141 | } | 142 | } | ||
142 | 143 | | |||
143 | KJob* MesonBuilder::configure(IProject* project, const Meson::BuildDir& buildDir, DirectoryStatus status) | 144 | KJob* MesonBuilder::configure(IProject* project, const Meson::BuildDir& buildDir, QStringList args, | ||
145 | DirectoryStatus status) | ||||
144 | { | 146 | { | ||
145 | Q_ASSERT(project); | 147 | Q_ASSERT(project); | ||
146 | 148 | | |||
147 | if (!buildDir.isValid()) { | 149 | if (!buildDir.isValid()) { | ||
148 | return new ErrorJob(this, i18n("The current build directory for %1 is invalid", project->name())); | 150 | return new ErrorJob(this, i18n("The current build directory for %1 is invalid", project->name())); | ||
149 | } | 151 | } | ||
150 | 152 | | |||
151 | if (status == ___UNDEFINED___) { | 153 | if (status == ___UNDEFINED___) { | ||
152 | status = evaluateBuildDirectory(buildDir.buildDir, buildDir.mesonBackend); | 154 | status = evaluateBuildDirectory(buildDir.buildDir, buildDir.mesonBackend); | ||
153 | } | 155 | } | ||
154 | 156 | | |||
155 | KJob* job = nullptr; | 157 | KJob* job = nullptr; | ||
156 | 158 | | |||
157 | switch (status) { | 159 | switch (status) { | ||
158 | case DOES_NOT_EXIST: | 160 | case DOES_NOT_EXIST: | ||
159 | case CLEAN: | 161 | case CLEAN: | ||
160 | case MESON_FAILED_CONFIGURATION: | 162 | case MESON_FAILED_CONFIGURATION: | ||
161 | job = new MesonJob(buildDir, project, MesonJob::CONFIGURE, {}, this); | 163 | job = new MesonJob(buildDir, project, MesonJob::CONFIGURE, args, this); | ||
162 | connect(job, &KJob::result, this, [this, project]() { emit configured(project); }); | 164 | connect(job, &KJob::result, this, [this, project]() { emit configured(project); }); | ||
163 | return job; | 165 | return job; | ||
164 | case MESON_CONFIGURED: | 166 | case MESON_CONFIGURED: | ||
165 | job = new MesonJob(buildDir, project, MesonJob::RE_CONFIGURE, {}, this); | 167 | job = new MesonJob(buildDir, project, MesonJob::RE_CONFIGURE, args, this); | ||
166 | connect(job, &KJob::result, this, [this, project]() { emit configured(project); }); | 168 | connect(job, &KJob::result, this, [this, project]() { emit configured(project); }); | ||
167 | return job; | 169 | return job; | ||
168 | case DIR_NOT_EMPTY: | 170 | case DIR_NOT_EMPTY: | ||
169 | return new ErrorJob( | 171 | return new ErrorJob( | ||
170 | this, | 172 | this, | ||
171 | i18n("The directory '%1' is not empty and does not seem to be an already configured build directory", | 173 | i18n("The directory '%1' is not empty and does not seem to be an already configured build directory", | ||
172 | buildDir.buildDir.toLocalFile())); | 174 | buildDir.buildDir.toLocalFile())); | ||
173 | case INVALID_BUILD_DIR: | 175 | case INVALID_BUILD_DIR: | ||
Show All 12 Lines | 185 | i18n("Congratulations: You have reached unreachable code!\n" | |||
186 | QStringLiteral(__FILE__), __LINE__)); | 188 | QStringLiteral(__FILE__), __LINE__)); | ||
187 | } | 189 | } | ||
188 | } | 190 | } | ||
189 | 191 | | |||
190 | KJob* MesonBuilder::configure(KDevelop::IProject* project) | 192 | KJob* MesonBuilder::configure(KDevelop::IProject* project) | ||
191 | { | 193 | { | ||
192 | Q_ASSERT(project); | 194 | Q_ASSERT(project); | ||
193 | auto buildDir = Meson::currentBuildDir(project); | 195 | auto buildDir = Meson::currentBuildDir(project); | ||
194 | return configure(project, buildDir); | 196 | if(!buildDir.isValid()) { | ||
197 | auto *bsm = project->buildSystemManager(); | ||||
198 | MesonManager *manager = dynamic_cast<MesonManager *>(bsm); | ||||
199 | if(!manager) { | ||||
200 | return new ErrorJob(this, i18n("Internal error: The buildsystem manager is not the MesonManager")); | ||||
201 | } | ||||
202 | | ||||
203 | KJob *newBDJob = manager->newBuildDirectory(project); | ||||
204 | if(!newBDJob) { | ||||
205 | return new ErrorJob(this, i18n("Failed to create a new build directory")); | ||||
206 | } | ||||
207 | return newBDJob; | ||||
208 | } | ||||
209 | return configure(project, buildDir, {}); | ||||
195 | } | 210 | } | ||
196 | 211 | | |||
197 | KJob* MesonBuilder::configureIfRequired(KDevelop::IProject* project, KJob* realJob) | 212 | KJob* MesonBuilder::configureIfRequired(KDevelop::IProject* project, KJob* realJob) | ||
198 | { | 213 | { | ||
199 | Q_ASSERT(project); | 214 | Q_ASSERT(project); | ||
200 | Meson::BuildDir buildDir = Meson::currentBuildDir(project); | 215 | Meson::BuildDir buildDir = Meson::currentBuildDir(project); | ||
201 | DirectoryStatus status = evaluateBuildDirectory(buildDir.buildDir, buildDir.mesonBackend); | 216 | DirectoryStatus status = evaluateBuildDirectory(buildDir.buildDir, buildDir.mesonBackend); | ||
202 | 217 | | |||
203 | if (status == MESON_CONFIGURED) { | 218 | if (status == MESON_CONFIGURED) { | ||
204 | return realJob; | 219 | return realJob; | ||
205 | } | 220 | } | ||
206 | 221 | | |||
222 | KJob *configureJob = nullptr; | ||||
223 | if(buildDir.isValid()) { | ||||
224 | configureJob = configure(project, buildDir, {}, status); | ||||
225 | } else { | ||||
226 | // Create a new build directory | ||||
227 | auto *bsm = project->buildSystemManager(); | ||||
228 | MesonManager *manager = dynamic_cast<MesonManager *>(bsm); | ||||
229 | if(!manager) { | ||||
230 | return new ErrorJob(this, i18n("Internal error: The buildsystem manager is not the MesonManager")); | ||||
231 | } | ||||
232 | | ||||
233 | configureJob = manager->newBuildDirectory(project); | ||||
234 | if(!configureJob) { | ||||
235 | return new ErrorJob(this, i18n("Failed to create a new build directory")); | ||||
236 | } | ||||
237 | } | ||||
238 | | ||||
207 | QList<KJob*> jobs = { | 239 | QList<KJob*> jobs = { | ||
208 | configure(project, buildDir, status), // First configure the build directory | 240 | configure(project, buildDir, {}, status), // First configure the build directory | ||
209 | realJob // If this succeeds execute the real job | 241 | realJob // If this succeeds execute the real job | ||
210 | }; | 242 | }; | ||
211 | 243 | | |||
212 | return new ExecuteCompositeJob(this, jobs); | 244 | return new ExecuteCompositeJob(this, jobs); | ||
213 | } | 245 | } | ||
214 | 246 | | |||
215 | KJob* MesonBuilder::build(KDevelop::ProjectBaseItem* item) | 247 | KJob* MesonBuilder::build(KDevelop::ProjectBaseItem* item) | ||
216 | { | 248 | { | ||
▲ Show 20 Lines • Show All 49 Lines • Show Last 20 Lines |