1
1
#!/usr/bin/env python
2
2
3
- # This tool dumps imported Swift APIs to help validate changes in the
4
- # Clang importer and its heuristics. One can execute it to dump the
5
- # API of a given module within a particular SDK, e.g., UIKit from the
6
- # iOS SDK as seen in Swift 3 after the "grand renaming":
3
+ # This tool dumps imported Swift APIs to help validate changes in the projection
4
+ # of (Objective-)C APIs into Swift, which is a function of the (Objective-)C
5
+ # APIs, any API notes added on top of those APIs, and the Clang importer
6
+ # itself. One can execute it to dump the API of a given module within a
7
+ # particular SDK, e.g., UIKit from the iOS SDK as seen in Swift 3 compatibility
8
+ # mode:
7
9
#
8
- # /path/to/bin/dir/swift-api-dump.py -3 -o output-dir -m UIKit -s iphoneos
10
+ # /path/to/bin/dir/swift-api-dump.py -swift-version 3 -o output-dir -m UIKit -s iphoneos
9
11
#
10
- # The -3 argument indicates that we're using the Swift 3 Clang
11
- # importer rules. The "-m" argument can be omitted, in which case the
12
- # script will collect all of the frameworks in the named SDK(s) and
13
- # dump their APIs.
12
+ # The "-m" argument can be omitted, in which case the script will collect all of
13
+ # the frameworks in the named SDK(s) and dump their APIs.
14
14
#
15
15
# One can supply multiple SDKs, written as a list. For example, to
16
- # dump the API for all frameworks across OS X , iOS, watchOS, and tvOS,
17
- # with the Swift 3 rules , use:
16
+ # dump the API for all frameworks across macOS , iOS, watchOS, and tvOS,
17
+ # in Swift 4 , use:
18
18
#
19
- # /path/to/bin/dir/swift-api-dump.py -3 -o output-dir -s macosx iphoneos \
19
+ # /path/to/bin/dir/swift-api-dump.py -swift-version 4 -o output-dir -s macosx iphoneos \
20
20
# watchos appletvos
21
21
#
22
22
@@ -93,11 +93,15 @@ def create_parser():
93
93
help = 'Print extra information.' )
94
94
parser .add_argument ('-F' , '--framework-dir' , action = 'append' ,
95
95
help = 'Add additional framework directories' )
96
+ parser .add_argument ('-iframework' , '--system-framework-dir' , action = 'append' ,
97
+ help = 'Add additional system framework directories' )
96
98
parser .add_argument ('-I' , '--include-dir' , action = 'append' ,
97
99
help = 'Add additional include directories' )
98
100
parser .add_argument ('--enable-infer-import-as-member' , action = 'store_true' ,
99
101
help = 'Infer when a global could be imported as a ' +
100
102
'member.' )
103
+ parser .add_argument ('-swift-version' , type = int , metavar = 'N' ,
104
+ help = 'the Swift version to use' )
101
105
return parser
102
106
103
107
@@ -187,7 +191,7 @@ def dump_module_api((cmd, extra_dump_args, output_dir, module, quiet,
187
191
188
192
def pretty_sdk_name (sdk ):
189
193
if sdk .find ("macosx" ) == 0 :
190
- return 'OSX '
194
+ return 'macOS '
191
195
if sdk .find ("iphoneos" ) == 0 :
192
196
return 'iOS'
193
197
if sdk .find ("watchos" ) == 0 :
@@ -277,14 +281,16 @@ def main():
277
281
'-module-print-skip-overlay' ,
278
282
'-skip-unavailable' ,
279
283
'-skip-print-doc-comments' ,
280
- '-always-argument-labels' ,
281
284
'-skip-overrides'
282
285
]
283
286
284
- # Add -F / -I arguments.
287
+ # Add -F / -iframework / - I arguments.
285
288
if args .framework_dir :
286
289
for path in args .framework_dir :
287
290
cmd_common = cmd_common + ['-F' , path ]
291
+ if args .system_framework_dir :
292
+ for path in args .system_framework_dir :
293
+ cmd_common = cmd_common + ['-iframework' , path ]
288
294
if args .include_dir :
289
295
for path in args .include_dir :
290
296
cmd_common = cmd_common + ['-I' , path ]
@@ -293,6 +299,9 @@ def main():
293
299
extra_args = ['-skip-imports' ]
294
300
if args .enable_infer_import_as_member :
295
301
extra_args = extra_args + ['-enable-infer-import-as-member' ]
302
+ if args .swift_version :
303
+ extra_args = extra_args + ['-swift-version' , '%d' % args .swift_version ]
304
+
296
305
# Create a .swift file we can feed into swift-ide-test
297
306
subprocess .call (['touch' , source_filename ])
298
307
0 commit comments