forked from qt-creator/qt-creator
Fix Android plugin to support Qt 5 style rules-files
In Qt 5 we have modularized the rules files so that each module specifies its own rules. This patch updates the plugin to support reading from these in addition to the rules.xml of Qt 4 so that it should work well for both. The "replaces" attribute of the lib element is also added in Qt 5 because the files are generated and thus the approach of rules.xml where replaces is a separate element and where the order has semantics was not convenient. We of course support the Necessitas approach as well. Change-Id: Ife21903c9faf61e1791cf8c0ea78bb61c74dcb34 Reviewed-by: Daniel Teske <daniel.teske@digia.com> Reviewed-by: Paul Olav Tvete <paul.tvete@digia.com>
This commit is contained in:
@@ -558,7 +558,7 @@ Utils::FileName AndroidManager::localLibsRulesFilePath(ProjectExplorer::Target *
|
||||
QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(target->kit());
|
||||
if (!version)
|
||||
return Utils::FileName();
|
||||
return Utils::FileName::fromString(version->qmakeProperty("QT_INSTALL_LIBS") + QLatin1String("/rules.xml"));
|
||||
return Utils::FileName::fromString(version->qmakeProperty("QT_INSTALL_LIBS"));
|
||||
}
|
||||
|
||||
QString AndroidManager::loadLocalLibs(ProjectExplorer::Target *target, int apiLevel)
|
||||
@@ -708,41 +708,79 @@ QString AndroidManager::loadLocal(ProjectExplorer::Target *target, int apiLevel,
|
||||
|
||||
QString localLibs;
|
||||
|
||||
QDomDocument doc;
|
||||
if (!openXmlFile(doc, localLibsRulesFilePath(target)))
|
||||
QDir rulesFilesDir(localLibsRulesFilePath(target).toString());
|
||||
if (!rulesFilesDir.exists())
|
||||
return localLibs;
|
||||
|
||||
QStringList libs;
|
||||
libs << qtLibs(target) << prebundledLibs(target);
|
||||
QDomElement element = doc.documentElement().firstChildElement(QLatin1String("platforms")).firstChildElement(itemType + QLatin1Char('s')).firstChildElement(QLatin1String("version"));
|
||||
while (!element.isNull()) {
|
||||
if (element.attribute(QLatin1String("value")).toInt() == apiLevel) {
|
||||
if (element.hasAttribute(QLatin1String("symlink")))
|
||||
apiLevel = element.attribute(QLatin1String("symlink")).toInt();
|
||||
break;
|
||||
|
||||
QFileInfoList rulesFiles = rulesFilesDir.entryInfoList(QStringList() << QLatin1String("*.xml"),
|
||||
QDir::Files | QDir::Readable);
|
||||
|
||||
QStringList dependencyLibs;
|
||||
QStringList replacedLibs;
|
||||
foreach (QFileInfo rulesFile, rulesFiles) {
|
||||
if (rulesFile.baseName() != QLatin1String("rules")
|
||||
&& !rulesFile.baseName().endsWith(QLatin1String("-android-dependencies"))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
QDomDocument doc;
|
||||
if (!openXmlFile(doc, Utils::FileName::fromString(rulesFile.absoluteFilePath())))
|
||||
return localLibs;
|
||||
|
||||
QDomElement element = doc.documentElement().firstChildElement(QLatin1String("platforms")).firstChildElement(itemType + QLatin1Char('s')).firstChildElement(QLatin1String("version"));
|
||||
while (!element.isNull()) {
|
||||
if (element.attribute(QLatin1String("value")).toInt() == apiLevel) {
|
||||
if (element.hasAttribute(QLatin1String("symlink")))
|
||||
apiLevel = element.attribute(QLatin1String("symlink")).toInt();
|
||||
break;
|
||||
}
|
||||
element = element.nextSiblingElement(QLatin1String("version"));
|
||||
}
|
||||
|
||||
element = doc.documentElement().firstChildElement(QLatin1String("dependencies")).firstChildElement(QLatin1String("lib"));
|
||||
while (!element.isNull()) {
|
||||
if (libs.contains(element.attribute(QLatin1String("name")))) {
|
||||
QDomElement libElement = element.firstChildElement(QLatin1String("depends")).firstChildElement(itemType);
|
||||
while (!libElement.isNull()) {
|
||||
if (libElement.hasAttribute(attribute)) {
|
||||
QString dependencyLib = libElement.attribute(attribute).arg(apiLevel);
|
||||
if (!dependencyLibs.contains(dependencyLib))
|
||||
dependencyLibs << dependencyLib;
|
||||
}
|
||||
|
||||
if (libElement.hasAttribute(QLatin1String("replaces"))) {
|
||||
QString replacedLib = libElement.attribute(QLatin1String("replaces")).arg(apiLevel);
|
||||
if (!replacedLibs.contains(replacedLib))
|
||||
replacedLibs << replacedLib;
|
||||
}
|
||||
|
||||
libElement = libElement.nextSiblingElement(itemType);
|
||||
}
|
||||
|
||||
libElement = element.firstChildElement(QLatin1String("replaces")).firstChildElement(itemType);
|
||||
while (!libElement.isNull()) {
|
||||
if (libElement.hasAttribute(attribute)) {
|
||||
QString replacedLib = libElement.attribute(attribute).arg(apiLevel);
|
||||
if (!replacedLibs.contains(replacedLib))
|
||||
replacedLibs << replacedLib;
|
||||
}
|
||||
|
||||
libElement = libElement.nextSiblingElement(itemType);
|
||||
}
|
||||
}
|
||||
element = element.nextSiblingElement(QLatin1String("lib"));
|
||||
}
|
||||
element = element.nextSiblingElement(QLatin1String("version"));
|
||||
}
|
||||
|
||||
element = doc.documentElement().firstChildElement(QLatin1String("dependencies")).firstChildElement(QLatin1String("lib"));
|
||||
while (!element.isNull()) {
|
||||
if (libs.contains(element.attribute(QLatin1String("name")))) {
|
||||
QDomElement libElement = element.firstChildElement(QLatin1String("depends")).firstChildElement(itemType);
|
||||
while (!libElement.isNull()) {
|
||||
if (libElement.hasAttribute(attribute))
|
||||
localLibs += libElement.attribute(attribute).arg(apiLevel) + QLatin1Char(':');
|
||||
libElement = libElement.nextSiblingElement(itemType);
|
||||
}
|
||||
// The next loop requires all library names to end with a ":" so we append one
|
||||
// to the end after joining.
|
||||
localLibs = dependencyLibs.join(QLatin1Char(':')) + QLatin1Char(':');
|
||||
foreach (QString replacedLib, replacedLibs)
|
||||
localLibs.remove(replacedLib + QLatin1Char(':'));
|
||||
|
||||
libElement = element.firstChildElement(QLatin1String("replaces")).firstChildElement(itemType);
|
||||
while (!libElement.isNull()) {
|
||||
if (libElement.hasAttribute(attribute))
|
||||
localLibs.replace(libElement.attribute(attribute).arg(apiLevel) + QLatin1Char(':'), QString());
|
||||
libElement = libElement.nextSiblingElement(itemType);
|
||||
}
|
||||
}
|
||||
element = element.nextSiblingElement(QLatin1String("lib"));
|
||||
}
|
||||
return localLibs;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user