Skip to content

Commit 245e627

Browse files
committed
Update metadata generator
1 parent 63e7be4 commit 245e627

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,3 +158,6 @@ cython_debug/
158158
# and can be added to the global gitignore or merged into this file. For a more nuclear
159159
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
160160
.idea/
161+
162+
# Metadata
163+
metadata.json

libs/metadata_generators/ios_metadata_generator.py

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
import clang.cindex
22
import json
33

4-
clang.cindex.Config.set_library_path(
5-
"/Applications/Xcode.app/Contents/Developer/Toolchains/"
6-
"XcodeDefault.xctoolchain/usr/lib/"
7-
)
4+
clang.cindex.Config.set_library_path("/usr/local/Cellar/llvm/16.0.4/lib/")
85
index = clang.cindex.Index.create()
96

107

118
def extract(cursor):
9+
print(f"{cursor.kind}: {cursor.spelling}")
1210
data = {"Name": cursor.spelling}
1311
if cursor.kind == clang.cindex.CursorKind.OBJC_INTERFACE_DECL:
1412
data["Type"] = "Interface"
@@ -29,11 +27,31 @@ def extract(cursor):
2927

3028

3129
def main():
30+
args = [
31+
"-x", "objective-c",
32+
"-arch", "arm64",
33+
"-fno-objc-arc",
34+
# "-fmodules",
35+
# "-fmodule-maps",
36+
"-ferror-limit=0",
37+
"-isysroot",
38+
"/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk",
39+
"-I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include",
40+
"-I/usr/local/include",
41+
"-I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/14.0.3/include",
42+
"-I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include",
43+
"-I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include",
44+
"-I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks"
45+
]
3246
tu = index.parse(
3347
"/Applications/Xcode.app/Contents/Developer/Platforms/"
3448
"iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/"
35-
"Library/Frameworks/UIKit.framework/Headers/UIKit.h"
49+
"Library/Frameworks/UIKit.framework/Headers/UIKit.h",
50+
args
3651
)
52+
print(f"Translation unit: {tu.spelling}")
53+
for diag in tu.diagnostics:
54+
print(diag)
3755
metadata = extract(tu.cursor)
3856
with open("metadata.json", "w") as f:
3957
json.dump(metadata, f, indent=2)

0 commit comments

Comments
 (0)