@@ -30,7 +30,7 @@ def escapeCmdArg(arg):
30
30
return arg
31
31
32
32
33
- def check_call (cmd , cwd = None , env = os .environ , verbose = True , output = None ):
33
+ def check_call (cmd , cwd = None , env = os .environ , verbose = False , output = None ):
34
34
if verbose :
35
35
print (' ' .join ([escapeCmdArg (arg ) for arg in cmd ]))
36
36
return subprocess .check_call (cmd , cwd = cwd , env = env ,
@@ -73,7 +73,7 @@ def __init__(self, platform):
73
73
self .tool_path = check_output (['xcrun' , '--find' ,
74
74
'swift-api-digester' ])
75
75
76
- def run (self , output , module , swift_ver , abi ):
76
+ def run (self , output , module , swift_ver , abi , verbose ):
77
77
cmd = [self .tool_path , '-o' , output , '-sdk' , self .sdk , '-target' ,
78
78
self .target , '-dump-sdk' , '-module-cache-path' ,
79
79
'/tmp/ModuleCache' , '-swift-version' ,
@@ -82,14 +82,33 @@ def run(self, output, module, swift_ver, abi):
82
82
cmd .extend (['-iframework' , path ])
83
83
if abi :
84
84
cmd .extend (['-abi' ])
85
+ if verbose :
86
+ cmd .extend (['-v' ])
85
87
if module :
86
88
cmd .extend (['-module' , module ])
87
- check_call (cmd )
89
+ check_call (cmd , verbose = verbose )
88
90
else :
89
91
with tempfile .NamedTemporaryFile () as tmp :
90
92
prepare_module_list (self .platform , tmp )
91
93
cmd .extend (['-module-list-file' , tmp .name ])
92
- check_call (cmd )
94
+ check_call (cmd , verbose = verbose )
95
+
96
+
97
+ class DiagnoseConfig :
98
+ def __init__ (self ):
99
+ self .tool_path = check_output (['xcrun' , '--find' ,
100
+ 'swift-api-digester' ])
101
+
102
+ def run (self , abi , before , after , output , verbose ):
103
+ cmd = [self .tool_path , '-diagnose-sdk' , '-input-paths' , before ,
104
+ '-input-paths' , after ]
105
+ if output :
106
+ cmd .extend (['-o' , output ])
107
+ if abi :
108
+ cmd .extend (['-abi' ])
109
+ if verbose :
110
+ cmd .extend (['-v' ])
111
+ check_call (cmd , verbose = verbose )
93
112
94
113
95
114
def main ():
@@ -124,18 +143,39 @@ def main():
124
143
action = 'store_true' ,
125
144
help = 'Whether we are jsonizing for abi' )
126
145
127
- args = parser .parse_args (sys .argv [1 :])
128
- if not args .target :
129
- fatal_error ("Need to specify --target" )
130
- if not args .output :
131
- fatal_error ("Need to specify --output" )
146
+ basic_group .add_argument ('--v' ,
147
+ action = 'store_true' ,
148
+ help = 'Process verbosely' )
149
+
150
+ basic_group .add_argument ('--dump-before' ,
151
+ action = None ,
152
+ help = '''
153
+ Path to the json file generated before change'
154
+ ''' )
132
155
156
+ basic_group .add_argument ('--dump-after' ,
157
+ action = None ,
158
+ help = '''
159
+ Path to the json file generated after change
160
+ ''' )
161
+
162
+ args = parser .parse_args (sys .argv [1 :])
133
163
if args .action == 'dump' :
164
+ if not args .target :
165
+ fatal_error ("Need to specify --target" )
166
+ if not args .output :
167
+ fatal_error ("Need to specify --output" )
134
168
runner = DumpConfig (platform = args .target )
135
169
runner .run (output = args .output , module = args .module ,
136
- swift_ver = args .swift_version , abi = args .abi )
170
+ swift_ver = args .swift_version , abi = args .abi , verbose = args . v )
137
171
elif args .action == 'diagnose' :
138
- fatal_error ('Not implemented' )
172
+ if not args .dump_before :
173
+ fatal_error ("Need to specify --dump-before" )
174
+ if not args .dump_after :
175
+ fatal_error ("Need to specify --dump-after" )
176
+ runner = DiagnoseConfig ()
177
+ runner .run (abi = args .abi , before = args .dump_before ,
178
+ after = args .dump_after , output = args .output , verbose = args .v )
139
179
else :
140
180
fatal_error ('Cannot recognize action: ' + args .action )
141
181
0 commit comments