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

Function enumerateTargets

plugins/cmake/cmakeutils.cpp:211–233  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

209}
210
211QHash<KDevelop::Path, QStringList> enumerateTargets(const KDevelop::Path& targetsFilePath, const QString& sourceDir, const KDevelop::Path &buildDir)
212{
213 const QString buildPath = buildDir.toLocalFile();
214 QHash<KDevelop::Path, QStringList> targets;
215 QFile targetsFile(targetsFilePath.toLocalFile());
216 if (!targetsFile.open(QIODevice::ReadOnly)) {
217 qCDebug(CMAKE) << "Couldn't find the Targets file in" << targetsFile.fileName();
218 }
219
220 QTextStream targetsFileStream(&targetsFile);
221 const QRegularExpression rx(QStringLiteral("^(.*)/CMakeFiles/(.*).dir$"));
222 while (!targetsFileStream.atEnd()) {
223 const QString line = targetsFileStream.readLine();
224 auto match = rx.match(line);
225 if (!match.hasMatch()) {
226 qCDebug(CMAKE) << "CMakeFiles regex: no match for" << line;
227 continue;
228 }
229 const QString sourcePath = match.captured(1).replace(buildPath, sourceDir);
230 targets[KDevelop::Path(sourcePath)].append(match.captured(2));
231 }
232 return targets;
233}
234
235KDevelop::Path projectRoot(KDevelop::IProject* project)
236{

Callers 2

importFunction · 0.85
testEnumerateTargetsMethod · 0.85

Calls 10

toLocalFileMethod · 0.80
atEndMethod · 0.80
readLineMethod · 0.80
hasMatchMethod · 0.80
PathClass · 0.70
openMethod · 0.45
fileNameMethod · 0.45
matchMethod · 0.45
replaceMethod · 0.45
appendMethod · 0.45

Tested by 1

testEnumerateTargetsMethod · 0.68