forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -1200,13 +1200,13 @@ void QmakePriFileNode::changeFiles(const QString &mimeType,
|
|||||||
if (!includeFile)
|
if (!includeFile)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QDir priFileDir = QDir(m_qmakeProFileNode->m_projectDir);
|
|
||||||
|
|
||||||
if (change == AddToProFile) {
|
if (change == AddToProFile) {
|
||||||
// Use the first variable for adding.
|
// Use the first variable for adding.
|
||||||
ProWriter::addFiles(includeFile, &lines, priFileDir, filePaths, varNameForAdding(mimeType));
|
ProWriter::addFiles(includeFile, &lines, filePaths, varNameForAdding(mimeType));
|
||||||
notChanged->clear();
|
notChanged->clear();
|
||||||
} else { // RemoveFromProFile
|
} else { // RemoveFromProFile
|
||||||
|
QDir priFileDir = QDir(m_qmakeProFileNode->m_projectDir);
|
||||||
*notChanged = ProWriter::removeFiles(includeFile, &lines, priFileDir, filePaths, varNamesForRemoving());
|
*notChanged = ProWriter::removeFiles(includeFile, &lines, priFileDir, filePaths, varNamesForRemoving());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -343,12 +343,15 @@ void ProWriter::putVarValues(ProFile *profile, QStringList *lines,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProWriter::addFiles(ProFile *profile, QStringList *lines,
|
void ProWriter::addFiles(ProFile *profile, QStringList *lines, const QStringList &values, const QString &var)
|
||||||
const QDir &proFileDir, const QStringList &values, const QString &var)
|
|
||||||
{
|
{
|
||||||
QStringList valuesToWrite;
|
QStringList valuesToWrite;
|
||||||
|
QString prefixPwd;
|
||||||
|
QDir baseDir = QFileInfo(profile->fileName()).absoluteDir();
|
||||||
|
if (profile->fileName().endsWith(QLatin1String(".pri")))
|
||||||
|
prefixPwd = QLatin1String("$$PWD/");
|
||||||
foreach (const QString &v, values)
|
foreach (const QString &v, values)
|
||||||
valuesToWrite << proFileDir.relativeFilePath(v);
|
valuesToWrite << (prefixPwd + baseDir.relativeFilePath(v));
|
||||||
|
|
||||||
putVarValues(profile, lines, valuesToWrite, var, AppendValues | MultiLine | AppendOperator);
|
putVarValues(profile, lines, valuesToWrite, var, AppendValues | MultiLine | AppendOperator);
|
||||||
}
|
}
|
||||||
@@ -508,8 +511,25 @@ QStringList ProWriter::removeFiles(ProFile *profile, QStringList *lines,
|
|||||||
foreach (const QString &absoluteFilePath, values)
|
foreach (const QString &absoluteFilePath, values)
|
||||||
valuesToFind << proFileDir.relativeFilePath(absoluteFilePath);
|
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;
|
QStringList notChanged;
|
||||||
foreach (int i, removeVarValues(profile, lines, valuesToFind, vars))
|
foreach (int i, removeVarValues(profile, lines, valuesToFind, vars))
|
||||||
notChanged.append(values.at(i));
|
notChanged.append(notYetChanged.at(i));
|
||||||
|
|
||||||
return notChanged;
|
return notChanged;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,8 +60,7 @@ public:
|
|||||||
static QList<int> removeVarValues(ProFile *profile, QStringList *lines,
|
static QList<int> removeVarValues(ProFile *profile, QStringList *lines,
|
||||||
const QStringList &values, const QStringList &vars);
|
const QStringList &values, const QStringList &vars);
|
||||||
|
|
||||||
static void addFiles(ProFile *profile, QStringList *lines,
|
static void addFiles(ProFile *profile, QStringList *lines, const QStringList &filePaths, const QString &var);
|
||||||
const QDir &proFileDir, const QStringList &filePaths, const QString &var);
|
|
||||||
static QStringList removeFiles(ProFile *profile, QStringList *lines,
|
static QStringList removeFiles(ProFile *profile, QStringList *lines,
|
||||||
const QDir &proFileDir, const QStringList &filePaths, const QStringList &vars);
|
const QDir &proFileDir, const QStringList &filePaths, const QStringList &vars);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user