| 161 | } |
| 162 | |
| 163 | static CMakeTarget parseTarget(const QJsonObject& target, StringInterner& stringInterner, |
| 164 | PathInterner& sourcePathInterner, PathInterner& buildPathInterner, |
| 165 | CMakeFilesCompilationData& compilationData) |
| 166 | { |
| 167 | CMakeTarget ret; |
| 168 | ret.name = target.value(QLatin1String("name")).toString(); |
| 169 | ret.type = CMakeTarget::typeToEnum(target.value(QLatin1String("type")).toString()); |
| 170 | ret.folder = target.value(QLatin1String("folder")).toObject().value(QLatin1String("name")).toString(); |
| 171 | |
| 172 | for (const auto& jsonArtifact : target.value(QLatin1String("artifacts")).toArray()) { |
| 173 | const auto artifact = jsonArtifact.toObject(); |
| 174 | const auto buildPath = buildPathInterner.internPath(artifact.value(QLatin1String("path")).toString()); |
| 175 | if (buildPath.isValid()) { |
| 176 | ret.artifacts.append(buildPath); |
| 177 | } |
| 178 | } |
| 179 | |
| 180 | for (const auto& jsonSource : target.value(QLatin1String("sources")).toArray()) { |
| 181 | const auto source = jsonSource.toObject(); |
| 182 | const auto sourcePath = sourcePathInterner.internPath(source.value(QLatin1String("path")).toString()); |
| 183 | if (sourcePath.isValid()) { |
| 184 | ret.sources.append(sourcePath); |
| 185 | } |
| 186 | } |
| 187 | |
| 188 | QVector<CMakeFile> compileGroups; |
| 189 | for (const auto& jsonCompileGroup : target.value(QLatin1String("compileGroups")).toArray()) { |
| 190 | CMakeFile cmakeFile; |
| 191 | const auto compileGroup = jsonCompileGroup.toObject(); |
| 192 | |
| 193 | cmakeFile.language = compileGroup.value(QLatin1String("language")).toString(); |
| 194 | |
| 195 | for (const auto& jsonFragment : compileGroup.value(QLatin1String("compileCommandFragments")).toArray()) { |
| 196 | const auto fragment = jsonFragment.toObject(); |
| 197 | cmakeFile.compileFlags += fragment.value(QLatin1String("fragment")).toString(); |
| 198 | cmakeFile.compileFlags += QLatin1Char(' '); |
| 199 | } |
| 200 | cmakeFile.compileFlags = stringInterner.internString(cmakeFile.compileFlags); |
| 201 | |
| 202 | for (const auto& jsonDefine : compileGroup.value(QLatin1String("defines")).toArray()) { |
| 203 | const auto define = jsonDefine.toObject(); |
| 204 | cmakeFile.addDefine(define.value(QLatin1String("define")).toString()); |
| 205 | } |
| 206 | cmakeFile.defines = MakeFileResolver::extractDefinesFromCompileFlags(cmakeFile.compileFlags, stringInterner, cmakeFile.defines); |
| 207 | |
| 208 | for (const auto& jsonInclude : compileGroup.value(QLatin1String("includes")).toArray()) { |
| 209 | const auto include = jsonInclude.toObject(); |
| 210 | const auto path = sourcePathInterner.internPath(include.value(QLatin1String("path")).toString()); |
| 211 | if (path.isValid()) { |
| 212 | cmakeFile.includes.append(path); |
| 213 | } |
| 214 | } |
| 215 | |
| 216 | compileGroups.append(cmakeFile); |
| 217 | } |
| 218 | |
| 219 | for (const auto& jsonSource : target.value(QLatin1String("sources")).toArray()) { |
| 220 | const auto source = jsonSource.toObject(); |
no test coverage detected