| 105 | } |
| 106 | |
| 107 | QString MesonIntrospectJob::importJSONFile(const BuildDir& buildDir, MesonIntrospectJob::Type type, QJsonObject* out) |
| 108 | { |
| 109 | QString typeStr = getTypeString(type); |
| 110 | QString fileName = QStringLiteral("intro-") + typeStr + QStringLiteral(".json"); |
| 111 | QString infoDir = buildDir.buildDir.toLocalFile() + QStringLiteral("/") + QStringLiteral("meson-info"); |
| 112 | QFile introFile(infoDir + QStringLiteral("/") + fileName); |
| 113 | |
| 114 | if (!introFile.exists()) { |
| 115 | return i18n("Introspection file '%1' does not exist", QFileInfo(introFile).canonicalFilePath()); |
| 116 | } |
| 117 | |
| 118 | if (!introFile.open(QFile::ReadOnly | QFile::Text)) { |
| 119 | return i18n("Failed to open introspection file '%1'", QFileInfo(introFile).canonicalFilePath()); |
| 120 | } |
| 121 | |
| 122 | QJsonParseError error; |
| 123 | QJsonDocument doc = QJsonDocument::fromJson(introFile.readAll(), &error); |
| 124 | if (error.error) { |
| 125 | return i18n("In %1:%2: %3", QFileInfo(introFile).canonicalFilePath(), error.offset, error.errorString()); |
| 126 | } |
| 127 | |
| 128 | if (doc.isArray()) { |
| 129 | (*out)[typeStr] = doc.array(); |
| 130 | } else if (doc.isObject()) { |
| 131 | (*out)[typeStr] = doc.object(); |
| 132 | } else { |
| 133 | return i18n("The introspection file '%1' contains neither an array nor an object", |
| 134 | QFileInfo(introFile).canonicalFilePath()); |
| 135 | } |
| 136 | |
| 137 | return QString(); |
| 138 | } |
| 139 | |
| 140 | QString MesonIntrospectJob::importMesonAPI(const BuildDir& buildDir, MesonIntrospectJob::Type type, QJsonObject* out) |
| 141 | { |
nothing calls this directly
no test coverage detected