aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2020-06-03 09:33:13 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2020-06-03 13:04:14 +0200
commited1a6d48c61b33c94c51fb92619ae173fa5c22c5 (patch)
tree530bff6dd4c2d6ead4255e787a74f8c84cab6f58 /sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp
parentf4964cf0a9142029f67ce888da6dda74fb122bf5 (diff)
shiboken: Allow for multiple header files on command line
Change ApiExtractor and MetaBuilder to use QFileInfoList. Refactor the options handling to work on a struct separating options from positional arguments to make handling multiple file names easier. Refactor and streamline the options parsing code a bit, avoid duplicated parsing of project files. Print the usage when positional arguments are missing. [ChangeLog][shiboken] shiboken now accepts multiple headers on the command line. Change-Id: I221ab5a71232af1323408f77295137dc92e3d582 Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp')
-rw-r--r--sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp25
1 files changed, 14 insertions, 11 deletions
diff --git a/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp
index b54dc70ef..dedf0db50 100644
--- a/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp
+++ b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp
@@ -3106,9 +3106,9 @@ AbstractMetaArgumentList AbstractMetaBuilderPrivate::reverseList(const AbstractM
return ret;
}
-void AbstractMetaBuilder::setGlobalHeader(const QString& globalHeader)
+void AbstractMetaBuilder::setGlobalHeaders(const QFileInfoList &globalHeaders)
{
- d->m_globalHeader = QFileInfo(globalHeader);
+ d->m_globalHeaders = globalHeaders;
}
void AbstractMetaBuilder::setHeaderPaths(const HeaderPaths &hp)
@@ -3146,23 +3146,26 @@ static bool matchHeader(const QString &headerPath, const QString &fileName)
&& fileName.startsWith(headerPath, caseSensitivity);
}
-void AbstractMetaBuilderPrivate::setInclude(TypeEntry *te, const QString &fileName) const
+void AbstractMetaBuilderPrivate::setInclude(TypeEntry *te, const QString &path) const
{
- auto it = m_resolveIncludeHash.find(fileName);
+ auto it = m_resolveIncludeHash.find(path);
if (it == m_resolveIncludeHash.end()) {
- QFileInfo info(fileName);
- if (m_globalHeader.fileName() == info.fileName())
+ QFileInfo info(path);
+ const QString fileName = info.fileName();
+ if (std::any_of(m_globalHeaders.cbegin(), m_globalHeaders.cend(),
+ [fileName] (const QFileInfo &fi) {
+ return fi.fileName() == fileName; })) {
return;
+ }
int bestMatchLength = 0;
for (const auto &headerPath : m_headerPaths) {
- if (headerPath.size() > bestMatchLength && matchHeader(headerPath, fileName))
+ if (headerPath.size() > bestMatchLength && matchHeader(headerPath, path))
bestMatchLength = headerPath.size();
}
const QString include = bestMatchLength > 0
- ? fileName.right(fileName.size() - bestMatchLength - 1)
- : info.fileName();
- it = m_resolveIncludeHash.insert(fileName, {Include::IncludePath, include});
+ ? path.right(path.size() - bestMatchLength - 1) : fileName;
+ it = m_resolveIncludeHash.insert(path, {Include::IncludePath, include});
}
te->setInclude(it.value());
}
@@ -3187,7 +3190,7 @@ static void debugFormatSequence(QDebug &d, const char *key, const Container& c,
void AbstractMetaBuilder::formatDebug(QDebug &debug) const
{
- debug << "m_globalHeader=" << d->m_globalHeader.absoluteFilePath();
+ debug << "m_globalHeader=" << d->m_globalHeaders;
debugFormatSequence(debug, "globalEnums", d->m_globalEnums, "\n");
debugFormatSequence(debug, "globalFunctions", d->m_globalFunctions, "\n");
if (const int scopeCount = d->m_scopes.size()) {