diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2017-11-02 14:13:37 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2017-11-03 15:28:13 +0000 |
commit | 0de4dffa0c5abc80df7063daf6bc9d1754891a9d (patch) | |
tree | 8a37329338fe6751c1db6668be32791158df6140 /sources/shiboken2/ApiExtractor/typedatabase.cpp | |
parent | 2bbe2cdb20cc6ee77bb69a0130cd74a161601861 (diff) |
shikoben2: Extend type system path resolution
- Remove stripping of directory components from the file names so that for
example QtCore/typesystem_core.xml can also be resolved via type system
path.
- In addition, pass in the path of the current file being parsed so that
for example typesystem_core_x11.xml is found from the directory
of typesystem_core.xml while parsing
Change-Id: Id10aafaf21750aa87460ccfe9ee3c3764086eda6
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'sources/shiboken2/ApiExtractor/typedatabase.cpp')
-rw-r--r-- | sources/shiboken2/ApiExtractor/typedatabase.cpp | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/sources/shiboken2/ApiExtractor/typedatabase.cpp b/sources/shiboken2/ApiExtractor/typedatabase.cpp index 4a96240c4..0ed016d3d 100644 --- a/sources/shiboken2/ApiExtractor/typedatabase.cpp +++ b/sources/shiboken2/ApiExtractor/typedatabase.cpp @@ -451,16 +451,20 @@ bool TypeDatabase::isSuppressedWarning(const QString& s) const return false; } -QString TypeDatabase::modifiedTypesystemFilepath(const QString& tsFile, bool stripPath) const +QString TypeDatabase::modifiedTypesystemFilepath(const QString& tsFile, const QString ¤tPath) const { const QFileInfo tsFi(tsFile); if (tsFi.isAbsolute()) // No point in further lookups return tsFi.absoluteFilePath(); if (tsFi.isFile()) // Make path absolute return tsFi.absoluteFilePath(); - const QString fileName = stripPath ? tsFi.fileName() : tsFile; + if (!currentPath.isEmpty()) { + const QFileInfo fi(currentPath + QLatin1Char('/') + tsFile); + if (fi.isFile()) + return fi.absoluteFilePath(); + } for (const QString &path : m_typesystemPaths) { - const QFileInfo fi(path + QLatin1Char('/') + fileName); + const QFileInfo fi(path + QLatin1Char('/') + tsFile); if (fi.isFile()) return fi.absoluteFilePath(); } @@ -469,7 +473,13 @@ QString TypeDatabase::modifiedTypesystemFilepath(const QString& tsFile, bool str bool TypeDatabase::parseFile(const QString &filename, bool generate) { - QString filepath = modifiedTypesystemFilepath(filename); + return parseFile(filename, QString(), generate); +} + +bool TypeDatabase::parseFile(const QString &filename, const QString ¤tPath, bool generate) +{ + + QString filepath = modifiedTypesystemFilepath(filename, currentPath); if (m_parsedTypesystemFiles.contains(filepath)) return m_parsedTypesystemFiles[filepath]; @@ -478,8 +488,11 @@ bool TypeDatabase::parseFile(const QString &filename, bool generate) QFile file(filepath); if (!file.exists()) { m_parsedTypesystemFiles[filepath] = false; - qCWarning(lcShiboken).noquote().nospace() - << "Can't find " << filename << ", typesystem paths: " << m_typesystemPaths.join(QLatin1String(", ")); + QString message = QLatin1String("Can't find ") + filename; + if (!currentPath.isEmpty()) + message += QLatin1String(", current path: ") + currentPath; + message += QLatin1String(", typesystem paths: ") + m_typesystemPaths.join(QLatin1String(", ")); + qCWarning(lcShiboken).noquote().nospace() << message; return false; } if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { |