Changeset View
Changeset View
Standalone View
Standalone View
projectmanagers/cmake/cmakeutils.cpp
Show All 18 Lines | |||||
19 | */ | 19 | */ | ||
20 | 20 | | |||
21 | #include "cmakeutils.h" | 21 | #include "cmakeutils.h" | ||
22 | 22 | | |||
23 | #include <QtCore/QFileInfo> | 23 | #include <QtCore/QFileInfo> | ||
24 | #include <QtCore/QDir> | 24 | #include <QtCore/QDir> | ||
25 | #include <QProcess> | 25 | #include <QProcess> | ||
26 | #include <QTemporaryDir> | 26 | #include <QTemporaryDir> | ||
27 | #include <QRegularExpression> | ||||
27 | 28 | | |||
28 | #include <kconfig.h> | 29 | #include <kconfig.h> | ||
29 | #include <KLocalizedString> | 30 | #include <KLocalizedString> | ||
30 | #include <kconfiggroup.h> | 31 | #include <kconfiggroup.h> | ||
31 | #include <kparts/mainwindow.h> | 32 | #include <kparts/mainwindow.h> | ||
32 | 33 | | |||
33 | #include <project/projectmodel.h> | 34 | #include <project/projectmodel.h> | ||
34 | #include <interfaces/iproject.h> | 35 | #include <interfaces/iproject.h> | ||
▲ Show 20 Lines • Show All 192 Lines • ▼ Show 20 Line(s) | 227 | !(QFile::exists( KDevelop::Path(builddir, "Makefile").toLocalFile() ) || | |||
227 | QFile::exists( KDevelop::Path(builddir, "build.ninja").toLocalFile() ) ) ) | 228 | QFile::exists( KDevelop::Path(builddir, "build.ninja").toLocalFile() ) ) ) | ||
228 | { | 229 | { | ||
229 | // User entered information already, but cmake hasn't actually been run yet. | 230 | // User entered information already, but cmake hasn't actually been run yet. | ||
230 | return true; | 231 | return true; | ||
231 | } | 232 | } | ||
232 | return false; | 233 | return false; | ||
233 | } | 234 | } | ||
234 | 235 | | |||
236 | QHash<KDevelop::Path, QStringList> enumerateTargets(const KDevelop::Path& targetsFilePath, const QString& sourceDir, const KDevelop::Path &buildDir) | ||||
237 | { | ||||
238 | const QString buildPath = buildDir.toLocalFile(); | ||||
239 | QHash<KDevelop::Path, QStringList> targets; | ||||
240 | QFile targetsFile(targetsFilePath.toLocalFile()); | ||||
241 | if (!targetsFile.open(QIODevice::ReadOnly)) { | ||||
242 | qCDebug(CMAKE) << "Couldn't find the Targets file in" << targetsFile.fileName(); | ||||
243 | } | ||||
244 | | ||||
245 | QTextStream targetsFileStream(&targetsFile); | ||||
246 | const QRegularExpression rx(QStringLiteral("^(.*)/CMakeFiles/(.*).dir$")); | ||||
247 | while (!targetsFileStream.atEnd()) { | ||||
248 | const QString line = targetsFileStream.readLine(); | ||||
249 | auto match = rx.match(line); | ||||
250 | if (!match.isValid()) | ||||
251 | qCDebug(CMAKE) << "invalid match for" << line; | ||||
252 | const QString sourcePath = match.captured(1).replace(buildPath, sourceDir); | ||||
253 | targets[KDevelop::Path(sourcePath)].append(match.captured(2)); | ||||
254 | } | ||||
255 | return targets; | ||||
256 | } | ||||
257 | | ||||
235 | KDevelop::Path projectRoot(KDevelop::IProject* project) | 258 | KDevelop::Path projectRoot(KDevelop::IProject* project) | ||
236 | { | 259 | { | ||
237 | if (!project) { | 260 | if (!project) { | ||
238 | return {}; | 261 | return {}; | ||
239 | } | 262 | } | ||
240 | 263 | | |||
241 | return project->path().cd(CMake::projectRootRelative(project)); | 264 | return project->path().cd(CMake::projectRootRelative(project)); | ||
242 | } | 265 | } | ||
▲ Show 20 Lines • Show All 324 Lines • Show Last 20 Lines |