Commit c95cba39 authored by Martin Smith's avatar Martin Smith
Browse files

qdoc: Find the system include path if not provided


clang needs the path to the system include files. There is
an option to pass system include paths to qdoc on the command
line, but currently there is no way to get the information
from the build system.

With this change, clangqdoc asks if the system include paths
have been provided. If not, it uses the path to <locale.h> as
the system include path, which it passes to clang using the
-isystem option.

Thanks to Edward Welbourne for this solution.

Change-Id: I2716505126d7780fc616b8ffd7cd2865576bae16
Reviewed-by: default avatarTopi Reiniö <topi.reinio@qt.io>
Showing with 26 additions and 1 deletion
......@@ -26,6 +26,15 @@
**
****************************************************************************/
// There must be no #include before this !
#define setlocale locale_file_name_for_clang_qdoc() { \
static char data[] = __FILE__; \
return data; \
} \
extern char *setlocale
#include <locale.h>
#undef setlocale
#include <qglobal.h>
#include <qhashfunctions.h>
#include <stdlib.h>
......@@ -636,6 +645,20 @@ QDocCommandLineParser::QDocCommandLineParser()
addOption(frameworkOption);
}
/*!
Return the system include directory used when compiling this file.
*/
static QByteArray getSystemIncludePath()
{
const char *raw = locale_file_name_for_clang_qdoc();
const char *slash = strrchr(raw, '/');
if (slash == NULL)
slash = strrchr(raw, '\\');
if (slash == NULL)
return QByteArray();
return QByteArray(raw, slash - raw);
}
void QDocCommandLineParser::process(const QCoreApplication &app)
{
QCommandLineParser::process(app);
......@@ -683,7 +706,9 @@ void QDocCommandLineParser::process(const QCoreApplication &app)
const auto paths = values(includePathOption);
for (const auto &i : paths)
includesPaths << "-I" << currentDir.absoluteFilePath(i);
const auto paths2 = values(includePathSystemOption);
auto paths2 = values(includePathSystemOption);
if (paths2.isEmpty())
paths2 << QString(getSystemIncludePath());
for (const auto &i : paths2)
includesPaths << "-isystem" << currentDir.absoluteFilePath(i);
const auto paths3 = values(frameworkOption);
......
Supports Markdown
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