From f97cf54db7a6f7642cc9fd122f23c4396c39bcf0 Mon Sep 17 00:00:00 2001 From: "Bobby R. Bruce" Date: Mon, 23 Sep 2019 13:52:58 -0700 Subject: ext: Updated Pybind11 to version 2.4.1. This updates Pybind11 from version 2.2.1 to version 2.4.1. This fixes warning/error received when "" is used when compiling using c++14 with clang. It should be noted that "ext/pybind11/include/pybind11/std.h" has been changed to include a fix added by commit ba42457254cc362eddc099f22b60d469cc6369e0. This is necessary to avoid build errors. Built: Linux (gcc, c++11) and MacOS (clang, c++14). Tested: Ran quick tests for X86, ARM, and RISC-V. Deprecates: https://gem5-review.googlesource.com/c/public/gem5/+/21019 Change-Id: Ie9783511cb6be50136076a55330e645f4f36d075 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/21119 Reviewed-by: Jason Lowe-Power Reviewed-by: Andreas Sandberg Maintainer: Jason Lowe-Power Maintainer: Andreas Sandberg Tested-by: kokoro --- ext/pybind11/tools/mkdoc.py | 127 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 101 insertions(+), 26 deletions(-) mode change 100644 => 100755 ext/pybind11/tools/mkdoc.py (limited to 'ext/pybind11/tools/mkdoc.py') diff --git a/ext/pybind11/tools/mkdoc.py b/ext/pybind11/tools/mkdoc.py old mode 100644 new mode 100755 index 1fd8cceed..44164af3d --- a/ext/pybind11/tools/mkdoc.py +++ b/ext/pybind11/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 @@ -40,6 +41,10 @@ PRINT_LIST = [ CursorKind.FIELD_DECL ] +PREFIX_BLACKLIST = [ + CursorKind.TRANSLATION_UNIT +] + CPP_OPERATORS = { '<=': 'le', '>=': 'ge', '==': 'eq', '!=': 'ne', '[]': 'array', '+=': 'iadd', '-=': 'isub', '*=': 'imul', '/=': 'idiv', '%=': @@ -56,10 +61,13 @@ CPP_OPERATORS = OrderedDict( job_count = cpu_count() job_semaphore = Semaphore(job_count) -output = [] + +class NoFilenamesError(ValueError): + pass + def d(s): - return s.decode('utf8') + return s if isinstance(s, str) else s.decode('utf8') def sanitize_name(name): @@ -182,18 +190,18 @@ def process_comment(comment): return result.rstrip().lstrip('\n') -def extract(filename, node, prefix): +def extract(filename, node, prefix, output): if not (node.location.file is None or os.path.samefile(d(node.location.file.name), filename)): return 0 if node.kind in RECURSE_LIST: sub_prefix = prefix - if node.kind != CursorKind.TRANSLATION_UNIT: + if node.kind not in PREFIX_BLACKLIST: if len(sub_prefix) > 0: sub_prefix += '_' sub_prefix += d(node.spelling) for i in node.get_children(): - extract(filename, i, sub_prefix) + extract(filename, i, sub_prefix, output) if node.kind in PRINT_LIST: comment = d(node.raw_comment) if node.raw_comment is not None else '' comment = process_comment(comment) @@ -202,15 +210,15 @@ def extract(filename, node, prefix): sub_prefix += '_' if len(node.spelling) > 0: name = sanitize_name(sub_prefix + d(node.spelling)) - global output output.append((name, filename, comment)) class ExtractionThread(Thread): - def __init__(self, filename, parameters): + def __init__(self, filename, parameters, output): Thread.__init__(self) self.filename = filename self.parameters = parameters + self.output = output job_semaphore.acquire() def run(self): @@ -219,13 +227,18 @@ class ExtractionThread(Thread): index = cindex.Index( cindex.conf.lib.clang_createIndex(False, True)) tu = index.parse(self.filename, self.parameters) - extract(self.filename, tu.cursor, '') + extract(self.filename, tu.cursor, '', self.output) finally: job_semaphore.release() -if __name__ == '__main__': - parameters = ['-x', 'c++', '-std=c++11'] + +def read_args(args): + parameters = [] filenames = [] + if "-x" not in args: + parameters.extend(['-x', 'c++']) + if not any(it.startswith("-std=") for it in args): + parameters.append('-std=c++11') if platform.system() == 'Darwin': dev_path = '/Applications/Xcode.app/Contents/Developer/' @@ -240,17 +253,48 @@ if __name__ == '__main__': sysroot_dir = os.path.join(sdk_dir, next(os.walk(sdk_dir))[1][0]) parameters.append('-isysroot') parameters.append(sysroot_dir) - - for item in sys.argv[1:]: + 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'(?