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()
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)
......
......@@ -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,12 +708,28 @@ 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);
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) {
......@@ -729,20 +745,42 @@ QString AndroidManager::loadLocal(ProjectExplorer::Target *target, int apiLevel,
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(':');
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))
localLibs.replace(libElement.attribute(attribute).arg(apiLevel) + QLatin1Char(':'), QString());
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"));
}
}
// 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;
}
......
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