diff options
author | Oswald Buddenhagen <oswald.buddenhagen@qt.io> | 2016-10-24 19:30:24 +0200 |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@qt.io> | 2016-11-01 17:34:55 +0000 |
commit | 424639ecac9d2e404d2bfaff7f46b45ed98664b8 (patch) | |
tree | 6ed64f844d8dca4e94e05ce2fa74e923d11220f1 /src/shared | |
parent | 1589ce3ce855833a50b4e12c86f2b9b5a83d7b02 (diff) |
make resource file handling able to deal with QMakeProject's VFS
resources.prf may create virtual qrc files when RESOURCES contains
non-qrc files.
Change-Id: If591de9b32b775059d67e94bc3cb06d23ee44b08
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
Diffstat (limited to 'src/shared')
-rw-r--r-- | src/shared/proparser/profileevaluator.cpp | 16 | ||||
-rw-r--r-- | src/shared/proparser/profileevaluator.h | 1 | ||||
-rw-r--r-- | src/shared/proparser/qmakevfs.cpp | 17 | ||||
-rw-r--r-- | src/shared/proparser/qmakevfs.h | 2 |
4 files changed, 29 insertions, 7 deletions
diff --git a/src/shared/proparser/profileevaluator.cpp b/src/shared/proparser/profileevaluator.cpp index ab11f5b6ce..5b937d3f09 100644 --- a/src/shared/proparser/profileevaluator.cpp +++ b/src/shared/proparser/profileevaluator.cpp @@ -26,6 +26,7 @@ #include "profileevaluator.h" #include "qmakeglobals.h" +#include "qmakevfs.h" #include "ioutils.h" #include <QDir> @@ -41,7 +42,8 @@ void ProFileEvaluator::initialize() ProFileEvaluator::ProFileEvaluator(QMakeGlobals *option, QMakeParser *parser, QMakeVfs *vfs, QMakeHandler *handler) - : d(new QMakeEvaluator(option, parser, vfs, handler)) + : d(new QMakeEvaluator(option, parser, vfs, handler)), + m_vfs(vfs) { } @@ -104,6 +106,7 @@ QStringList ProFileEvaluator::fixifiedValues( return result; } +// VFS note: all search paths are assumed to be real. QStringList ProFileEvaluator::absolutePathValues( const QString &variable, const QString &baseDirectory) const { @@ -124,25 +127,24 @@ QStringList ProFileEvaluator::absoluteFileValues( foreach (const QString &el, pro ? values(variable, pro) : values(variable)) { QString absEl; if (IoUtils::isAbsolutePath(el)) { - if (IoUtils::exists(el)) { + if (m_vfs->exists(el)) { result << el; goto next; } absEl = el; } else { foreach (const QString &dir, searchDirs) { - QString fn = dir + QLatin1Char('/') + el; - if (IoUtils::exists(fn)) { - result << QDir::cleanPath(fn); + QString fn = QDir::cleanPath(dir + QLatin1Char('/') + el); + if (m_vfs->exists(fn)) { + result << fn; goto next; } } if (baseDirectory.isEmpty()) goto next; - absEl = baseDirectory + QLatin1Char('/') + el; + absEl = QDir::cleanPath(baseDirectory + QLatin1Char('/') + el); } { - absEl = QDir::cleanPath(absEl); int nameOff = absEl.lastIndexOf(QLatin1Char('/')); QString absDir = d->m_tmp1.setRawData(absEl.constData(), nameOff); if (IoUtils::exists(absDir)) { diff --git a/src/shared/proparser/profileevaluator.h b/src/shared/proparser/profileevaluator.h index dd016c0911..898198e66b 100644 --- a/src/shared/proparser/profileevaluator.h +++ b/src/shared/proparser/profileevaluator.h @@ -86,6 +86,7 @@ public: private: QMakeEvaluator *d; + QMakeVfs *m_vfs; }; QT_END_NAMESPACE diff --git a/src/shared/proparser/qmakevfs.cpp b/src/shared/proparser/qmakevfs.cpp index 0231fa9a46..4d993ca2c1 100644 --- a/src/shared/proparser/qmakevfs.cpp +++ b/src/shared/proparser/qmakevfs.cpp @@ -97,6 +97,23 @@ bool QMakeVfs::writeFile(const QString &fn, QIODevice::OpenMode mode, bool exe, #endif } +#ifndef PROEVALUATOR_FULL +bool QMakeVfs::readVirtualFile(const QString &fn, QString *contents) +{ +# ifdef PROEVALUATOR_THREAD_SAFE + QMutexLocker locker(&m_mutex); +# endif + QHash<QString, QString>::ConstIterator it = m_files.constFind(fn); + if (it != m_files.constEnd() + && it->constData() != m_magicMissing.constData() + && it->constData() != m_magicExisting.constData()) { + *contents = *it; + return true; + } + return false; +} +#endif + bool QMakeVfs::readFile(const QString &fn, QString *contents, QString *errStr) { #ifndef PROEVALUATOR_FULL diff --git a/src/shared/proparser/qmakevfs.h b/src/shared/proparser/qmakevfs.h index 3ffe67c1ba..43f9e8c20c 100644 --- a/src/shared/proparser/qmakevfs.h +++ b/src/shared/proparser/qmakevfs.h @@ -48,6 +48,8 @@ public: bool exists(const QString &fn); #ifndef PROEVALUATOR_FULL + bool readVirtualFile(const QString &fn, QString *contents); + void invalidateCache(); void invalidateContents(); #endif |