From 4612db54ace3215ab5a2d6bfa8169191866c8171 Mon Sep 17 00:00:00 2001 From: Dan Date: Wed, 15 May 2019 20:06:08 -0400 Subject: [PATCH] Try to autodetect the location of the clang standard libraries. On some linuxes, /usr/include belongs to GCC and the standard libraries that work with clang are in /usr/lib/clang/8.0.0 or some variation thereof. This results in errors such as: ``` /../lib64/gcc/x86_64-pc-linux-gnu/8.3.0/../../../../include/c++/8.3.0/bits/cxxabi_init_exception.h:38:10: fatal error: 'stddef.h' file not found ``` during extraction. --- tools/mkdoc.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tools/mkdoc.py b/tools/mkdoc.py index 740bc3b3..f7048ce7 100644 --- a/tools/mkdoc.py +++ b/tools/mkdoc.py @@ -14,6 +14,7 @@ import textwrap from clang import cindex from clang.cindex import CursorKind from collections import OrderedDict +from glob import glob from threading import Thread, Semaphore from multiprocessing import cpu_count @@ -240,6 +241,20 @@ if __name__ == '__main__': sysroot_dir = os.path.join(sdk_dir, next(os.walk(sdk_dir))[1][0]) parameters.append('-isysroot') parameters.append(sysroot_dir) + elif platform.system() == 'Linux': + # clang doesn't find its own base includes by default on Linux, + # but different distros install them in different paths. + # Try to autodetect, preferring the highest numbered version. + def clang_folder_version(d): + return [int(ver) for ver in re.findall(r'(?