forked from qt-creator/qt-creator
Android: Fix unnecessary loop in parsePlatforms
While the 'targets' value is indeed an array, we only use the first value in practice for Android builds. Simplify the code by removing the loop over 'targets' and use the first value directly. Also, try the next platform if we encounter a problem with the current one. Change-Id: Id00fc595d1a88fa81cb9c90c9ff3343704d781c7 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -212,24 +212,27 @@ static AndroidQtVersion::BuiltWith parsePlatforms(const QJsonObject &jsonObject,
|
||||
const QJsonObject platform = platformValue.toObject();
|
||||
if (platform.value("name").toString() != QLatin1String("Android"))
|
||||
continue;
|
||||
for (const QJsonValue &targetsValue : platform.value("targets").toArray()) {
|
||||
const QJsonObject target = targetsValue.toObject();
|
||||
const QJsonArray targets = platform.value("targets").toArray();
|
||||
if (targets.isEmpty())
|
||||
continue;
|
||||
const QJsonObject target = targets.first().toObject();
|
||||
const QString apiVersionString = target.value("api_version").toString();
|
||||
if (apiVersionString.isNull())
|
||||
return {};
|
||||
continue;
|
||||
bool apiVersionOK = false;
|
||||
result.apiVersion = versionFromPlatformString(apiVersionString, &apiVersionOK);
|
||||
if (!apiVersionOK)
|
||||
return {};
|
||||
continue;
|
||||
const QString ndkVersionString = target.value("ndk_version").toString();
|
||||
if (ndkVersionString.isNull())
|
||||
return {};
|
||||
continue;
|
||||
result.ndkVersion = QVersionNumber::fromString(ndkVersionString);
|
||||
if (result.apiVersion != -1 && !result.ndkVersion.isNull()) {
|
||||
if (ok)
|
||||
*ok = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (ok)
|
||||
*ok = true;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user