mirror of
https://github.com/opentx/opentx.git
synced 2025-07-14 20:10:08 +03:00
Bsongis/modules sync issue 7288 (#7296)
This commit is contained in:
parent
c99175fc29
commit
dfcc7e92af
7 changed files with 88 additions and 26 deletions
|
@ -1,30 +1,33 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import sys
|
||||
import clang.cindex
|
||||
import time
|
||||
import os
|
||||
|
||||
if sys.platform == "darwin":
|
||||
if os.path.exists('/usr/local/Cellar/llvm/6.0.0/lib/libclang.dylib'):
|
||||
clang.cindex.Config.set_library_file('/usr/local/Cellar/llvm/6.0.0/lib/libclang.dylib')
|
||||
elif os.path.exists('/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/libclang.dylib'):
|
||||
clang.cindex.Config.set_library_file('/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/libclang.dylib')
|
||||
elif os.path.exists('/Library/Developer/CommandLineTools/usr/lib/libclang.dylib'):
|
||||
clang.cindex.Config.set_library_file('/Library/Developer/CommandLineTools/usr/lib/libclang.dylib')
|
||||
elif sys.platform.startswith("linux"):
|
||||
for version in ("7", "6.0", "3.8"):
|
||||
libclang = "/usr/lib/x86_64-linux-gnu/libclang-%s.so.1" % version
|
||||
if os.path.exists(libclang):
|
||||
clang.cindex.Config.set_library_file(libclang)
|
||||
break
|
||||
|
||||
structs = []
|
||||
extrastructs = []
|
||||
|
||||
|
||||
def find_libclang():
|
||||
if sys.platform == "darwin":
|
||||
for path in ("/usr/local/Cellar/llvm/6.0.0/lib/libclang.dylib",
|
||||
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/libclang.dylib",
|
||||
"/Library/Developer/CommandLineTools/usr/lib/libclang.dylib"):
|
||||
if os.path.exists(path):
|
||||
return path
|
||||
elif sys.platform.startswith("linux"):
|
||||
for version in ("7", "6.0", "3.8"):
|
||||
path = "/usr/lib/x86_64-linux-gnu/libclang-%s.so.1" % version
|
||||
if os.path.exists(path):
|
||||
return path
|
||||
for path in ("/usr/local/lib/libclang.so",
|
||||
"/usr/lib/libclang.so"):
|
||||
if os.path.exists(path):
|
||||
return path
|
||||
|
||||
|
||||
def build_struct(cursor, anonymousUnion=False):
|
||||
if not anonymousUnion:
|
||||
structs.append(cursor.spelling)
|
||||
|
@ -98,7 +101,28 @@ def header():
|
|||
print("// This file was auto-generated by %s script on %s. Do not edit this file!\n\n\n" % (os.path.basename(sys.argv[0]), time.asctime()))
|
||||
|
||||
|
||||
index = clang.cindex.Index.create()
|
||||
translation_unit = index.parse(sys.argv[1], ['-x', 'c++', '-std=c++11'] + sys.argv[2:])
|
||||
header()
|
||||
build(translation_unit.cursor)
|
||||
def print_translation_unit_diags(diags, prefix=''):
|
||||
for diag in diags:
|
||||
print(prefix + str(diag), file=sys.stderr)
|
||||
print_translation_unit_diags(diag.children, ' ' + prefix)
|
||||
|
||||
|
||||
def main():
|
||||
libclang = find_libclang()
|
||||
if libclang:
|
||||
# print(libclang, file=sys.stderr)
|
||||
clang.cindex.Config.set_library_file(libclang)
|
||||
|
||||
index = clang.cindex.Index.create()
|
||||
translation_unit = index.parse(sys.argv[1], ['-x', 'c++', '-std=c++11'] + sys.argv[2:])
|
||||
|
||||
if translation_unit.diagnostics:
|
||||
print_translation_unit_diags(translation_unit.diagnostics)
|
||||
sys.exit(-1)
|
||||
|
||||
header()
|
||||
build(translation_unit.cursor)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue