@@ -47,15 +47,15 @@ def get_sdk_path(platform):
47
47
return check_output (['xcrun' , '-sdk' , platform , '-show-sdk-path' ])
48
48
49
49
50
- def prepare_module_list (platform , file , verbose , swift_frameworks_only ):
50
+ def prepare_module_list (platform , file , verbose , module_filter_flags ,
51
+ include_fixed_modules ):
51
52
cmd = [INFER_IMPORT_PATH , '-s' , get_sdk_path (platform )]
52
- if swift_frameworks_only :
53
- cmd .extend (['--swift-frameworks-only' ])
53
+ cmd .extend (module_filter_flags )
54
54
if verbose :
55
55
cmd .extend (['--v' ])
56
56
check_call (cmd , output = file )
57
57
# The fixed modules are all objc frameworks.
58
- if swift_frameworks_only :
58
+ if not include_fixed_modules :
59
59
return
60
60
with open (INFER_IMPORT_DIR + '/fixed-modules-common.txt' , 'r' ) as extra :
61
61
file .write (extra .read ())
@@ -92,7 +92,7 @@ def __init__(self, tool_path, platform):
92
92
os .path .realpath (self .sdk + '/../../Library/Frameworks/' )]
93
93
94
94
def run (self , output , module , swift_ver , opts , verbose ,
95
- swift_frameworks_only , separate_by_module ):
95
+ module_filter_flags , include_fixed_modules , separate_by_module ):
96
96
cmd = [self .tool_path , '-sdk' , self .sdk , '-target' ,
97
97
self .target , '-dump-sdk' , '-module-cache-path' ,
98
98
'/tmp/ModuleCache' , '-swift-version' ,
@@ -109,7 +109,7 @@ def run(self, output, module, swift_ver, opts, verbose,
109
109
else :
110
110
with tempfile .NamedTemporaryFile () as tmp :
111
111
prepare_module_list (self .platform , tmp , verbose ,
112
- swift_frameworks_only )
112
+ module_filter_flags , include_fixed_modules )
113
113
if separate_by_module :
114
114
tmp .seek (0 )
115
115
create_directory (output )
@@ -177,9 +177,9 @@ def main():
177
177
name of the module/framework to generate baseline, e.g. Foundation
178
178
''' )
179
179
180
- basic_group .add_argument ('--swift-frameworks-only' ,
181
- action = 'store_true' ,
182
- help = 'Only include Swift frameworks in the dump ' )
180
+ basic_group .add_argument ('--module-filter' , default = '' , help = '''
181
+ the action to perform for swift-api-digester
182
+ '' ' )
183
183
184
184
basic_group .add_argument ('--opts' , nargs = '+' , default = [], help = '''
185
185
additional flags to pass to swift-api-digester
@@ -206,16 +206,29 @@ def main():
206
206
help = 'When importing entire SDK, dump content '
207
207
'seprately by module names' )
208
208
args = parser .parse_args (sys .argv [1 :])
209
+
209
210
if args .action == 'dump' :
210
211
if not args .target :
211
212
fatal_error ("Need to specify --target" )
212
213
if not args .output :
213
214
fatal_error ("Need to specify --output" )
215
+ if args .module_filter == '' :
216
+ module_filter_flags = []
217
+ include_fixed_modules = True
218
+ elif args .module_filter == 'swift-frameworks-only' :
219
+ module_filter_flags = ['--swift-frameworks-only' ]
220
+ include_fixed_modules = False
221
+ elif args .module_filter == 'swift-overlay-only' :
222
+ module_filter_flags = ['--swift-overlay-only' ]
223
+ include_fixed_modules = False
224
+ else :
225
+ fatal_error ("cannot recognize --module-filter" )
214
226
runner = DumpConfig (tool_path = args .tool_path , platform = args .target )
215
227
runner .run (output = args .output , module = args .module ,
216
228
swift_ver = args .swift_version , opts = args .opts ,
217
229
verbose = args .v ,
218
- swift_frameworks_only = args .swift_frameworks_only ,
230
+ module_filter_flags = module_filter_flags ,
231
+ include_fixed_modules = include_fixed_modules ,
219
232
separate_by_module = args .separate_by_module )
220
233
elif args .action == 'diagnose' :
221
234
if not args .dump_before :
0 commit comments