Commit 765ad6c3 authored by Daniel Teske's avatar Daniel Teske

Android: Set ANDROID_EXTRA_LIBS scoped to the arch

The workflow for adding a library for multiple archs is not ideal, but
now a little better. The user has to go to the deploy setting for a
kit per architecture and add the right extra library.

Change-Id: I2bda6961f6f1164bdc58acd78fa3d2221977f0cf
Reviewed-by: default avatarOswald Buddenhagen <oswald.buddenhagen@digia.com>
parent 43579c9b
......@@ -31,6 +31,7 @@
#include "androidextralibrarylistmodel.h"
#include <qmakeprojectmanager/qmakeproject.h>
#include <qmakeprojectmanager/qmakenodes.h>
#include <proparser/prowriter.h>
using namespace Android;
using namespace Internal;
......@@ -83,6 +84,10 @@ void AndroidExtraLibraryListModel::proFileUpdated(QmakeProjectManager::QmakeProF
if (node != root)
return;
m_scope = QLatin1String("contains(ANDROID_TARGET_ARCH,")
+ node->singleVariableValue(QmakeProjectManager::AndroidArchVar)
+ QLatin1Char(')');
if (parseInProgress) {
emit enabledChanged(false);
return;
......@@ -124,7 +129,9 @@ void AndroidExtraLibraryListModel::addEntries(const QStringList &list)
m_entries += QDir(m_project->projectDirectory()).relativeFilePath(path);
QmakeProjectManager::QmakeProFileNode *node = m_project->rootQmakeProjectNode();
node->setProVariable(QLatin1String("ANDROID_EXTRA_LIBS"), m_entries.join(QLatin1String(" ")));
node->setProVariable(QLatin1String("ANDROID_EXTRA_LIBS"), m_entries, m_scope,
QmakeProjectManager::Internal::ProWriter::ReplaceValues
| QmakeProjectManager::Internal::ProWriter::MultiLine);
endInsertRows();
}
......@@ -156,5 +163,5 @@ void AndroidExtraLibraryListModel::removeEntries(QModelIndexList list)
}
QmakeProjectManager::QmakeProFileNode *node = m_project->rootQmakeProjectNode();
node->setProVariable(QLatin1String("ANDROID_EXTRA_LIBS"), m_entries.join(QLatin1String(" ")));
node->setProVariable(QLatin1String("ANDROID_EXTRA_LIBS"), m_entries, m_scope);
}
......@@ -68,6 +68,7 @@ private slots:
private:
QmakeProjectManager::QmakeProject *m_project;
QStringList m_entries;
QString m_scope;
};
} // namespace Internal
......
......@@ -252,7 +252,7 @@ void CreateAndroidManifestWizard::createAndroidManifestFile()
QString value = QLatin1String("$$PWD/")
+ QDir(m_target->project()->projectDirectory()).relativeFilePath(dir);
bool result =
m_node->setProVariable(QLatin1String("ANDROID_PACKAGE_SOURCE_DIR"), value);
m_node->setProVariable(QLatin1String("ANDROID_PACKAGE_SOURCE_DIR"), QStringList(value));
QStringList unChanged;
m_node->addFiles(QStringList(fileName), &unChanged);
......
......@@ -1214,7 +1214,7 @@ void QmakePriFileNode::changeFiles(const QString &mimeType,
includeFile->deref();
}
bool QmakePriFileNode::setProVariable(const QString &var, const QString &value)
bool QmakePriFileNode::setProVariable(const QString &var, const QStringList &values, const QString &scope, int flags)
{
if (!ensureWriteableProFile(m_projectFilePath))
return false;
......@@ -1223,8 +1223,9 @@ bool QmakePriFileNode::setProVariable(const QString &var, const QString &value)
ProFile *includeFile = pair.first;
QStringList lines = pair.second;
ProWriter::putVarValues(includeFile, &lines, QStringList(value), var,
ProWriter::ReplaceValues | ProWriter::OneLine | ProWriter::AssignOperator);
ProWriter::putVarValues(includeFile, &lines, values, var,
ProWriter::PutFlags(flags),
scope);
if (!includeFile)
return false;
......
......@@ -31,6 +31,7 @@
#define QMAKENODES_H
#include "qmakeprojectmanager_global.h"
#include "proparser/prowriter.h"
#include <coreplugin/idocument.h>
#include <projectexplorer/projectnodes.h>
......@@ -160,7 +161,9 @@ public:
bool renameFile(const QString &filePath, const QString &newFilePath);
AddNewInformation addNewInformation(const QStringList &files, Node *context) const;
bool setProVariable(const QString &var, const QString &value);
bool setProVariable(const QString &var, const QStringList &values,
const QString &scope = QString(),
int flags = QmakeProjectManager::Internal::ProWriter::ReplaceValues);
bool folderChanged(const QString &changedFolder, const QSet<Utils::FileName> &newFiles);
......@@ -199,6 +202,7 @@ private slots:
private:
static bool ensureWriteableProFile(const QString &file);
static QPair<ProFile *, QStringList> readProFile(const QString &file);
static QPair<ProFile *, QStringList> readProFileFromContents(const QString &contents);
void save(const QStringList &lines);
bool priFileWritable(const QString &path);
bool saveModifiedEditors();
......
......@@ -333,6 +333,7 @@ public:
const QString &items() const { return m_proitems; }
QString *itemsRef() { return &m_proitems; }
const ushort *tokPtr() const { return (const ushort *)m_proitems.constData(); }
const ushort *tokPtrEnd() const { return (const ushort *)m_proitems.constData() + m_proitems.size(); }
void ref() { m_refCount.ref(); }
void deref() { if (!m_refCount.deref()) delete this; }
......
......@@ -27,6 +27,7 @@
**
****************************************************************************/
#include "qmakeparser.h"
#include "prowriter.h"
#include "proitems.h"
......@@ -173,7 +174,34 @@ static const ushort *skipToken(ushort tok, const ushort *&tokPtr, int &lineNo)
return 0;
}
bool ProWriter::locateVarValues(const ushort *tokPtr,
QString ProWriter::compileScope(const QString &scope)
{
if (scope.isEmpty())
return QString();
QMakeParser parser(0, 0, 0);
ProFile *includeFile = parser.parsedProBlock(scope, QLatin1String("no-file"), 1);
if (!includeFile)
return QString();
QString result = includeFile->items();
includeFile->deref();
return result.mid(2); // chop of TokLine + linenumber
}
static bool startsWithTokens(const ushort *that, const ushort *thatEnd, const ushort *s, const ushort *sEnd)
{
if (thatEnd - that < sEnd - s)
return false;
do {
if (*that != *s)
return false;
++that;
++s;
} while (s < sEnd);
return true;
}
bool ProWriter::locateVarValues(const ushort *tokPtr, const ushort *tokPtrEnd,
const QString &scope, const QString &var, int *scopeStart, int *bestLine)
{
const bool inScope = scope.isEmpty();
......@@ -181,6 +209,10 @@ bool ProWriter::locateVarValues(const ushort *tokPtr,
QString tmp;
const ushort *lastXpr = 0;
bool fresh = true;
QString compiledScope = compileScope(scope);
const ushort *cTokPtr = (const ushort *)compiledScope.constData();
while (ushort tok = *tokPtr++) {
if (inScope && (tok == TokAssign || tok == TokAppend || tok == TokAppendUnique)) {
if (getLiteral(lastXpr, tokPtr - 1, tmp) && var == tmp) {
......@@ -190,12 +222,15 @@ bool ProWriter::locateVarValues(const ushort *tokPtr,
skipExpression(++tokPtr, lineNo);
fresh = true;
} else {
if (!inScope && tok == TokCondition && *tokPtr == TokBranch
&& getLiteral(lastXpr, tokPtr - 1, tmp) && scope == tmp) {
if (!inScope && fresh
&& startsWithTokens(tokPtr - 1, tokPtrEnd, cTokPtr, cTokPtr + compiledScope.size())
&& *(tokPtr -1 + compiledScope.size()) == TokBranch) {
*scopeStart = lineNo - 1;
if (locateVarValues(tokPtr + 3, QString(), var, scopeStart, bestLine))
if (locateVarValues(tokPtr + compiledScope.size() + 2, tokPtrEnd,
QString(), var, scopeStart, bestLine))
return true;
}
const ushort *oTokPtr = skipToken(tok, tokPtr, lineNo);
if (tok != TokLine) {
if (oTokPtr) {
......@@ -241,7 +276,7 @@ void ProWriter::putVarValues(ProFile *profile, QStringList *lines,
{
QString indent = scope.isEmpty() ? QString() : QLatin1String(" ");
int scopeStart = -1, lineNo;
if (locateVarValues(profile->tokPtr(), scope, var, &scopeStart, &lineNo)) {
if (locateVarValues(profile->tokPtr(), profile->tokPtrEnd(), scope, var, &scopeStart, &lineNo)) {
if (flags & ReplaceValues) {
// remove continuation lines with old values
int lNo = skipContLines(lines, lineNo, false);
......
......@@ -66,8 +66,9 @@ public:
const QDir &proFileDir, const QStringList &filePaths, const QStringList &vars);
private:
static bool locateVarValues(const ushort *tokPtr,
const QString &scope, const QString &var, int *scopeStart, int *bestLine);
static bool locateVarValues(const ushort *tokPtr, const ushort *tokPtrEnd,
const QString &scope, const QString &var, int *scopeStart, int *bestLine);
static QString compileScope(const QString &scope);
};
Q_DECLARE_OPERATORS_FOR_FLAGS(ProWriter::PutFlags)
......
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