Skip to content

Commit 7f8eb53

Browse files
authored
Merge pull request #26745 from nkcsgexi/catalyst-infer-frameworks
swift-api-checker: teach infer-imports to find all catalyst-supporting Swift frameworks
2 parents eddb736 + 756be16 commit 7f8eb53

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

utils/api_checker/sdk-module-lists/infer-imports.py

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,31 @@ def get_immediate_subdirectories(a_dir):
1515
if os.path.isdir(os.path.join(a_dir, name))]
1616

1717

18+
def collect_catalyst_frameworks(frameworks_path):
19+
names = []
20+
for frame in os.listdir(frameworks_path):
21+
if frame.endswith(".framework"):
22+
name = frame[:-len(".framework")]
23+
# using the existence of this interface file as a sign of catalyst
24+
# being supported
25+
macabi_interface_path = \
26+
os.path.join(frameworks_path, frame,
27+
'Modules', name + '.swiftmodule',
28+
'x86_64-apple-ios-macabi.swiftinterface')
29+
if os.path.exists(macabi_interface_path):
30+
if name not in blacklist:
31+
names.append(name)
32+
return names
33+
34+
35+
def get_catalyst_frameworks(sdk_path):
36+
frameworks_path = sdk_path + "/System/Library/Frameworks"
37+
ios_support_path = sdk_path + \
38+
'/System/iOSSupport/System/Library/Frameworks/'
39+
return collect_catalyst_frameworks(frameworks_path) + \
40+
collect_catalyst_frameworks(ios_support_path)
41+
42+
1843
def get_frameworks(sdk_path, swift_frameworks_only):
1944
frameworks_path = sdk_path + "/System/Library/Frameworks"
2045
names = []
@@ -113,6 +138,7 @@ def main():
113138
parser.add_option("--swift-frameworks-only", action="store_true")
114139
parser.add_option("--swift-overlay-only", action="store_true")
115140
parser.add_option("--v", action="store_true")
141+
parser.add_option("--catalyst", action="store_true")
116142
(opts, cmd) = parser.parse_args()
117143

118144
if not opts.sdk:
@@ -125,7 +151,14 @@ def main():
125151
if opts.swift_overlay_only:
126152
frames = get_overlays(opts.sdk)
127153
else:
128-
frames = get_frameworks(opts.sdk, opts.swift_frameworks_only)
154+
if opts.catalyst:
155+
if opts.swift_frameworks_only:
156+
frames = get_catalyst_frameworks(opts.sdk)
157+
else:
158+
parser.error("only support find catalyst frameworks "
159+
"with --swift-frameworks-only")
160+
else:
161+
frames = get_frameworks(opts.sdk, opts.swift_frameworks_only)
129162
if opts.v:
130163
for name in frames:
131164
print >>sys.stderr, 'Including: ', name

0 commit comments

Comments
 (0)