@@ -47,21 +47,33 @@ def get_sdk_path(platform):
47
47
return check_output (['xcrun' , '-sdk' , platform , '-show-sdk-path' ])
48
48
49
49
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
+
50
65
def prepare_module_list (platform , file , verbose , module_filter_flags ,
51
- include_fixed_modules ):
66
+ include_fixed_clang_modules ):
52
67
cmd = [INFER_IMPORT_PATH , '-s' , get_sdk_path (platform )]
53
68
cmd .extend (module_filter_flags )
54
69
if verbose :
55
70
cmd .extend (['--v' ])
56
71
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 )
65
77
66
78
67
79
def get_api_digester_path (tool_path ):
@@ -92,7 +104,8 @@ def __init__(self, tool_path, platform):
92
104
os .path .realpath (self .sdk + '/../../Library/Frameworks/' )]
93
105
94
106
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 ):
96
109
cmd = [self .tool_path , '-sdk' , self .sdk , '-target' ,
97
110
self .target , '-dump-sdk' , '-module-cache-path' ,
98
111
'/tmp/ModuleCache' , '-swift-version' ,
@@ -109,11 +122,15 @@ def run(self, output, module, swift_ver, opts, verbose,
109
122
else :
110
123
with tempfile .NamedTemporaryFile () as tmp :
111
124
prepare_module_list (self .platform , tmp , verbose ,
112
- module_filter_flags , include_fixed_modules )
125
+ module_filter_flags ,
126
+ include_fixed_clang_modules )
113
127
if separate_by_module :
114
128
tmp .seek (0 )
115
129
create_directory (output )
116
130
for module in [name .strip () for name in tmp .readlines ()]:
131
+ # Skip comments
132
+ if module .startswith ('//' ):
133
+ continue
117
134
dir_path = os .path .realpath (output + '/' + module )
118
135
file_path = os .path .realpath (dir_path + '/' +
119
136
self .platform + '.json' )
@@ -214,21 +231,21 @@ def main():
214
231
fatal_error ("Need to specify --output" )
215
232
if args .module_filter == '' :
216
233
module_filter_flags = []
217
- include_fixed_modules = True
234
+ include_fixed_clang_modules = True
218
235
elif args .module_filter == 'swift-frameworks-only' :
219
236
module_filter_flags = ['--swift-frameworks-only' ]
220
- include_fixed_modules = False
237
+ include_fixed_clang_modules = False
221
238
elif args .module_filter == 'swift-overlay-only' :
222
239
module_filter_flags = ['--swift-overlay-only' ]
223
- include_fixed_modules = False
240
+ include_fixed_clang_modules = False
224
241
else :
225
242
fatal_error ("cannot recognize --module-filter" )
226
243
runner = DumpConfig (tool_path = args .tool_path , platform = args .target )
227
244
runner .run (output = args .output , module = args .module ,
228
245
swift_ver = args .swift_version , opts = args .opts ,
229
246
verbose = args .v ,
230
247
module_filter_flags = module_filter_flags ,
231
- include_fixed_modules = include_fixed_modules ,
248
+ include_fixed_clang_modules = include_fixed_clang_modules ,
232
249
separate_by_module = args .separate_by_module )
233
250
elif args .action == 'diagnose' :
234
251
if not args .dump_before :
0 commit comments