Skip to content

Commit d388bac

Browse files
committed
swift-api-checker: rename existing fixed-module lists to fixed-clang-modules
This patch also adds fixed-swift-modules to hard-code CreateML, which could not be found in the regular framework search path.
1 parent 0cdfda0 commit d388bac

11 files changed

+37
-15
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
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+
CreateML
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: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -47,21 +47,33 @@ def get_sdk_path(platform):
4747
return check_output(['xcrun', '-sdk', platform, '-show-sdk-path'])
4848

4949

50+
def write_fixed_module(file, platform, infix, verbose):
51+
common_modules_path = os.path.join(INFER_IMPORT_DIR, 'fixed-' + infix +
52+
'-modules-common.txt')
53+
platform_modules_path = os.path.join(INFER_IMPORT_DIR, 'fixed-' + infix +
54+
'-modules-' + platform + '.txt')
55+
with open(common_modules_path, 'r') as extra:
56+
if verbose:
57+
print('Including modules in: ' + common_modules_path)
58+
file.write(extra.read())
59+
with open(platform_modules_path, 'r') as extra:
60+
if verbose:
61+
print('Including modules in: ' + platform_modules_path)
62+
file.write(extra.read())
63+
64+
5065
def prepare_module_list(platform, file, verbose, module_filter_flags,
51-
include_fixed_modules):
66+
include_fixed_clang_modules):
5267
cmd = [INFER_IMPORT_PATH, '-s', get_sdk_path(platform)]
5368
cmd.extend(module_filter_flags)
5469
if verbose:
5570
cmd.extend(['--v'])
5671
check_call(cmd, output=file)
57-
# The fixed modules are all objc frameworks.
58-
if not include_fixed_modules:
59-
return
60-
with open(INFER_IMPORT_DIR + '/fixed-modules-common.txt', 'r') as extra:
61-
file.write(extra.read())
62-
with open(INFER_IMPORT_DIR + '/fixed-modules-' + platform + '.txt',
63-
'r') as extra:
64-
file.write(extra.read())
72+
# Always include fixed swift modules
73+
write_fixed_module(file, platform, 'swift', verbose)
74+
# Check if we need fixed clang modules
75+
if include_fixed_clang_modules:
76+
write_fixed_module(file, platform, 'clang', verbose)
6577

6678

6779
def get_api_digester_path(tool_path):
@@ -92,7 +104,8 @@ def __init__(self, tool_path, platform):
92104
os.path.realpath(self.sdk + '/../../Library/Frameworks/')]
93105

94106
def run(self, output, module, swift_ver, opts, verbose,
95-
module_filter_flags, include_fixed_modules, separate_by_module):
107+
module_filter_flags, include_fixed_clang_modules,
108+
separate_by_module):
96109
cmd = [self.tool_path, '-sdk', self.sdk, '-target',
97110
self.target, '-dump-sdk', '-module-cache-path',
98111
'/tmp/ModuleCache', '-swift-version',
@@ -109,11 +122,15 @@ def run(self, output, module, swift_ver, opts, verbose,
109122
else:
110123
with tempfile.NamedTemporaryFile() as tmp:
111124
prepare_module_list(self.platform, tmp, verbose,
112-
module_filter_flags, include_fixed_modules)
125+
module_filter_flags,
126+
include_fixed_clang_modules)
113127
if separate_by_module:
114128
tmp.seek(0)
115129
create_directory(output)
116130
for module in [name.strip() for name in tmp.readlines()]:
131+
# Skip comments
132+
if module.startswith('//'):
133+
continue
117134
dir_path = os.path.realpath(output + '/' + module)
118135
file_path = os.path.realpath(dir_path + '/' +
119136
self.platform + '.json')
@@ -214,21 +231,21 @@ def main():
214231
fatal_error("Need to specify --output")
215232
if args.module_filter == '':
216233
module_filter_flags = []
217-
include_fixed_modules = True
234+
include_fixed_clang_modules = True
218235
elif args.module_filter == 'swift-frameworks-only':
219236
module_filter_flags = ['--swift-frameworks-only']
220-
include_fixed_modules = False
237+
include_fixed_clang_modules = False
221238
elif args.module_filter == 'swift-overlay-only':
222239
module_filter_flags = ['--swift-overlay-only']
223-
include_fixed_modules = False
240+
include_fixed_clang_modules = False
224241
else:
225242
fatal_error("cannot recognize --module-filter")
226243
runner = DumpConfig(tool_path=args.tool_path, platform=args.target)
227244
runner.run(output=args.output, module=args.module,
228245
swift_ver=args.swift_version, opts=args.opts,
229246
verbose=args.v,
230247
module_filter_flags=module_filter_flags,
231-
include_fixed_modules=include_fixed_modules,
248+
include_fixed_clang_modules=include_fixed_clang_modules,
232249
separate_by_module=args.separate_by_module)
233250
elif args.action == 'diagnose':
234251
if not args.dump_before:

0 commit comments

Comments
 (0)