diff options
author | Eike Ziller <eike.ziller@qt.io> | 2020-02-25 15:09:12 +0100 |
---|---|---|
committer | Eike Ziller <eike.ziller@qt.io> | 2020-02-27 10:27:29 +0100 |
commit | ce895f066579f71d87c3b46361e291ad7734e88e (patch) | |
tree | 150402a0419c7da359c98c4cd8560542fc79c550 | |
parent | 698ffa215fd3fd7b8dd67ed9be88ca1a6731df91 (diff) |
QDoc: Fix handling of -F option
Even though it was documented to use -F to pass framework paths to
QDoc (macOS), that was not working and instead passing
"-I-Fthe_path_that_was_specified" to Clang.
[ChangeLog][qdoc] Fixed "-F" option on macOS
Task-number: QTBUG-82252
Change-Id: Ib85e3affad5487e428a8eccf0c239b437c75b759
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: Topi Reiniƶ <topi.reinio@qt.io>
-rw-r--r-- | src/qdoc/clangcodeparser.cpp | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/src/qdoc/clangcodeparser.cpp b/src/qdoc/clangcodeparser.cpp index 5e04c344e..f39d69354 100644 --- a/src/qdoc/clangcodeparser.cpp +++ b/src/qdoc/clangcodeparser.cpp @@ -1050,25 +1050,29 @@ void ClangCodeParser::initializeParser(const Config &config) printParsingErrors_ = 1; version_ = config.getString(CONFIG_VERSION); const auto args = config.getStringList(CONFIG_INCLUDEPATHS); - QStringList squeezedArgs; + QSet<QString> seen; + includePaths_.clear(); + // Remove empty paths and duplicates and add -I and canonicalize if necessary for (const auto &p : args) { - if (p.startsWith(QLatin1String("-I"))) - squeezedArgs << p.mid(2).trimmed(); - else - squeezedArgs << p; + QByteArray option; + QString rawpath; + if (p.startsWith(QLatin1String("-I")) || p.startsWith(QLatin1String("-F"))) { + rawpath = p.mid(2).trimmed(); + option = p.left(2).toUtf8(); + } else { + rawpath = p; + option = "-I"; + } + if (rawpath.isEmpty() || seen.contains(rawpath)) + continue; + seen.insert(rawpath); + QByteArray path(rawpath.toUtf8()); + QFileInfo fi(QDir::current(), rawpath); + if (fi.exists()) + path = fi.canonicalFilePath().toUtf8(); + path.prepend(option); + includePaths_.append(path); } - // Remove empty paths and duplicates - squeezedArgs.removeAll({}); - squeezedArgs.removeDuplicates(); - includePaths_.resize(squeezedArgs.size()); - std::transform(squeezedArgs.begin(), squeezedArgs.end(), includePaths_.begin(), - [](const QString &s) { - QByteArray path(s.toUtf8()); - QFileInfo fi(QDir::current(), s); - if (fi.exists()) - path = fi.canonicalFilePath().toUtf8(); - return path.prepend("-I"); - }); CppCodeParser::initializeParser(config); pchFileDir_.reset(nullptr); allHeaders_.clear(); |