Esempio n. 1
0
def load_libclang():
    from ctypes.util import find_library

    if platform.system() == 'Darwin':
        libclangs = [
            '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/libclang.dylib',
            '/Library/Developer/CommandLineTools/usr/lib/libclang.dylib'
        ]
        found = False
        for libclang in libclangs:
            if os.path.exists(libclang):
                cindex.Config.set_library_path(os.path.dirname(libclang))
                found = True
                break
        if not found:
            lname = find_library("clang")
            if not lname is None:
                cindex.Config.set_library_file(lname)
    else:
        versions = [
            None, '7.0', '6.0', '5.0', '4.0', '3.9', '3.8', '3.7', '3.6',
            '3.5', '3.4', '3.3', '3.2'
        ]
        for v in versions:
            name = 'clang'
            if not v is None:
                name += '-' + v
            lname = find_library(name)
            if not lname is None:
                cindex.Config.set_library_file(lname)
                break

    testconf = cindex.Config()
    try:
        testconf.get_cindex_library()
    except cindex.LibclangError as e:
        log.error(
            "Fatal: Failed to locate libclang library.\ndox++ depends on libclang for parsing sources, please make sure you have libclang installed."
        )
        log.error(str(e))
        exit(1)

    return cindex
Esempio n. 2
0
else:
    versions = [None, '3.5', '3.4', '3.3', '3.2']

    for v in versions:
        name = 'clang'

        if not v is None:
            name += '-' + v

        lname = find_library(name)

        if not lname is None:
            cindex.Config.set_library_file(lname)
            break

testconf = cindex.Config()

try:
    testconf.get_cindex_library()
except cindex.LibclangError as e:
    sys.stderr.write(
        "\nFatal: Failed to locate libclang library. cldoc depends on libclang for parsing sources, please make sure you have libclang installed.\n"
        + str(e) + "\n\n")
    sys.exit(1)


class Tree(documentmerger.DocumentMerger):
    def __init__(self, files, flags):
        self.processed = {}
        self.files, ok = self.expand_sources(
            [os.path.realpath(f) for f in files])