Changeset View
Changeset View
Standalone View
Standalone View
projectmanagers/cmake/cmakeimportjsonjob.cpp
Show First 20 Lines • Show All 96 Lines • ▼ Show 20 Line(s) | 80 | foreach(const QJsonValue& value, document.array()) { | |||
---|---|---|---|---|---|
97 | // leading to lookup failures | 97 | // leading to lookup failures | ||
98 | const auto path = Path(QFileInfo(entry[KEY_FILE].toString()).canonicalFilePath()); | 98 | const auto path = Path(QFileInfo(entry[KEY_FILE].toString()).canonicalFilePath()); | ||
99 | data.files[path] = ret; | 99 | data.files[path] = ret; | ||
100 | } | 100 | } | ||
101 | 101 | | |||
102 | data.isValid = true; | 102 | data.isValid = true; | ||
103 | return data; | 103 | return data; | ||
104 | } | 104 | } | ||
105 | 105 | | |||
106 | QHash<KDevelop::Path, QStringList> importTargets(const Path& targetsFilePath, const QString& sourceDir, const KDevelop::Path &buildDir) | | |||
107 | { | | |||
108 | const QString buildPath = buildDir.toLocalFile(); | | |||
109 | QHash<KDevelop::Path, QStringList> targets; | | |||
110 | QFile targetsFile(targetsFilePath.toLocalFile()); | | |||
111 | if (!targetsFile.open(QIODevice::ReadOnly)) { | | |||
112 | qCDebug(CMAKE) << "Couldn't find the Targets file in" << targetsFile.fileName(); | | |||
113 | } | | |||
114 | const QRegularExpression rx(QStringLiteral("^(.*)/CMakeFiles/(.*).dir$")); | | |||
115 | for(; !targetsFile.atEnd(); ) { | | |||
116 | const QByteArray line = targetsFile.readLine(); | | |||
117 | auto match = rx.match(QString::fromUtf8(line)); | | |||
118 | if (!match.isValid()) | | |||
119 | qCDebug(CMAKE) << "invalid match for" << line; | | |||
120 | const QString sourcePath = match.captured(1).replace(buildPath, sourceDir); | | |||
121 | targets[KDevelop::Path(sourcePath)].append(match.captured(2)); | | |||
122 | } | | |||
123 | return targets; | | |||
124 | } | | |||
125 | | ||||
126 | QVector<Test> importTestSuites(const Path &buildDir) | 106 | QVector<Test> importTestSuites(const Path &buildDir) | ||
apol: I don't understand why. | |||||
arrowd: Me neither. What you suggest? | |||||
You can explain a bit better why it doesn't match with the $. If you print the matched strings, what do you get? apol: You can explain a bit better why it doesn't match with the $. If you print the matched strings… | |||||
arrowd: They are empty, both of them. | |||||
apol: What's the original string? Does it look like it should match? | |||||
Absolutely. C:/bla/bla/path/to/build/CMakeFiles/targetname.dir But no matches. arrowd: Absolutely.
C:/bla/bla/path/to/build/CMakeFiles/targetname.dir
But no matches. | |||||
Well, changing the line would mean to remove it because either we don't understand how QRegularExpression works or because ::readLine() isn't doint its job well (and thus should be properly fixed in Qt). apol: Well, changing the line would mean to remove it because either we don't understand how… | |||||
How about this? Even if it is a bug in Qt, this code wouldn't break once it is fixed. arrowd: How about this? Even if it is a bug in Qt, this code wouldn't break once it is fixed. | |||||
Could also switch to QTextStream-based file reading, which strips \r\n and \n. Makes this code more readable and avoids us having to do implement platform-specific behavior. kfunk: Could also switch to `QTextStream`-based file reading, which strips \r\n and \n. Makes this… | |||||
kfunk: Just `while(...)` | |||||
127 | { | 107 | { | ||
This should be in CMakeManager::populateTargets(), with the *_automoc target filtering. apol: This should be in CMakeManager::populateTargets(), with the *_automoc target filtering. | |||||
arrowd: K, will do. | |||||
128 | QVector<Test> ret; | 108 | QVector<Test> ret; | ||
129 | #pragma message("TODO use subdirs instead of this") | 109 | #pragma message("TODO use subdirs instead of this") | ||
130 | foreach(const QFileInfo &info, QDir(buildDir.toLocalFile()).entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot)) { | 110 | foreach(const QFileInfo &info, QDir(buildDir.toLocalFile()).entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot)) { | ||
131 | ret += importTestSuites(Path(buildDir, info.fileName())); | 111 | ret += importTestSuites(Path(buildDir, info.fileName())); | ||
132 | } | 112 | } | ||
133 | 113 | | |||
134 | QFile file(buildDir.toLocalFile()+"/CTestTestfile.cmake"); | 114 | QFile file(buildDir.toLocalFile()+"/CTestTestfile.cmake"); | ||
135 | if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { | 115 | if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { | ||
Show All 18 Lines | |||||
154 | 134 | | |||
155 | return ret; | 135 | return ret; | ||
156 | } | 136 | } | ||
157 | 137 | | |||
158 | ImportData import(const Path& commandsFile, const Path &targetsFilePath, const QString &sourceDir, const KDevelop::Path &buildPath) | 138 | ImportData import(const Path& commandsFile, const Path &targetsFilePath, const QString &sourceDir, const KDevelop::Path &buildPath) | ||
159 | { | 139 | { | ||
160 | return ImportData { | 140 | return ImportData { | ||
161 | importCommands(commandsFile), | 141 | importCommands(commandsFile), | ||
162 | importTargets(targetsFilePath, sourceDir, buildPath), | 142 | CMake::enumerateTargets(targetsFilePath, sourceDir, buildPath), | ||
163 | importTestSuites(buildPath) | 143 | importTestSuites(buildPath) | ||
164 | }; | 144 | }; | ||
165 | } | 145 | } | ||
166 | 146 | | |||
167 | } | 147 | } | ||
168 | 148 | | |||
169 | CMakeImportJob::CMakeImportJob(IProject* project, QObject* parent) | 149 | CMakeImportJob::CMakeImportJob(IProject* project, QObject* parent) | ||
170 | : KJob(parent) | 150 | : KJob(parent) | ||
▲ Show 20 Lines • Show All 58 Lines • Show Last 20 Lines |
I don't understand why.