@@ -56,22 +56,27 @@ def prepare_module_list(platform, file):
56
56
file .write (extra .read ())
57
57
58
58
59
+ def get_api_digester_path (tool_path ):
60
+ if tool_path :
61
+ return tool_path
62
+ return check_output (['xcrun' , '--find' , 'swift-api-digester' ])
63
+
64
+
59
65
class DumpConfig :
60
- def __init__ (self , platform ):
66
+ def __init__ (self , tool_path , platform ):
61
67
target_map = {
62
68
'iphoneos' : 'arm64-apple-ios10.0' ,
63
69
'macosx' : 'x86_64-apple-macosx10.11' ,
64
70
'appletvos' : 'arm64-apple-tvos10.0' ,
65
71
'watchos' : 'armv7k-apple-watchos3.0' ,
66
72
}
73
+ self .tool_path = get_api_digester_path (tool_path )
67
74
self .platform = platform
68
75
self .target = target_map [platform ]
69
76
self .sdk = get_sdk_path (platform )
70
77
self .frameworks = [
71
78
self .sdk + '/System/Library/Frameworks/' ,
72
79
os .path .realpath (self .sdk + '/../../Library/Frameworks/' )]
73
- self .tool_path = check_output (['xcrun' , '--find' ,
74
- 'swift-api-digester' ])
75
80
76
81
def run (self , output , module , swift_ver , abi , verbose ):
77
82
cmd = [self .tool_path , '-o' , output , '-sdk' , self .sdk , '-target' ,
@@ -95,9 +100,8 @@ def run(self, output, module, swift_ver, abi, verbose):
95
100
96
101
97
102
class DiagnoseConfig :
98
- def __init__ (self ):
99
- self .tool_path = check_output (['xcrun' , '--find' ,
100
- 'swift-api-digester' ])
103
+ def __init__ (self , tool_path ):
104
+ self .tool_path = get_api_digester_path (tool_path )
101
105
102
106
def run (self , abi , before , after , output , verbose ):
103
107
cmd = [self .tool_path , '-diagnose-sdk' , '-input-paths' , before ,
@@ -119,6 +123,12 @@ def main():
119
123
''' )
120
124
121
125
basic_group = parser .add_argument_group ('Basic' )
126
+
127
+ basic_group .add_argument ('--tool-path' , default = None , help = '''
128
+ the path to a swift-api-digester; if not specified, the script will
129
+ use the one from the toolchain
130
+ ''' )
131
+
122
132
basic_group .add_argument ('--action' , default = '' , help = '''
123
133
the action to perform for swift-api-digester
124
134
''' )
@@ -165,15 +175,15 @@ def main():
165
175
fatal_error ("Need to specify --target" )
166
176
if not args .output :
167
177
fatal_error ("Need to specify --output" )
168
- runner = DumpConfig (platform = args .target )
178
+ runner = DumpConfig (tool_path = args . tool_path , platform = args .target )
169
179
runner .run (output = args .output , module = args .module ,
170
180
swift_ver = args .swift_version , abi = args .abi , verbose = args .v )
171
181
elif args .action == 'diagnose' :
172
182
if not args .dump_before :
173
183
fatal_error ("Need to specify --dump-before" )
174
184
if not args .dump_after :
175
185
fatal_error ("Need to specify --dump-after" )
176
- runner = DiagnoseConfig ()
186
+ runner = DiagnoseConfig (tool_path = args . tool_path )
177
187
runner .run (abi = args .abi , before = args .dump_before ,
178
188
after = args .dump_after , output = args .output , verbose = args .v )
179
189
else :
0 commit comments