Skip to content

Commit 362ece8

Browse files
committed
swift-api-checker: add support for invoking low-level executable using iosmac target
1 parent d388bac commit 362ece8

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// Empty
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// Empty

utils/api_checker/swift-api-checker.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ def check_output(cmd, verbose=False):
4444

4545

4646
def get_sdk_path(platform):
47+
if platform.startswith('iosmac'):
48+
platform = 'macosx'
4749
return check_output(['xcrun', '-sdk', platform, '-show-sdk-path'])
4850

4951

@@ -94,14 +96,24 @@ def __init__(self, tool_path, platform):
9496
'macosx': 'x86_64-apple-macosx10.15',
9597
'appletvos': 'arm64-apple-tvos13.0',
9698
'watchos': 'armv7k-apple-watchos6.0',
99+
'iosmac': 'x86_64-apple-ios13.0-macabi',
97100
}
98101
self.tool_path = get_api_digester_path(tool_path)
99102
self.platform = platform
100103
self.target = target_map[platform]
101104
self.sdk = get_sdk_path(platform)
105+
self.inputs = []
106+
if self.platform == 'macosx':
107+
# We need this input search path for CreateML
108+
self.inputs.extend([self.sdk + '/usr/lib/swift/'])
102109
self.frameworks = [
103110
self.sdk + '/System/Library/Frameworks/',
104111
os.path.realpath(self.sdk + '/../../Library/Frameworks/')]
112+
if self.platform.startswith('iosmac'):
113+
# Catalyst modules need this extra framework dir
114+
iOSSupport = self.sdk + \
115+
'/System/iOSSupport/System/Library/Frameworks'
116+
self.frameworks.extend([iOSSupport])
105117

106118
def run(self, output, module, swift_ver, opts, verbose,
107119
module_filter_flags, include_fixed_clang_modules,
@@ -110,15 +122,19 @@ def run(self, output, module, swift_ver, opts, verbose,
110122
self.target, '-dump-sdk', '-module-cache-path',
111123
'/tmp/ModuleCache', '-swift-version',
112124
swift_ver, '-abort-on-module-fail']
125+
_environ = dict(os.environ)
126+
_environ['SWIFT_FORCE_MODULE_LOADING'] = 'prefer-interface'
113127
for path in self.frameworks:
114128
cmd.extend(['-iframework', path])
129+
for path in self.inputs:
130+
cmd.extend(['-I', path])
115131
cmd.extend(['-' + o for o in opts])
116132
if verbose:
117133
cmd.extend(['-v'])
118134
if module:
119135
cmd.extend(['-module', module])
120136
cmd.extend(['-o', output])
121-
check_call(cmd, verbose=verbose)
137+
check_call(cmd, env=_environ, verbose=verbose)
122138
else:
123139
with tempfile.NamedTemporaryFile() as tmp:
124140
prepare_module_list(self.platform, tmp, verbose,
@@ -138,11 +154,11 @@ def run(self, output, module, swift_ver, opts, verbose,
138154
current_cmd = list(cmd)
139155
current_cmd.extend(['-module', module])
140156
current_cmd.extend(['-o', file_path])
141-
check_call(current_cmd, verbose=verbose)
157+
check_call(current_cmd, env=_environ, verbose=verbose)
142158
else:
143159
cmd.extend(['-o', output])
144160
cmd.extend(['-module-list-file', tmp.name])
145-
check_call(cmd, verbose=verbose)
161+
check_call(cmd, env=_environ, verbose=verbose)
146162

147163

148164
class DiagnoseConfig:

0 commit comments

Comments
 (0)