MCPcopy Create free account
hub / github.com/KDE/kdevelop / createImportJob

Method createImportJob

plugins/meson/mesonmanager.cpp:282–370  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

280}
281
282KJob* MesonManager::createImportJob(ProjectFolderItem* item)
283{
284 IProject* project = item->project();
285 Q_ASSERT(project);
286
287 qCDebug(KDEV_Meson) << "Importing project" << project->name();
288
289 auto buildDir = Meson::currentBuildDir(project);
290
291 KJob* configureJob = nullptr;
292 if (!buildDir.isValid()) {
293 configureJob = newBuildDirectory(project, &buildDir);
294 if (!configureJob) {
295 QString error = i18n("Importing %1 failed because no build directory could be created.", project->name());
296 qCDebug(KDEV_Meson) << error;
297 return new ErrorJob(this, error);
298 }
299 }
300
301 auto introJob = new MesonIntrospectJob(
302 project, buildDir, { MesonIntrospectJob::TARGETS, MesonIntrospectJob::TESTS, MesonIntrospectJob::PROJECTINFO },
303 MesonIntrospectJob::BUILD_DIR, this);
304
305 KDirWatchPtr watcher = m_projectWatchers[project];
306 if (!watcher) {
307 // Create a new watcher
308 watcher = m_projectWatchers[project] = make_shared<KDirWatch>(nullptr);
309 QString projectName = project->name();
310
311 connect(watcher.get(), &KDirWatch::dirty, this, [=](QString p) { onMesonInfoChanged(p, projectName); });
312 connect(watcher.get(), &KDirWatch::created, this, [=](QString p) { onMesonInfoChanged(p, projectName); });
313 }
314
315 Path watchFile = buildDir.buildDir;
316 watchFile.addPath(QStringLiteral("meson-info"));
317 watchFile.addPath(QStringLiteral("meson-info.json"));
318 if (!watcher->contains(watchFile.path())) {
319 qCDebug(KDEV_Meson) << "Start watching file" << watchFile;
320 watcher->addFile(watchFile.path());
321 }
322
323 connect(introJob, &KJob::result, this, [this, introJob, item, project]() {
324 auto targets = introJob->targets();
325 auto tests = introJob->tests();
326 if (!targets || !tests) {
327 return;
328 }
329
330 // Remove old test suites before deleting them
331 if (const auto& suites = m_projectTestSuites[project]) {
332 cleanupTestSuites(suites->testSuites());
333 }
334
335 m_projectTargets[project] = targets;
336 m_projectTestSuites[project] = tests;
337 auto tgtList = targets->targets();
338 QVector<MesonTarget*> tgtCopy;
339 tgtCopy.reserve(tgtList.size());

Callers

nothing calls this directly

Calls 15

currentBuildDirFunction · 0.85
transformFunction · 0.85
populateTargetsFunction · 0.85
testControllerMethod · 0.80
setAbortOnSubjobErrorMethod · 0.80
cleanupTestSuitesFunction · 0.70
beginFunction · 0.50
endFunction · 0.50
projectMethod · 0.45
nameMethod · 0.45
isValidMethod · 0.45

Tested by

no test coverage detected