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: default avatarDaniel Teske <daniel.teske@digia.com>
Reviewed-by: default avatarPaul Olav Tvete <paul.tvete@digia.com>
parent 6f150943
...@@ -262,7 +262,10 @@ int AndroidDeployStep::deviceAPILevel() ...@@ -262,7 +262,10 @@ int AndroidDeployStep::deviceAPILevel()
Utils::FileName AndroidDeployStep::localLibsRulesFilePath() Utils::FileName AndroidDeployStep::localLibsRulesFilePath()
{ {
return AndroidManager::localLibsRulesFilePath(target()); Utils::FileName fileName = AndroidManager::localLibsRulesFilePath(target());
fileName.append(QLatin1String("/rules.xml"));
return fileName;
} }
unsigned int AndroidDeployStep::remoteModificationTime(const QString &fullDestination, QHash<QString, unsigned int> *cache) unsigned int AndroidDeployStep::remoteModificationTime(const QString &fullDestination, QHash<QString, unsigned int> *cache)
......
...@@ -558,7 +558,7 @@ Utils::FileName AndroidManager::localLibsRulesFilePath(ProjectExplorer::Target * ...@@ -558,7 +558,7 @@ Utils::FileName AndroidManager::localLibsRulesFilePath(ProjectExplorer::Target *
QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(target->kit()); QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(target->kit());
if (!version) if (!version)
return Utils::FileName(); 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) QString AndroidManager::loadLocalLibs(ProjectExplorer::Target *target, int apiLevel)
...@@ -708,41 +708,79 @@ QString AndroidManager::loadLocal(ProjectExplorer::Target *target, int apiLevel, ...@@ -708,41 +708,79 @@ QString AndroidManager::loadLocal(ProjectExplorer::Target *target, int apiLevel,
QString localLibs; QString localLibs;
QDomDocument doc; QDir rulesFilesDir(localLibsRulesFilePath(target).toString());
if (!openXmlFile(doc, localLibsRulesFilePath(target))) if (!rulesFilesDir.exists())
return localLibs; return localLibs;
QStringList libs; QStringList libs;
libs << qtLibs(target) << prebundledLibs(target); libs << qtLibs(target) << prebundledLibs(target);
QDomElement element = doc.documentElement().firstChildElement(QLatin1String("platforms")).firstChildElement(itemType + QLatin1Char('s')).firstChildElement(QLatin1String("version"));
while (!element.isNull()) { QFileInfoList rulesFiles = rulesFilesDir.entryInfoList(QStringList() << QLatin1String("*.xml"),
if (element.attribute(QLatin1String("value")).toInt() == apiLevel) { QDir::Files | QDir::Readable);
if (element.hasAttribute(QLatin1String("symlink")))
apiLevel = element.attribute(QLatin1String("symlink")).toInt(); QStringList dependencyLibs;
break; QStringList replacedLibs;
foreach (QFileInfo rulesFile, rulesFiles) {
if (rulesFile.baseName() != QLatin1String("rules")
&& !rulesFile.baseName().endsWith(QLatin1String("-android-dependencies"))) {
continue;
} }
element = element.nextSiblingElement(QLatin1String("version"));
}
element = doc.documentElement().firstChildElement(QLatin1String("dependencies")).firstChildElement(QLatin1String("lib")); QDomDocument doc;
while (!element.isNull()) { if (!openXmlFile(doc, Utils::FileName::fromString(rulesFile.absoluteFilePath())))
if (libs.contains(element.attribute(QLatin1String("name")))) { return localLibs;
QDomElement libElement = element.firstChildElement(QLatin1String("depends")).firstChildElement(itemType);
while (!libElement.isNull()) { QDomElement element = doc.documentElement().firstChildElement(QLatin1String("platforms")).firstChildElement(itemType + QLatin1Char('s')).firstChildElement(QLatin1String("version"));
if (libElement.hasAttribute(attribute)) while (!element.isNull()) {
localLibs += libElement.attribute(attribute).arg(apiLevel) + QLatin1Char(':'); if (element.attribute(QLatin1String("value")).toInt() == apiLevel) {
libElement = libElement.nextSiblingElement(itemType); 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 = element.firstChildElement(QLatin1String("replaces")).firstChildElement(itemType); libElement = libElement.nextSiblingElement(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"));
} }
element = element.nextSiblingElement(QLatin1String("lib"));
} }
// 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(':'));
return localLibs; return localLibs;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment