aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Teske <daniel.teske@digia.com>2014-03-07 12:56:59 +0100
committerDaniel Teske <daniel.teske@digia.com>2014-04-01 16:23:10 +0200
commit765ad6c3d28813d4baa0aeafd03076ba76557d3d (patch)
treee3613025312663987463f7b7af36b7d2a34ce445
parent43579c9bc6501eb871edf5704c2c75a3f82309ee (diff)
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: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
-rw-r--r--src/plugins/android/androidextralibrarylistmodel.cpp11
-rw-r--r--src/plugins/android/androidextralibrarylistmodel.h1
-rw-r--r--src/plugins/android/createandroidmanifestwizard.cpp2
-rw-r--r--src/plugins/qmakeprojectmanager/qmakenodes.cpp7
-rw-r--r--src/plugins/qmakeprojectmanager/qmakenodes.h6
-rw-r--r--src/shared/proparser/proitems.h1
-rw-r--r--src/shared/proparser/prowriter.cpp45
-rw-r--r--src/shared/proparser/prowriter.h5
8 files changed, 64 insertions, 14 deletions
diff --git a/src/plugins/android/androidextralibrarylistmodel.cpp b/src/plugins/android/androidextralibrarylistmodel.cpp
index 858b78adb3..7b0a2b28f1 100644
--- a/src/plugins/android/androidextralibrarylistmodel.cpp
+++ b/src/plugins/android/androidextralibrarylistmodel.cpp
@@ -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);
}
diff --git a/src/plugins/android/androidextralibrarylistmodel.h b/src/plugins/android/androidextralibrarylistmodel.h
index b575ce60cd..86e82672ea 100644
--- a/src/plugins/android/androidextralibrarylistmodel.h
+++ b/src/plugins/android/androidextralibrarylistmodel.h
@@ -68,6 +68,7 @@ private slots:
private:
QmakeProjectManager::QmakeProject *m_project;
QStringList m_entries;
+ QString m_scope;
};
} // namespace Internal
diff --git a/src/plugins/android/createandroidmanifestwizard.cpp b/src/plugins/android/createandroidmanifestwizard.cpp
index bd8e0fbc52..21eedf7f10 100644
--- a/src/plugins/android/createandroidmanifestwizard.cpp
+++ b/src/plugins/android/createandroidmanifestwizard.cpp
@@ -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);
diff --git a/src/plugins/qmakeprojectmanager/qmakenodes.cpp b/src/plugins/qmakeprojectmanager/qmakenodes.cpp
index f0f5bdc3e1..8316e4b362 100644
--- a/src/plugins/qmakeprojectmanager/qmakenodes.cpp
+++ b/src/plugins/qmakeprojectmanager/qmakenodes.cpp
@@ -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;
diff --git a/src/plugins/qmakeprojectmanager/qmakenodes.h b/src/plugins/qmakeprojectmanager/qmakenodes.h
index 305d16380c..ff1342508e 100644
--- a/src/plugins/qmakeprojectmanager/qmakenodes.h
+++ b/src/plugins/qmakeprojectmanager/qmakenodes.h
@@ -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();
diff --git a/src/shared/proparser/proitems.h b/src/shared/proparser/proitems.h
index 391a4ef361..d1286156db 100644
--- a/src/shared/proparser/proitems.h
+++ b/src/shared/proparser/proitems.h
@@ -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; }
diff --git a/src/shared/proparser/prowriter.cpp b/src/shared/proparser/prowriter.cpp
index 4ac401eacb..40eb243121 100644
--- a/src/shared/proparser/prowriter.cpp
+++ b/src/shared/proparser/prowriter.cpp
@@ -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);
diff --git a/src/shared/proparser/prowriter.h b/src/shared/proparser/prowriter.h
index d48e1008a2..bcb429f888 100644
--- a/src/shared/proparser/prowriter.h
+++ b/src/shared/proparser/prowriter.h
@@ -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)