Commit 9e32603c authored by Christian Kandeler's avatar Christian Kandeler

QmakeProjectManager: Support wildcards in INSTALLS again

This functionality was (accidentally?) lost in some semi-recent
refactoring in the pro file evaluation code. Note that only the "*" and
"?" globs are supported.

Task-number: QTCREATORBUG-17935
Change-Id: I9ade940f4dbf9c5836cd8b5fab2d85d10f42ad9a
Reviewed-by: Oswald Buddenhagen's avatarOswald Buddenhagen <oswald.buddenhagen@qt.io>
parent f2ea25f0
......@@ -1419,7 +1419,7 @@ QmakeEvalResult *QmakeProFile::evaluate(const QmakeEvalInput &input)
result->newVarValues[Variable::CumulativeResource] = fileListForVar(cumulativeSourceFiles, QLatin1String("RESOURCES"));
result->newVarValues[Variable::PkgConfig] = exactReader->values(QLatin1String("PKGCONFIG"));
result->newVarValues[Variable::PrecompiledHeader] = ProFileEvaluator::sourcesToFiles(exactReader->fixifiedValues(
QLatin1String("PRECOMPILED_HEADER"), input.projectDir, input.buildDirectory.toString()));
QLatin1String("PRECOMPILED_HEADER"), input.projectDir, input.buildDirectory.toString(), false));
result->newVarValues[Variable::LibDirectories] = libDirectories(exactReader);
result->newVarValues[Variable::Config] = exactReader->values(QLatin1String("CONFIG"));
result->newVarValues[Variable::QmlImportPath] = exactReader->absolutePathValues(
......@@ -1657,7 +1657,8 @@ QStringList QmakeProFile::includePaths(QtSupport::ProFileReader *reader, const F
}
foreach (const ProFileEvaluator::SourceFile &el,
reader->fixifiedValues(QLatin1String("INCLUDEPATH"), projectDir, buildDir.toString())) {
reader->fixifiedValues(QLatin1String("INCLUDEPATH"), projectDir, buildDir.toString(),
false)) {
paths << sysrootify(el.fileName, sysroot.toString(), projectDir, buildDir.toString());
}
// paths already contains moc dir and ui dir, due to corrrectly parsing uic.prf and moc.prf
......@@ -1814,7 +1815,7 @@ InstallsList QmakeProFile::installsList(const QtSupport::ProFileReader *reader,
result.targetPath = itemPath;
} else {
const auto &itemFiles = reader->fixifiedValues(
item + QLatin1String(".files"), projectDir, buildDir);
item + QLatin1String(".files"), projectDir, buildDir, true);
result.items << InstallsItem(itemPath, itemFiles, active);
}
}
......
......@@ -77,7 +77,8 @@ QStringList ProFileEvaluator::values(const QString &variableName) const
}
QVector<ProFileEvaluator::SourceFile> ProFileEvaluator::fixifiedValues(
const QString &variable, const QString &baseDirectory, const QString &buildDirectory) const
const QString &variable, const QString &baseDirectory, const QString &buildDirectory,
bool expandWildcards) const
{
QVector<SourceFile> result;
foreach (const ProString &str, d->values(ProKey(variable))) {
......@@ -86,11 +87,29 @@ QVector<ProFileEvaluator::SourceFile> ProFileEvaluator::fixifiedValues(
result << SourceFile{QDir::cleanPath(el), str.sourceFile()};
} else {
QString fn = QDir::cleanPath(baseDirectory + QLatin1Char('/') + el);
if (IoUtils::exists(fn))
if (IoUtils::exists(fn)) {
result << SourceFile{fn, str.sourceFile()};
else
result << SourceFile{QDir::cleanPath(buildDirectory + QLatin1Char('/') + el),
str.sourceFile()};
} else {
QStringRef fileNamePattern;
if (expandWildcards) {
fileNamePattern = IoUtils::fileName(fn);
expandWildcards = fileNamePattern.contains('*')
|| fileNamePattern.contains('?');
}
if (expandWildcards) {
const QString patternBaseDir = IoUtils::pathName(fn).toString();
const QDir::Filters filters = QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot;
for (const QString &fileName : QDir(patternBaseDir).entryList(
QStringList(fileNamePattern.toString()), filters)) {
const QString fullFilePath
= QDir::cleanPath(patternBaseDir + '/' + fileName);
result << SourceFile({fullFilePath, str.sourceFile()});
}
} else {
result << SourceFile{QDir::cleanPath(buildDirectory + QLatin1Char('/') + el),
str.sourceFile()};
}
}
}
}
return result;
......
......@@ -81,7 +81,8 @@ public:
QString value(const QString &variableName) const;
QStringList values(const QString &variableName) const;
QVector<SourceFile> fixifiedValues(
const QString &variable, const QString &baseDirectory, const QString &buildDirectory) const;
const QString &variable, const QString &baseDirectory, const QString &buildDirectory,
bool expandWildcards) const;
QStringList absolutePathValues(const QString &variable, const QString &baseDirectory) const;
QVector<SourceFile> absoluteFileValues(
const QString &variable, const QString &baseDirectory, const QStringList &searchDirs,
......
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