aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Teske <daniel.teske@digia.com>2014-04-11 15:59:56 +0200
committerDaniel Teske <daniel.teske@digia.com>2014-04-14 12:00:49 +0200
commite820f577367340b091c2213fbe09bd9ecaa73812 (patch)
tree24322cc57efe073d362ed359f221bf386ef04253
parent47df753c7ddcb428b53800de054fa2940d1cd9b3 (diff)
ProWriter: Prepend $$PWD to files if adding to a .pri file
QMake's behavior for .pri files otherwise treats those paths as relative to the .pro file. That's rarely what you want. Also change the remove code to handle those files. Change-Id: I5fe95035b470c32c365adbdee161f4a6cae05c2b Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
-rw-r--r--src/plugins/qmakeprojectmanager/qmakenodes.cpp4
-rw-r--r--src/shared/proparser/prowriter.cpp28
-rw-r--r--src/shared/proparser/prowriter.h3
3 files changed, 27 insertions, 8 deletions
diff --git a/src/plugins/qmakeprojectmanager/qmakenodes.cpp b/src/plugins/qmakeprojectmanager/qmakenodes.cpp
index 5012d8e76e..71f6ad1c4e 100644
--- a/src/plugins/qmakeprojectmanager/qmakenodes.cpp
+++ b/src/plugins/qmakeprojectmanager/qmakenodes.cpp
@@ -1200,13 +1200,13 @@ void QmakePriFileNode::changeFiles(const QString &mimeType,
if (!includeFile)
return;
- QDir priFileDir = QDir(m_qmakeProFileNode->m_projectDir);
if (change == AddToProFile) {
// Use the first variable for adding.
- ProWriter::addFiles(includeFile, &lines, priFileDir, filePaths, varNameForAdding(mimeType));
+ ProWriter::addFiles(includeFile, &lines, filePaths, varNameForAdding(mimeType));
notChanged->clear();
} else { // RemoveFromProFile
+ QDir priFileDir = QDir(m_qmakeProFileNode->m_projectDir);
*notChanged = ProWriter::removeFiles(includeFile, &lines, priFileDir, filePaths, varNamesForRemoving());
}
diff --git a/src/shared/proparser/prowriter.cpp b/src/shared/proparser/prowriter.cpp
index 40eb243121..1860a6a95f 100644
--- a/src/shared/proparser/prowriter.cpp
+++ b/src/shared/proparser/prowriter.cpp
@@ -343,12 +343,15 @@ void ProWriter::putVarValues(ProFile *profile, QStringList *lines,
}
}
-void ProWriter::addFiles(ProFile *profile, QStringList *lines,
- const QDir &proFileDir, const QStringList &values, const QString &var)
+void ProWriter::addFiles(ProFile *profile, QStringList *lines, const QStringList &values, const QString &var)
{
QStringList valuesToWrite;
+ QString prefixPwd;
+ QDir baseDir = QFileInfo(profile->fileName()).absoluteDir();
+ if (profile->fileName().endsWith(QLatin1String(".pri")))
+ prefixPwd = QLatin1String("$$PWD/");
foreach (const QString &v, values)
- valuesToWrite << proFileDir.relativeFilePath(v);
+ valuesToWrite << (prefixPwd + baseDir.relativeFilePath(v));
putVarValues(profile, lines, valuesToWrite, var, AppendValues | MultiLine | AppendOperator);
}
@@ -508,8 +511,25 @@ QStringList ProWriter::removeFiles(ProFile *profile, QStringList *lines,
foreach (const QString &absoluteFilePath, values)
valuesToFind << proFileDir.relativeFilePath(absoluteFilePath);
+ QStringList notYetChanged;
+ foreach (int i, removeVarValues(profile, lines, valuesToFind, vars))
+ notYetChanged.append(values.at(i));
+
+ if (!profile->fileName().endsWith(QLatin1String(".pri")))
+ return notYetChanged;
+
+ // If we didn't find them with a relative path to the .pro file
+ // maybe those files can be found via $$PWD/relativeToPriFile
+
+ valuesToFind.clear();
+ QDir baseDir = QFileInfo(profile->fileName()).absoluteDir();
+ QString prefixPwd = QLatin1String("$$PWD/");
+ foreach (const QString &absoluteFilePath, notYetChanged)
+ valuesToFind << (prefixPwd + baseDir.relativeFilePath(absoluteFilePath));
+
QStringList notChanged;
foreach (int i, removeVarValues(profile, lines, valuesToFind, vars))
- notChanged.append(values.at(i));
+ notChanged.append(notYetChanged.at(i));
+
return notChanged;
}
diff --git a/src/shared/proparser/prowriter.h b/src/shared/proparser/prowriter.h
index bcb429f888..d4ecad5b5e 100644
--- a/src/shared/proparser/prowriter.h
+++ b/src/shared/proparser/prowriter.h
@@ -60,8 +60,7 @@ public:
static QList<int> removeVarValues(ProFile *profile, QStringList *lines,
const QStringList &values, const QStringList &vars);
- static void addFiles(ProFile *profile, QStringList *lines,
- const QDir &proFileDir, const QStringList &filePaths, const QString &var);
+ static void addFiles(ProFile *profile, QStringList *lines, const QStringList &filePaths, const QString &var);
static QStringList removeFiles(ProFile *profile, QStringList *lines,
const QDir &proFileDir, const QStringList &filePaths, const QStringList &vars);