Skip to content

Commit a4e4af0

Browse files
committed
Generalize omit-needless-words script to swift-api-dump.
The omit-needless-words script has grown into a more general "API dumping" script. Make it a bit more useful by installing it alongside swift-ide-test, symlinking it in the build directory next to swift-ide-test (for Swift developers), and defaulting to using the swift-ide-test in the same directory as the script. Now it's fairly easy to dump the API for a given SDK with, e.g., swift-api-dump.py -s iphoneos
1 parent 14b9196 commit a4e4af0

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

utils/CMakeLists.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,18 @@ swift_install_in_component(editor-integration
88
FILES swift-mode.el
99
DESTINATION "share/emacs/site-lisp")
1010

11+
swift_install_in_component(editor-integration
12+
FILES swift-mode.el
13+
DESTINATION "share/emacs/site-lisp")
14+
15+
swift_install_in_component(tools
16+
TARGETS swift-api-dump.py
17+
RUNTIME DESTINATION bin)
18+
19+
# Create a symlink for swift-api-dump.py in the bin directory
20+
add_custom_target(swift-api-dump ALL
21+
COMMAND
22+
"${CMAKE_COMMAND}" "-E" "create_symlink"
23+
"${CMAKE_CURRENT_SOURCE_DIR}/swift-api-dump.py"
24+
"${SWIFT_RUNTIME_OUTPUT_INTDIR}/swift-api-dump.py"
25+
COMMENT "Creating development symlink for swift-api-dump.py")

utils/omit-needless-words.py renamed to utils/swift-api-dump.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
#!/usr/bin/env python
22

3-
# This tool helps assess the impact of automatically applying
4-
# heuristics that omit 'needless' words from APIs imported from Clang
5-
# into Swift.
3+
# This tool helps dump the APIs of imported modules for a module, SDK,
4+
# or set of SDKs. It is primarily useful in determining the effect of
5+
# changes to the Clang importer.
66

77
from __future__ import print_function
88

99
import argparse
10+
import multiprocessing
1011
import os
1112
import re
1213
import subprocess
13-
import multiprocessing
14+
import sys
1415

1516
DEFAULT_TARGET_BASED_ON_SDK = {
1617
'macosx': 'x86_64-apple-macosx10.11',
@@ -46,6 +47,10 @@
4647
}
4748

4849
def create_parser():
50+
script_path = os.path.dirname(sys.argv[0])
51+
script_path = os.path.abspath(script_path)
52+
default_swift_ide_test = '%s/swift-ide-test' % (script_path)
53+
4954
parser = argparse.ArgumentParser(
5055
description="Determines the effects of omitting 'needless' words from imported APIs",
5156
prog='omit-needless-words.py',
@@ -54,7 +59,7 @@ def create_parser():
5459
parser.add_argument('-j', '--jobs', type=int, help='The number of parallel jobs to execute')
5560
parser.add_argument('-s', '--sdk', nargs='+', required=True, help="The SDKs to use.")
5661
parser.add_argument('-t', '--target', help="The target triple to use.")
57-
parser.add_argument('-i', '--swift-ide-test', default='swift-ide-test', help="The swift-ide-test executable.")
62+
parser.add_argument('-i', '--swift-ide-test', default=default_swift_ide_test, help="The swift-ide-test executable.")
5863
parser.add_argument('-3', '--swift-3', action='store_true', help="Use Swift 3 transformation")
5964
parser.add_argument('-o', '--output-dir', default=os.getcwd(), help='Directory to which the output will be emitted.')
6065
parser.add_argument('-q', '--quiet', action='store_true', help='Suppress printing of status messages.')

0 commit comments

Comments
 (0)